次の方法で共有


DrawingAttributes.ExtendedProperties プロパティ

アプリケーションで定義したデータのコレクションを取得します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
Public ReadOnly Property ExtendedProperties As ExtendedProperties
'使用
Dim instance As DrawingAttributes
Dim value As ExtendedProperties

value = instance.ExtendedProperties
public ExtendedProperties ExtendedProperties { get; }
public:
property ExtendedProperties^ ExtendedProperties {
    ExtendedProperties^ get ();
}
/** @property */
public ExtendedProperties get_ExtendedProperties()
public function get ExtendedProperties () : ExtendedProperties

プロパティ値

型 : Microsoft.Ink.ExtendedProperties
アプリケーションで定義したデータのコレクション。

解説

アプリケーションで ExtendedProperties プロパティを使用し、DrawingAttributes オブジェクトに格納されているカスタム データにアクセスできます。このカスタム データは、オブジェクトによって自動的にシリアル化されます。

この C# の例では、3 種類のインク (細い黒色のペン、太い青色のマーカー、および黄色の蛍光ペン) だけが使用できるインク対応アプリケーションが含まれています。DrawingAttributes オブジェクト availableDrawingAttributes の配列は、これらの 3 つのオプションのために作成され、各オプションには識別のための GUID drawingAttributesNameId が付与されています。InitializeDrawingAttributes メソッドがコンストラクタで呼び出され、ユーザーがペンを変更するたびに ChangeDrawingAttributes メソッドが呼び出されます。ペンの名前は、DrawingAttributes オブジェクトの ExtendedProperty として格納されます。Label、labelPenName は、ペンの名前を表示するために使用されます。

using Microsoft.Ink;
//...
    private InkOverlay theInkOverlay;
    private DrawingAttributes[] availableDrawingAttributes;
    private Guid drawingAttributesNameId;
    private System.Windows.Forms.Label labelPenName; 
//...
    private void InitializeDrawingAttributes()
    {
        availableDrawingAttributes = new DrawingAttributes[3];
        drawingAttributesNameId = Guid.NewGuid();

        // Thin pen
        availableDrawingAttributes[0] = new DrawingAttributes(new Pen(Color.Black, 1));
        availableDrawingAttributes[0].ExtendedProperties.Add(drawingAttributesNameId, "Thin pen");

        // Thick marker
        availableDrawingAttributes[1] = new DrawingAttributes(new Pen(Color.Blue, 200));
        availableDrawingAttributes[1].ExtendedProperties.Add(drawingAttributesNameId, "Thick marker");

        // Highlighter
        availableDrawingAttributes[2] = new DrawingAttributes(Color.Yellow);
        availableDrawingAttributes[2].Height = 800;
        availableDrawingAttributes[2].Width = 1;
        availableDrawingAttributes[2].PenTip = PenTip.Rectangle;
        availableDrawingAttributes[2].Transparency = 125;
        availableDrawingAttributes[2].ExtendedProperties.Add(drawingAttributesNameId, "Highlighter");
    }

    private void ChangeDrawingAttributes(int index)
    {
        // Set the default drawing attributes of the InkOverlay
        theInkOverlay.DefaultDrawingAttributes = availableDrawingAttributes[index];

        // Display the pen name that you are using
        labelPenName.Text = 
            (String)availableDrawingAttributes[index].ExtendedProperties[drawingAttributesNameId].Data;
    }

この Microsoft® Visual Basic® .NET の例では、3 種類のインク (細い黒色のペン、太い青色のマーカー、および黄色の蛍光ペン) だけが使用できるインク対応アプリケーションが含まれています。DrawingAttributes オブジェクト availableDrawingAttributes の配列は、これらの 3 つのオプションのために作成され、各オプションには識別のための GUID drawingAttributesNameId が付与されています。InitializeDrawingAttributes メソッドがコンストラクタで呼び出され、ユーザーがペンを変更するたびに ChangeDrawingAttributes メソッドが呼び出されます。ペンの名前は、DrawingAttributes オブジェクトの ExtendedProperty として格納されます。Label、labelPenName は、ペンの名前を表示するために使用されます。

Imports Microsoft.Ink
'...
Private WithEvents theInkOverlay As InkOverlay
Private availableDrawingAttributes As DrawingAttributes()
Private drawingAttributesNameId As Guid
Friend WithEvents LabelPenName As System.Windows.Forms.Label
'...
Private Sub InitializeDrawingAttributes()
    ReDim availableDrawingAttributes(2)
    drawingAttributesNameId = Guid.NewGuid()

    'Thin pen
    availableDrawingAttributes(0) = New DrawingAttributes(New Pen(Color.Black, 1))
    availableDrawingAttributes(0).ExtendedProperties.Add(drawingAttributesNameId, "Thin pen")

    'Thick marker
    availableDrawingAttributes(1) = New DrawingAttributes(New Pen(Color.Blue, 200))
    availableDrawingAttributes(1).ExtendedProperties.Add(drawingAttributesNameId, "Thick marker")

    'Highlighter
    availableDrawingAttributes(2) = New DrawingAttributes(Color.Yellow)
    availableDrawingAttributes(2).Height = 800
    availableDrawingAttributes(2).Width = 1
    availableDrawingAttributes(2).PenTip = PenTip.Rectangle
    availableDrawingAttributes(2).Transparency = 125
    availableDrawingAttributes(2).ExtendedProperties.Add(drawingAttributesNameId, "Highlighter")
End Sub

Private Sub ChangeDrawingAttributes(ByVal index As Integer)
    'Set the default drawing attributes of the InkOverlay
    theInkOverlay.DefaultDrawingAttributes = availableDrawingAttributes(index)

    'Display the pen name that you are using
    LabelPenName.Text = _
        availableDrawingAttributes(index).ExtendedProperties(drawingAttributesNameId).Data
End Sub

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

DrawingAttributes クラス

DrawingAttributes メンバ

Microsoft.Ink 名前空間

ExtendedProperties

ExtendedProperty