Cursor.DrawingAttributes 属性

获取或设置在绘制墨迹 时应用于该墨迹的绘制属性。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Property DrawingAttributes As DrawingAttributes
用法
Dim instance As Cursor
Dim value As DrawingAttributes

value = instance.DrawingAttributes

instance.DrawingAttributes = value
public DrawingAttributes DrawingAttributes { get; set; }
public:
property DrawingAttributes^ DrawingAttributes {
    DrawingAttributes^ get ();
    void set (DrawingAttributes^ value);
}
/** @property */
public DrawingAttributes get_DrawingAttributes()
/** @property */
public  void set_DrawingAttributes(DrawingAttributes value)
public function get DrawingAttributes () : DrawingAttributes
public function set DrawingAttributes (value : DrawingAttributes)

属性值

类型:Microsoft.Ink.DrawingAttributes
绘制墨迹时应用于该墨迹的 DrawingAttributes 对象。如果此对象为 nullnull 引用(在 Visual Basic 中为 Nothing)(在 Microsoft Visual Basic .NET 中为 Nothing),则光标使用墨迹收集器对象的默认绘制属性。

备注

绘制属性指定笔画 的外观。例如,可以指定墨迹的宽度和颜色。

对 DrawingAttributes 属性 (Property) 的后续调用仅更改新笔画的绘制属性 (Attribute)。这些调用不会应用于已收集或正在收集的笔画。

备注

InkCollector.DefaultDrawingAttributesInkOverlay.DefaultDrawingAttributesInkPicture.DefaultDrawingAttributes 包含所有光标使用的绘制属性 (Attribute),除非它们设置了自己的 DrawingAttributes 属性 (Property)。例如,没有设置 DrawingAttributes 的新 Cursor 对象和其 DrawingAttributes 设置为 nullnull 引用(在 Visual Basic 中为 Nothing)(在 Visual Basic .NET 中为 Nothing)的旧 Cursor 对象都使用 DefaultDrawingAttributes。

对于自己所接触的每个墨迹收集器InkCollectorInkOverlayInkPicture),光标可以具有不同的绘制属性。如果未为某个光标指定绘制属性,那么该光标将使用墨迹收集器的默认绘制属性。这些默认属性 (Attribute) 使用特定墨迹收集器的 DefaultDrawingAttributes 属性 (Property) 设置(InkCollector.DefaultDrawingAttributesInkOverlay.DefaultDrawingAttributes 或 [P:Microsoft.Ink.InkPicture. DefaultDrawingAttributes])。

示例

在此示例中,当 CursorInRange 事件激发时,将检查 InkCollector 对象是否第一次与此特定 Cursor 对象相联系。如果是,则将 DefaultDrawingAttributes 属性的复本分配给 DrawingAttributes 属性。这将确保对 DrawingAttributes 属性的后续访问不会引发 null 引用异常。

Private Sub mInkObject_CursorInRange(ByVal sender As Object, ByVal e As InkCollectorCursorInRangeEventArgs)
    Const MOUSE_CURSOR_ID As Integer = 1
    If e.NewCursor Then
        ' mInkObject can be InkCollector, InkOverlay, or InkPicture
        e.Cursor.DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone()
        ' if this cursor is the mouse, we'll set color to red
        If (MOUSE_CURSOR_ID = e.Cursor.Id) Then
            e.Cursor.DrawingAttributes.Color = Color.Red
        End If

    End If
End Sub
private void mInkObject_CursorInRange(object sender, InkCollectorCursorInRangeEventArgs e)
{
    const int MOUSE_CURSOR_ID = 1;

    if (e.NewCursor)
    {
        // mInkObject can be InkCollector, InkOverlay, or InkPicture
        e.Cursor.DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone();
        // if this cursor is the mouse, we'll set color to red
        if (MOUSE_CURSOR_ID == e.Cursor.Id)
        {
            e.Cursor.DrawingAttributes.Color = Color.Red;
        }
    }
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Cursor 类

Cursor 成员

Microsoft.Ink 命名空间

DrawingAttributes

Stroke.DrawingAttributes

Strokes.ModifyDrawingAttributes