DrawingAttributes Class

 

Specifies the appearance of a Stroke

Namespace:   System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)

System.Object
  System.Windows.Ink.DrawingAttributes

Public Class DrawingAttributes
	Implements INotifyPropertyChanged

NameDescription
System_CAPS_pubmethodDrawingAttributes()

Initializes a new instance of the DrawingAttributes class.

NameDescription
System_CAPS_pubpropertyColor

Gets or sets the color of a Stroke.

System_CAPS_pubpropertyFitToCurve

Gets or sets a value that indicates whether Bezier smoothing is used to render the Stroke.

System_CAPS_pubpropertyHeight

Gets or sets the height of the stylus used to draw the Stroke.

System_CAPS_pubpropertyIgnorePressure

Gets or sets a value that indicates whether the thickness of a rendered Stroke changes according the amount of pressure applied.

System_CAPS_pubpropertyIsHighlighter

Gets or sets a value that indicates whether the Stroke looks like a highlighter.

System_CAPS_pubpropertyStylusTip

Gets or sets the shape of the stylus used to draw the Stroke.

System_CAPS_pubpropertyStylusTipTransform

Gets or sets the Matrix that specifies the transformation to perform on the stylus' tip.

System_CAPS_pubpropertyWidth

Gets or sets the width of the stylus used to draw the Stroke.

NameDescription
System_CAPS_pubmethodAddPropertyData(Guid, Object)

Adds a custom property to the DrawingAttributes object.

System_CAPS_pubmethodClone()

Copies the DrawingAttributes object.

System_CAPS_pubmethodContainsPropertyData(Guid)

Returns a value that indicates whether the specified property data identifier is in the DrawingAttributes object.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified DrawingAttributes object is equal to the current DrawingAttributes object. (Overrides Object.Equals(Object).)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as a hash function for a particular type.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodGetPropertyData(Guid)

Gets the value of the custom property associated with the specified Guid.

System_CAPS_pubmethodGetPropertyDataIds()

Returns the GUIDs of any custom properties associated with the StrokeCollection.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnAttributeChanged(PropertyDataChangedEventArgs)

Raises the AttributeChanged event.

System_CAPS_protmethodOnPropertyChanged(PropertyChangedEventArgs)

This API supports the product infrastructure and is not intended to be used directly from your code. Occurs when any DrawingAttributes property changes.

System_CAPS_protmethodOnPropertyDataChanged(PropertyDataChangedEventArgs)

Raises the PropertyDataChanged event.

System_CAPS_pubmethodRemovePropertyData(Guid)

Removes the custom property associated with the specified Guid.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticMaxHeight

Specifies the largest value allowed for the Height property.

System_CAPS_pubfieldSystem_CAPS_staticMaxWidth

Specifies the largest value allowed for the Width property.

System_CAPS_pubfieldSystem_CAPS_staticMinHeight

Specifies the smallest value allowed for the Height property.

System_CAPS_pubfieldSystem_CAPS_staticMinWidth

Specifies the smallest value allowed for the Width property.

NameDescription
System_CAPS_pubeventAttributeChanged

Occurs when a property in the DrawingAttributes object changes.

System_CAPS_pubeventPropertyDataChanged

Occurs when property data is added or removed from the StrokeCollection.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticEquality(DrawingAttributes, DrawingAttributes)

Determines whether the specified DrawingAttributes objects are equal.

System_CAPS_puboperatorSystem_CAPS_staticInequality(DrawingAttributes, DrawingAttributes)

Determines whether the specified DrawingAttributes objects are not equal.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_priveventINotifyPropertyChanged.PropertyChanged

This API supports the product infrastructure and is not intended to be used directly from your code. Occurs when the value of any DrawingAttributes property has changed.

Use the DrawingAttributes property to specify settings such as color, width, transparency, and the shape of the stylus tip for a Stroke.

Use the DefaultDrawingAttributes property to specify the drawing attributes for the strokes added to an InkCanvas. Only strokes that are added after the DefaultDrawingAttributes undergo change show the updated attributes. The appearance of the strokes that are already on the InkCanvas does not change.

For a list of initial property values for an instance of the DrawingAttributes class, see the DrawingAttributes constructor.

This class is not typically used in XAML.

The following example demonstrates how to use two DrawingAttributes objects to simulate using a pen and a highlighter on the same InkCanvas. The example assumes the root element in the XAML file is a DockPanel called root. It also assumes that there is a Button called switchHighlighter and that the Click event is connected to the event handler defined in this example.

Private WithEvents inkCanvas1 As New InkCanvas()
Private inkDA As DrawingAttributes
Private highlighterDA As DrawingAttributes
Private useHighlighter As Boolean = False

' Add an InkCanvas to the window, and allow the user to 
' switch between using a green pen and a purple highlighter 
' on the InkCanvas.
Private Sub WindowLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

    inkCanvas1.Background = Brushes.DarkSlateBlue
    inkCanvas1.DefaultDrawingAttributes.Color = Colors.SpringGreen

    ' Add the InkCanvas to the DockPanel, named root.
    root.Children.Add(inkCanvas1)

    ' Set up the DrawingAttributes for the pen.
    inkDA = New DrawingAttributes()
    With inkDA
        .Color = Colors.SpringGreen
        .Height = 5
        .Width = 5
        .FitToCurve = True
    End With

    ' Set up the DrawingAttributes for the highlighter.
    highlighterDA = New DrawingAttributes()
    With highlighterDA
        .Color = Colors.Orchid
        .IsHighlighter = True
        .IgnorePressure = True
        .StylusTip = StylusTip.Rectangle
        .Height = 30
        .Width = 10
    End With

    inkCanvas1.DefaultDrawingAttributes = inkDA

End Sub 'WindowLoaded


' Create a button called switchHighlighter and use 
' SwitchHighlighter_Click to handle the Click event.  
' The useHighlighter variable is a boolean that indicates
' whether the InkCanvas renders ink as a highlighter.

' Switch between using the 'pen' DrawingAttributes and the 
' 'highlighter' DrawingAttributes when the user clicks on .
Private Sub SwitchHighlighter_Click(ByVal sender As [Object], ByVal e As RoutedEventArgs)

    useHighlighter = Not useHighlighter

    If useHighlighter Then
        switchHighlighter.Content = "Use Pen"
        inkCanvas1.DefaultDrawingAttributes = highlighterDA
    Else

        switchHighlighter.Content = "Use Highlighter"
        inkCanvas1.DefaultDrawingAttributes = inkDA
    End If

End Sub 'SwitchHighlighter_Click

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: