Sdílet prostřednictvím


XmlDataFileEditor Třída

Definice

Poskytuje uživatelské rozhraní návrhu pro výběr datového souboru XML.

public ref class XmlDataFileEditor : System::Web::UI::Design::UrlEditor
public class XmlDataFileEditor : System.Web.UI.Design.UrlEditor
type XmlDataFileEditor = class
    inherit UrlEditor
Public Class XmlDataFileEditor
Inherits UrlEditor
Dědičnost
XmlDataFileEditor

Příklady

Následující příklad kódu ukazuje, jak přidružit instanci XmlDataFileEditor třídy k vlastnosti, která je obsažena v rámci vlastního ovládacího prvku. Když je vlastnost ovládacího prvku upravena na návrhové ploše, XmlDataFileEditor třída poskytuje uživatelské rozhraní pro výběr a úpravu názvu souboru XML pro hodnotu vlastnosti.

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 data file name property.  Indicate that the
        // property can be edited at design-time with the XmlDataFileEditor class.
        [EditorAttribute(typeof(System.Web.UI.Design.XmlDataFileEditor), 
                         typeof(System.Drawing.Design.UITypeEditor))]
        public string XmlFileName
        {
            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 data file name property.  Indicate that the
        ' property can be edited at design-time with the XmlDataFileEditor class.
        <EditorAttribute(GetType(System.Web.UI.Design.XmlDataFileEditor), _
                         GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property XmlFileName() 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

Poznámky

Objekt XmlDataFileEditor se používá v době návrhu k výběru a úpravě adresy URL datového souboru XML (.xml) a následnému přiřazení adresy URL vlastnosti ovládacího prvku. Například XmlDataSource ovládací prvek používá třídu v době návrhu XmlDataFileEditor k nastavení hodnoty DataFile vlastnosti.

Pomocí atributu EditorAttribute přidružte XmlDataFileEditor vlastnost. Když je přidružená vlastnost upravena na návrhové ploše, návrhář hostitel volá metodu EditValue . Metoda EditValue používá metodu BuildUrl , která zase zobrazí uživatelské rozhraní pro výběr adresy URL a poté vrátí adresu URL vybranou uživatelem. Metoda GetEditStyle označuje styl zobrazení uživatelského rozhraní.

Odvozujte třídu z XmlDataFileEditor definice vlastního editoru pro vlastnost dat XML. Odvozená třída může například přepsat metodu EditValue a poté volat metodu BuildUrl Filter vlastní nebo Caption hodnotou.

Konstruktory

XmlDataFileEditor()

Inicializuje novou instanci XmlDataFileEditor třídy.

Vlastnosti

Caption

Získá titulek, který se zobrazí v dialogovém okně výběru.

Filter

Získá možnosti filtru adresy URL pro editor, který slouží k filtrování položek, které se zobrazí v dialogovém okně pro výběr adresy URL.

IsDropDownResizable

Získá hodnotu označující, jestli má uživatel změnit velikost rozevíracích editorů.

(Zděděno od UITypeEditor)
Options

Získá možnosti pro tvůrce adres URL, které se mají použít.

(Zděděno od UrlEditor)

Metody

EditValue(IServiceProvider, Object)

Upraví hodnotu zadaného objektu pomocí stylu editoru označeného metodou GetEditStyle() .

(Zděděno od UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Upraví hodnotu zadaného objektu pomocí stylu editoru poskytnutého metodou GetEditStyle(ITypeDescriptorContext) .

(Zděděno od UrlEditor)
Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetEditStyle()

Získá styl editoru používaný metodou EditValue(IServiceProvider, Object) .

(Zděděno od UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Získá styl EditValue(ITypeDescriptorContext, IServiceProvider, Object) úprav metody.

(Zděděno od UrlEditor)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetPaintValueSupported()

Určuje, zda tento editor podporuje malování reprezentace hodnoty objektu.

(Zděděno od UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Určuje, zda zadaný kontext podporuje malování reprezentace hodnoty objektu v zadaném kontextu.

(Zděděno od UITypeEditor)
GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
PaintValue(Object, Graphics, Rectangle)

Nakreslí reprezentaci hodnoty zadaného objektu na zadané plátno.

(Zděděno od UITypeEditor)
PaintValue(PaintValueEventArgs)

Nakreslí reprezentaci hodnoty objektu pomocí zadaného PaintValueEventArgsobjektu .

(Zděděno od UITypeEditor)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také