XsdSchemaFileEditor Klasa

Definicja

Udostępnia interfejs użytkownika czasu projektowania do wybierania pliku definicji schematu XML.

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
Dziedziczenie
XsdSchemaFileEditor

Przykłady

W poniższym przykładzie kodu pokazano, jak skojarzyć wystąpienie XsdSchemaFileEditor klasy z właściwością zawartą w kontrolce niestandardowej. Gdy właściwość kontrolki jest edytowana na powierzchni projektowej, XsdSchemaFileEditor klasa udostępnia interfejs użytkownika do wybierania i edytowania nazwy pliku definicji schematu XML dla wartości właściwości.

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

Uwagi

Obiekt XsdSchemaFileEditor jest używany w czasie projektowania do wybierania i edytowania adresu URL pliku definicji schematu XML (xsd) oraz przypisywania adresu URL do właściwości kontrolki.

Użyj atrybutu EditorAttribute , aby skojarzyć XsdSchemaFileEditor właściwość z właściwością. Gdy skojarzona właściwość jest edytowana na powierzchni projektowej, host projektanta wywołuje metodę EditValue . Metoda EditValue używa BuildUrl metody , która z kolei wyświetla interfejs użytkownika do wybierania adresu URL, a następnie zwraca adres URL wybrany przez użytkownika. Metoda GetEditStyle wskazuje styl wyświetlania interfejsu użytkownika.

Utwórz klasę z klasy XsdSchemaFileEditor , aby zdefiniować edytor niestandardowy dla właściwości adresu URL schematu XML. Na przykład klasa pochodna może zastąpić EditValue metodę, a następnie wywołać BuildUrl metodę za pomocą niestandardowej Filter lub Caption wartości.

Konstruktory

XsdSchemaFileEditor()

Inicjuje nowe wystąpienie klasy XsdSchemaFileEditor.

Właściwości

Caption

Pobiera podpis do wyświetlenia w oknie dialogowym wyboru.

Filter

Pobiera opcje filtru adresu URL edytora, które są używane do filtrowania elementów wyświetlanych w oknie dialogowym wyboru adresu URL.

IsDropDownResizable

Pobiera wartość wskazującą, czy edytory listy rozwijanej powinny być zmienialne przez użytkownika.

(Odziedziczone po UITypeEditor)
Options

Pobiera opcje konstruktora adresów URL do użycia.

(Odziedziczone po UrlEditor)

Metody

EditValue(IServiceProvider, Object)

Edytuje wartość określonego obiektu przy użyciu stylu edytora wskazanego przez metodę GetEditStyle() .

(Odziedziczone po UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Edytuje wartość określonego obiektu przy użyciu stylu edytora dostarczonego przez metodę GetEditStyle(ITypeDescriptorContext) .

(Odziedziczone po UrlEditor)
Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEditStyle()

Pobiera styl edytora używany przez metodę EditValue(IServiceProvider, Object) .

(Odziedziczone po UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Pobiera styl edycji EditValue(ITypeDescriptorContext, IServiceProvider, Object) metody.

(Odziedziczone po UrlEditor)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetPaintValueSupported()

Wskazuje, czy ten edytor obsługuje malowanie reprezentacji wartości obiektu.

(Odziedziczone po UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Wskazuje, czy określony kontekst obsługuje malowanie reprezentacji wartości obiektu w określonym kontekście.

(Odziedziczone po UITypeEditor)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
PaintValue(Object, Graphics, Rectangle)

Maluje reprezentację wartości określonego obiektu na określoną kanwę.

(Odziedziczone po UITypeEditor)
PaintValue(PaintValueEventArgs)

Maluje reprezentację wartości obiektu przy użyciu określonego PaintValueEventArgsobiektu .

(Odziedziczone po UITypeEditor)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też