Share via


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# 示例包含一个支持墨迹 的应用程序,该应用程序仅显示三种墨迹:黑色细笔、蓝色粗标记和黄色荧光笔。将为这三个选项创建一个 DrawingAttributes 对象的数组 availableDrawingAttributes,并且对于每个选项均分配有标识用的 GUID drawingAttributesNameId。InitializeDrawingAttributes 方法在构造函数中受到调用,并且每次用户更改笔的时候均会调用 ChangeDrawingAttributes 方法。笔名称保存为 DrawingAttributes 对象的 ExtendedPropertyLabel (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(R) Visual Basic(R) .NET 示例包含一个支持墨迹 的应用程序,该应用程序仅显示三种墨迹:黑色细笔、蓝色粗标记和黄色荧光笔。将为这三个选项创建一个 DrawingAttributes 对象的数组 availableDrawingAttributes,并且对于每个选项均分配有标识用的 GUID drawingAttributesNameId。InitializeDrawingAttributes 方法在构造函数中受到调用,并且每次用户更改笔的时候均会调用 ChangeDrawingAttributes 方法。笔名称保存为 DrawingAttributes 对象的 ExtendedPropertyLabel (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