XsdSchemaFileEditor Classe

Definizione

Fornisce un'interfaccia utente in fase di progettazione per la selezione di un file di definizione di XML Schema.

public ref class XsdSchemaFileEditor : System::Web::UI::Design::UrlEditor
public class XsdSchemaFileEditor : System.Web.UI.Design.UrlEditor
type XsdSchemaFileEditor = class
    inherit UrlEditor
Public Class XsdSchemaFileEditor
Inherits UrlEditor
Ereditarietà
XsdSchemaFileEditor

Esempio

Nell'esempio di codice seguente viene illustrato come associare un'istanza della XsdSchemaFileEditor classe a una proprietà contenuta all'interno di un controllo personalizzato. Quando la proprietà del controllo viene modificata nell'area di progettazione, la XsdSchemaFileEditor classe fornisce l'interfaccia utente per selezionare e modificare un nome di file di definizione di XML Schema 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 schema file property.  Indicate that the
        // property can be edited at design-time with the XsdSchemaFileEditor class.
        [EditorAttribute(typeof(System.Web.UI.Design.XsdSchemaFileEditor), 
                         typeof(System.Drawing.Design.UITypeEditor))]
        public string SchemaFileName
        {
            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 XSD schema file name property.  Indicate that the
        ' property can be edited at design-time with the XsdSchemaFileEditor class.
        <EditorAttribute(GetType(System.Web.UI.Design.XsdSchemaFileEditor), _
                         GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property SchemaFileName() 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 XsdSchemaFileEditor oggetto viene usato in fase di progettazione per selezionare e modificare un URL per un file di definizione di XML Schema (con estensione xsd) e per assegnare l'URL a una proprietà del controllo.

Utilizzare l'attributo EditorAttribute per associare l'oggetto XsdSchemaFileEditor 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 XsdSchemaFileEditor per definire un editor personalizzato per una proprietà URL di XML Schema. 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

XsdSchemaFileEditor()

Inizializza una nuova istanza della classe XsdSchemaFileEditor.

Proprietà

Caption

Ottiene il titolo da visualizzare sulla finestra di dialogo di selezione.

Filter

Ottiene le opzioni di filtro URL per l'editor, utilizzate per filtrare gli elementi visualizzati nella finestra di dialogo di selezione URL.

IsDropDownResizable

Ottiene un valore che indica se gli editor a discesa possono essere ridimensionati dall'utente.

(Ereditato da UITypeEditor)
Options

Ottiene le opzioni utilizzabili dal generatore di URL.

(Ereditato da UrlEditor)

Metodi

EditValue(IServiceProvider, Object)

Modifica il valore dell'oggetto specificato, usando lo stile dell'editor indicato dal metodo GetEditStyle().

(Ereditato da UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Modifica il valore dell'oggetto specificato, utilizzando lo stile dell'editor fornito dal metodo GetEditStyle(ITypeDescriptorContext).

(Ereditato da UrlEditor)
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetEditStyle()

Ottiene lo stile dell'editor usato dal metodo EditValue(IServiceProvider, Object).

(Ereditato da UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Ottiene lo stile di modifica del metodo EditValue(ITypeDescriptorContext, IServiceProvider, Object).

(Ereditato da UrlEditor)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetPaintValueSupported()

Indica se questo editor supporta la rappresentazione grafica del valore di un oggetto.

(Ereditato da UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Indica se il contesto specificato supporta la rappresentazione grafica del valore di un oggetto all'interno del contesto specificato.

(Ereditato da UITypeEditor)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
PaintValue(Object, Graphics, Rectangle)

Descrive graficamente il valore dell'oggetto specificato sulla superficie specificata.

(Ereditato da UITypeEditor)
PaintValue(PaintValueEventArgs)

Descrive graficamente il valore di un oggetto usando la classe PaintValueEventArgs specificata.

(Ereditato da UITypeEditor)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a

Vedi anche