XslTransformFileEditor Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce un'interfaccia utente in fase di progettazione per la selezione di un file di trasformazione 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
- Ereditarietà
Esempio
Nell'esempio di codice seguente viene illustrato come associare un'istanza della XslTransformFileEditor classe a una proprietà contenuta in un controllo personalizzato. Quando la proprietà del controllo viene modificata nell'area di progettazione, la XslTransformFileEditor classe consente all'interfaccia utente di selezionare e modificare un nome di file di trasformazione XML per il valore della proprietà.
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
Commenti
Un XslTransformFileEditor oggetto viene utilizzato in fase di progettazione per selezionare e modificare un URL per un file di trasformazione XML (xsl) e per assegnare l'URL a una proprietà del controllo. Ad esempio, il XmlDataSource controllo usa la XslTransformFileEditor classe in fase di progettazione per impostare il valore della TransformFile proprietà .
Utilizzare l'attributo per associare l'oggetto EditorAttributeXslTransformFileEditor a una proprietà . Quando la proprietà associata viene modificata nell'area di progettazione, l'host della finestra di progettazione chiama il EditValue metodo . Il EditValue metodo usa il BuildUrl metodo , che a sua volta visualizza un'interfaccia utente per la selezione dell'URL e quindi restituisce l'URL selezionato dall'utente. Il GetEditStyle metodo indica lo stile di visualizzazione dell'interfaccia utente.
Derivare una classe da XslTransformFileEditor per definire un editor personalizzato per una proprietà URL del file di trasformazione XML. Ad esempio, una classe derivata può eseguire l'override del EditValue metodo e quindi chiamare il BuildUrl metodo con un valore o Caption personalizzatoFilter.
Costruttori
| Nome | Descrizione |
|---|---|
| XslTransformFileEditor() |
Inizializza una nuova istanza della classe XslTransformFileEditor. |
Proprietà
| Nome | Descrizione |
|---|---|
| Caption |
Ottiene la didascalia da visualizzare nella finestra di dialogo di selezione. |
| Filter |
Ottiene le opzioni di filtro URL per l'editor, che viene utilizzato per filtrare gli elementi visualizzati nella finestra di dialogo di selezione URL. |
| IsDropDownResizable |
Ottiene un valore che indica se gli editor a discesa devono essere ridimensionati dall'utente. (Ereditato da UITypeEditor) |
| Options |
Ottiene le opzioni da usare per il generatore di URL. (Ereditato da UrlEditor) |
Metodi
| Nome | Descrizione |
|---|---|
| EditValue(IServiceProvider, Object) |
Modifica il valore dell'oggetto specificato utilizzando lo stile dell'editor indicato dal GetEditStyle() metodo . (Ereditato da UITypeEditor) |
| EditValue(ITypeDescriptorContext, IServiceProvider, Object) |
Modifica il valore dell'oggetto specificato utilizzando lo stile dell'editor fornito dal GetEditStyle(ITypeDescriptorContext) metodo . (Ereditato da UrlEditor) |
| Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
| GetEditStyle() |
Ottiene lo stile dell'editor utilizzato dal EditValue(IServiceProvider, Object) metodo . (Ereditato da UITypeEditor) |
| GetEditStyle(ITypeDescriptorContext) |
Ottiene lo stile di modifica del EditValue(ITypeDescriptorContext, IServiceProvider, Object) metodo . (Ereditato da UrlEditor) |
| GetHashCode() |
Funge da funzione hash predefinita. (Ereditato da Object) |
| GetPaintValueSupported() |
Indica se questo editor supporta il disegno di una rappresentazione del valore di un oggetto. (Ereditato da UITypeEditor) |
| GetPaintValueSupported(ITypeDescriptorContext) |
Indica se il contesto specificato supporta il disegno di una rappresentazione del valore di un oggetto all'interno del contesto specificato. (Ereditato da UITypeEditor) |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| PaintValue(Object, Graphics, Rectangle) |
Disegna una rappresentazione del valore dell'oggetto specificato nell'area di disegno specificata. (Ereditato da UITypeEditor) |
| PaintValue(PaintValueEventArgs) |
Disegna una rappresentazione del valore di un oggetto utilizzando l'oggetto specificato PaintValueEventArgs. (Ereditato da UITypeEditor) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |