MailFileEditor クラス

定義

デザイン時にプロパティのメール ファイル名を選択および編集するためのユーザー インターフェイスを提供します。

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
継承
MailFileEditor

次のコード例は、クラスの MailFileEditor インスタンスを、カスタム コントロール内に含まれるプロパティに関連付ける方法を示しています。 デザイン 画面でコントロール プロパティを編集すると、 MailFileEditor クラスは、プロパティ値のメール ファイル名を選択および編集するためのユーザー インターフェイスを提供します。

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

注釈

この MailFileEditor クラスは、 UITypeEditor デザイン時にメール ファイル名を選択して編集し、文字列として使用し、その文字列をコントロール プロパティに割り当てるために使用できるオブジェクトです。 たとえば、コントロールは EmbeddedMailObject デザイン時にクラスを MailFileEditor 使用して、プロパティの値を Path 設定します。

属性を EditorAttribute 使用して、プロパティに MailFileEditor 関連付けます。 デザイン 画面で関連付けられているプロパティを編集すると、デザイナー ホストはメソッドを EditValue 呼び出します。 このメソッドは EditValue 、フィルター処理されたファイルの一覧からメール ファイル名を選択するためのダイアログ ボックスを表示し、ユーザーが選択したファイル名を返します。 このメソッドは GetEditStyle 、ユーザー インターフェイスの表示スタイルを示します。

メール ファイル名プロパティの MailFileEditor カスタム エディターを定義するクラスを派生させます。 たとえば、派生クラスはメソッドを EditValue オーバーライドし、カスタム メール ファイル フィルターまたはタイトルを OpenFileDialog 使用してインスタンスを表示できます。

コンストラクター

MailFileEditor()

MailFileEditor クラスの新しいインスタンスを初期化します。

プロパティ

Caption

エディター ダイアログのキャプションを取得します。

Filter

ダイアログのファイル フィルター文字列 ("*.txt" など) を取得します。

IsDropDownResizable

ユーザーがドロップダウン エディターのサイズを変更できるかどうかを示す値を取得します。

(継承元 UITypeEditor)
Options

使用する URL ビルダーのオプションを取得します。

(継承元 UrlEditor)

メソッド

EditValue(IServiceProvider, Object)

GetEditStyle() メソッドで提供されたエディター スタイルを使用して、指定したオブジェクトの値を編集します。

(継承元 UITypeEditor)
EditValue(ITypeDescriptorContext, IServiceProvider, Object)

GetEditStyle(ITypeDescriptorContext) メソッドで提供されたエディター スタイルを使用して、指定したオブジェクトの値を編集します。

(継承元 UrlEditor)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetEditStyle()

EditValue(IServiceProvider, Object) メソッドで使用するエディター スタイルを取得します。

(継承元 UITypeEditor)
GetEditStyle(ITypeDescriptorContext)

EditValue(ITypeDescriptorContext, IServiceProvider, Object) メソッドの編集スタイルを取得します。

(継承元 UrlEditor)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetPaintValueSupported()

エディターでオブジェクトの値の視覚的な表現を描画できるかどうかを示します。

(継承元 UITypeEditor)
GetPaintValueSupported(ITypeDescriptorContext)

指定したコンテキスト内でオブジェクトの値の視覚的な表現を描画できるかどうかを示します。

(継承元 UITypeEditor)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
PaintValue(Object, Graphics, Rectangle)

指定したキャンバスに、指定したオブジェクトの値の視覚的な表現を描画します。

(継承元 UITypeEditor)
PaintValue(PaintValueEventArgs)

指定した PaintValueEventArgs を使用して、オブジェクトの値の視覚的な表現を描画します。

(継承元 UITypeEditor)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください