Compartir a través de


MailFileEditor Clase

Definición

Proporciona una interfaz de usuario para seleccionar y editar un nombre de archivo de correo de una propiedad en tiempo de diseño.

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
Herencia
MailFileEditor

Ejemplos

En el ejemplo de código siguiente se muestra cómo asociar una instancia de la MailFileEditor clase con una propiedad contenida en un control personalizado. Cuando la propiedad de control se edita en la superficie de diseño, la MailFileEditor clase proporciona la interfaz de usuario para seleccionar y editar un nombre de archivo de correo para el valor de propiedad.

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

Comentarios

La MailFileEditor clase es un UITypeEditor objeto que se puede usar en tiempo de diseño para seleccionar y editar un nombre de archivo de correo como una cadena y asignar la cadena a una propiedad de control. Por ejemplo, el EmbeddedMailObject control usa la MailFileEditor clase en tiempo de diseño para establecer el valor de la Path propiedad .

Utilice el EditorAttribute atributo para asociar con MailFileEditor una propiedad . Cuando la propiedad asociada se edita en la superficie de diseño, el host del diseñador llama al EditValue método . El EditValue método muestra un cuadro de diálogo para seleccionar un nombre de archivo de correo de una lista filtrada de archivos y devuelve el nombre de archivo seleccionado por el usuario. El GetEditStyle método indica el estilo de presentación de la interfaz de usuario.

Derive una clase de MailFileEditor para definir un editor personalizado para una propiedad de nombre de archivo de correo. Por ejemplo, una clase derivada puede invalidar el EditValue método y mostrar una OpenFileDialog instancia con un filtro o título de archivo de correo personalizado.

Constructores

MailFileEditor()

Inicializa una nueva instancia de la clase MailFileEditor.

Propiedades

Caption

Obtiene el título del cuadro de diálogo del editor.

Filter

Obtiene la cadena de filtro de archivos para el cuadro de diálogo (por ejemplo, "*.txt").

IsDropDownResizable

Obtiene un valor que indica si el usuario puede cambiar el tamaño de los editores desplegables.

(Heredado de UITypeEditor)
Options

Obtiene las opciones que el generador de direcciones URL va a utilizar.

(Heredado de UrlEditor)

Métodos

EditValue(IServiceProvider, Object)

Edita el valor del objeto especificado utilizando el estilo del editor indicado por el método GetEditStyle().

(Heredado de UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

Edite el valor del objeto especificado utilizando el estilo del editor proporcionado por el método GetEditStyle(ITypeDescriptorContext).

(Heredado de UrlEditor)
Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetEditStyle()

Obtiene el estilo de editor utilizado por el método EditValue(IServiceProvider, Object).

(Heredado de UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

Obtiene el estilo de edición del método EditValue(ITypeDescriptorContext, IServiceProvider, Object).

(Heredado de UrlEditor)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetPaintValueSupported()

Indica si este editor permite dibujar una representación del valor de un objeto.

(Heredado de UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

Indica si el contexto especificado permite dibujar una representación del valor de un objeto dentro de ese contexto.

(Heredado de UITypeEditor)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
PaintValue(Object, Graphics, Rectangle)

Dibuja una representación del valor del objeto especificado en el lienzo indicado.

(Heredado de UITypeEditor)
PaintValue(PaintValueEventArgs)

Dibuja una representación del valor de un objeto utilizando el PaintValueEventArgs especificado.

(Heredado de UITypeEditor)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a

Consulte también