Sdílet prostřednictvím


MailFileEditor Třída

Definice

Poskytuje uživatelské rozhraní pro výběr a úpravu názvu souboru pošty pro vlastnost v době návrhu.

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

Příklady

Následující příklad kódu ukazuje, jak přidružit instanci MailFileEditor třídy k vlastnosti, která je obsažena v rámci vlastního ovládacího prvku. Při úpravě vlastnosti ovládacího prvku v návrhové ploše MailFileEditor poskytuje třída uživatelské rozhraní pro výběr a úpravu názvu poštovního souboru 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;

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 file name property.  Indicate that the
        // property can be edited at design-time with the MailFileEditor class.
        [EditorAttribute(typeof(System.Web.UI.Design.MailFileEditor), 
                         typeof(System.Drawing.Design.UITypeEditor))]
        public string MailFileName
        {
            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 (System.IO.File.Exists(_filename))
                    {
                        DateTime lastChangedStamp = System.IO.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

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 mail file name property.  Indicate that the
        ' property can be edited at design-time with the MailFileEditor class.
        <EditorAttribute(GetType(System.Web.UI.Design.MailFileEditor), _
                         GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property MailFileName() 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 System.IO.File.Exists(_filename) Then
                        Dim lastChangedStamp As DateTime
                        lastChangedStamp = System.IO.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

Třída MailFileEditor je UITypeEditor objekt, který lze použít v době návrhu k výběru a úpravě názvu poštovního souboru jako řetězce a přiřazení řetězce k ovládací vlastnosti. Například EmbeddedMailObject ovládací prvek používá MailFileEditor třídu v době návrhu k nastavení hodnoty Path vlastnosti.

Pomocí atributu EditorAttribute přidružte MailFileEditor vlastnost. Pokud je přidružená vlastnost upravena na návrhové ploše, hostitel návrháře volá metodu EditValue . Metoda EditValue zobrazí dialogové okno pro výběr názvu poštovního souboru z filtrovaného seznamu souborů a vrátí název souboru, který je vybrán uživatelem. Metoda GetEditStyle označuje styl zobrazení uživatelského rozhraní.

Odvozujte třídu z MailFileEditor definice vlastního editoru pro vlastnost názvu souboru pošty. Odvozená třída může například přepsat metodu EditValue a zobrazit OpenFileDialog instanci s vlastním filtrem nebo názvem poštovního souboru.

Konstruktory

MailFileEditor()

Inicializuje novou instanci MailFileEditor třídy.

Vlastnosti

Caption

Získá titulek dialogového okna editoru.

Filter

Získá řetězec filtru souboru pro dialogové okno (například "*.txt").

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é