Compartilhar via


DrawingAttributes.ExtendedProperties Property

DrawingAttributes.ExtendedProperties Property

Gets the collection of application-defined data.

Definition

Visual Basic .NET Public ReadOnly Property ExtendedProperties As ExtendedProperties
C# public ExtendedProperties ExtendedProperties { get; }
Managed C++ public: __property ExtendedProperties* get_ExtendedProperties();

Property Value

Microsoft.Ink.ExtendedProperties. The collection of application-defined data.

This property is read-only. This property has no default value.

Remarks

Applications can use the ExtendedProperties property to access the custom data that is stored in the DrawingAttributes object. This custom data is automatically serialized with the object.

Examples

[C#]

This C# example contains an ink-enabled application that allows only three kinds of ink: a thin black pen, a thick blue marker, and a yellow highlighter. An array of DrawingAttributes objects, availableDrawingAttributes, is created for these three options, each of which is given an identifying GUID, drawingAttributesNameId. The InitializeDrawingAttributes method is called in the constructor, and the ChangeDrawingAttributes method is called whenever the user changes pens. The pen name is stored as an ExtendedProperty of the DrawingAttributes object. A Label Leave Site, labelPenName, is used to display the pen name.

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;
    }
                

[VB.NET]

This Microsoft® Visual Basic® .NET example contains an ink-enabled application that allows only three kinds of ink: a thin black pen, a thick blue marker, and a yellow highlighter. An array of DrawingAttributes objects, availableDrawingAttributes, is created for these three options, each of which is given an identifying GUID, drawingAttributesNameId. The InitializeDrawingAttributes method is called in the constructor, and the ChangeDrawingAttributes method is called whenever the user changes pens. The pen name is stored as an ExtendedProperty of the DrawingAttributes object. A Label Leave Site, labelPenName, is used to display the pen name.

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
            

See Also