XslTransformFileEditor Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Proporciona una interfaz de usuario en tiempo de diseño para seleccionar un archivo de transformación XML.
public ref class XslTransformFileEditor : System::Web::UI::Design::UrlEditor
public class XslTransformFileEditor : System.Web.UI.Design.UrlEditor
type XslTransformFileEditor = class
inherit UrlEditor
Public Class XslTransformFileEditor
Inherits UrlEditor
- Herencia
Ejemplos
En el ejemplo de código siguiente se muestra cómo asociar una instancia de la XslTransformFileEditor clase a una propiedad contenida en un control personalizado. Cuando la propiedad de control se edita en la superficie de diseño, la XslTransformFileEditor clase permite que la interfaz de usuario seleccione y edite un nombre de archivo de transformación XML para el valor de propiedad.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.IO;
namespace ControlDesignerSamples.CS
{
// Define a simple text control, derived from the
// System.Web.UI.WebControls.Label class.
[
Designer(typeof(TextControlDesigner))
]
public class SimpleTextControl : Label
{
// Define a private member to store the file name value in the control.
private string _filename = "";
private string _internalText = "";
// Define the public XML transform file property. Indicate that the
// property can be edited at design-time with the XslTransformFileEditor class.
[EditorAttribute(typeof(System.Web.UI.Design.XslTransformFileEditor),
typeof(System.Drawing.Design.UITypeEditor))]
public string TransformFileName
{
get
{
return _filename;
}
set
{
_filename = value;
}
}
// Define a property that returns the timestamp
// for the selected file.
public string LastChanged
{
get
{
if ((_filename != null) && (_filename.Length > 0))
{
if (File.Exists(_filename))
{
DateTime lastChangedStamp = File.GetLastWriteTime(_filename);
return lastChangedStamp.ToLongDateString();
}
}
return "";
}
}
// Override the control Text property, setting the default
// text to the LastChanged string value for the selected
// file name. If the file name has not been set in the
// design view, then default to an empty string.
public override string Text
{
get
{
if ((_internalText == "") && (LastChanged.Length > 0))
{
// If the internally stored value hasn't been set,
// and the file name property has been set,
// return the last changed timestamp for the file.
_internalText = LastChanged;
}
return _internalText;
}
set
{
if ((value != null) && (value.Length > 0))
{
_internalText = value;
}
else {
_internalText = "";
}
}
}
}
}
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls
Imports System.IO
Namespace ControlDesignerSamples.VB
' Define a simple text control, derived from the
' System.Web.UI.WebControls.Label class.
<Designer(GetType(TextControlDesigner))> _
Public Class SimpleTextControl
Inherits Label
' Define a private member to store the file name value in the control.
Private _filename As String = ""
Private _internalText As String = ""
' Define the public XML transform file property. Indicate that the
' property can be edited at design-time with the XslTransformFileEditor class.
<EditorAttribute(GetType(System.Web.UI.Design.XslTransformFileEditor), _
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property TransformFileName() As String
Get
Return _filename
End Get
Set(ByVal value As String)
_filename = value
End Set
End Property
' Define a property that returns the timestamp
' for the selected file.
Public ReadOnly Property LastChanged() As String
Get
If Not _filename Is Nothing AndAlso _filename.Length > 0 Then
If File.Exists(_filename) Then
Dim lastChangedStamp As DateTime
lastChangedStamp = File.GetLastWriteTime(_filename)
Return lastChangedStamp.ToLongDateString()
End If
End If
Return String.Empty
End Get
End Property
' Override the control Text property, setting the default
' text to the LastChanged string value for the selected
' file name. If the file name has not been set in the
' design view, then default to an empty string.
Public Overrides Property Text() As String
Get
If _internalText.Length = 0 And LastChanged.Length > 0 Then
' If the internally stored value hasn't been set,
' and the file name property has been set,
' return the last changed timestamp for the file.
_internalText = LastChanged
End If
Return _internalText
End Get
Set(ByVal value As String)
If Not value Is Nothing AndAlso value.Length > 0 Then
_internalText = value
Else
_internalText = String.Empty
End If
End Set
End Property
End Class
End Namespace
Comentarios
Un XslTransformFileEditor objeto se usa en tiempo de diseño para seleccionar y editar una dirección URL para un archivo de transformación XML (.xsl) y para asignar la dirección URL a una propiedad de control. Por ejemplo, el XmlDataSource control usa la XslTransformFileEditor clase en tiempo de diseño para establecer el valor de la TransformFile propiedad .
Use el EditorAttribute atributo para asociar el XslTransformFileEditor objeto a una propiedad . Cuando la propiedad asociada se edita en la superficie de diseño, el host del diseñador llama al EditValue método . El EditValue método usa el BuildUrl método , que a su vez muestra una interfaz de usuario para seleccionar la dirección URL y, a continuación, devuelve la dirección URL seleccionada por el usuario. El GetEditStyle método indica el estilo de presentación de la interfaz de usuario.
Derive una clase de XslTransformFileEditor para definir un editor personalizado para una propiedad URL de archivo de transformación XML. Por ejemplo, una clase derivada puede invalidar el EditValue método y, a continuación, llamar al BuildUrl método con un valor o Caption personalizadoFilter.
Constructores
| Nombre | Description |
|---|---|
| XslTransformFileEditor() |
Inicializa una nueva instancia de la clase XslTransformFileEditor. |
Propiedades
| Nombre | Description |
|---|---|
| Caption |
Obtiene el título que se va a mostrar en el cuadro de diálogo de selección. |
| Filter |
Obtiene las opciones de filtro de dirección URL para el editor, que se usa para filtrar los elementos que aparecen en el cuadro de diálogo selección de dirección URL. |
| IsDropDownResizable |
Obtiene un valor que indica si el usuario debe cambiar el tamaño de los editores desplegables. (Heredado de UITypeEditor) |
| Options |
Obtiene las opciones del generador de direcciones URL que se va a usar. (Heredado de UrlEditor) |
Métodos
| Nombre | Description |
|---|---|
| EditValue(IServiceProvider, Object) |
Edita el valor del objeto especificado utilizando el estilo del editor indicado por el GetEditStyle() método . (Heredado de UITypeEditor) |
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) |
Edita el valor del objeto especificado mediante el estilo del editor proporcionado por el GetEditStyle(ITypeDescriptorContext) método . (Heredado de UrlEditor) |
| Equals(Object) |
Determina si el objeto especificado es igual al objeto actual. (Heredado de Object) |
| GetEditStyle() |
Obtiene el estilo del editor utilizado por el EditValue(IServiceProvider, Object) método . (Heredado de UITypeEditor) |
| GetEditStyle(ITypeDescriptorContext) |
Obtiene el estilo de edición del EditValue(ITypeDescriptorContext, IServiceProvider, Object) método . (Heredado de UrlEditor) |
| GetHashCode() |
Actúa como función hash predeterminada. (Heredado de Object) |
| GetPaintValueSupported() |
Indica si este editor admite pintar una representación del valor de un objeto. (Heredado de UITypeEditor) |
| GetPaintValueSupported(ITypeDescriptorContext) |
Indica si el contexto especificado admite pintar una representación del valor de un objeto dentro del contexto especificado. (Heredado de UITypeEditor) |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| PaintValue(Object, Graphics, Rectangle) |
Pinta una representación del valor del objeto especificado en el lienzo especificado. (Heredado de UITypeEditor) |
| PaintValue(PaintValueEventArgs) |
Pinta una representación del valor de un objeto utilizando el especificado PaintValueEventArgs. (Heredado de UITypeEditor) |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |