Freigeben über


DrawingAttributes.Color Property

DrawingAttributes.Color Property

Gets or sets the color of the ink that is drawn with this DrawingAttributes object.

Definition

Visual Basic .NET Public Property Color As Color
C# public Color Color { get; set; }
Managed C++ public: __property Color* get_Color();
public: __property void set_Color(Color*);

Property Value

System.Drawing.Color. The color of the ink that is drawn with this DrawingAttributes object.

This property is read/write.

Black Default. Ink is rendered in Black Leave Site.
System.Drawing.Color The ink is rendered in the color of the selected Color Leave Site object.

Remarks

In High Contrast mode, ink always appears with the system color setting (WindowText Leave Site), regardless of the setting of the Color property. However, the actual color of the ink is always saved as the color set in the Color property (or the default color if not set). For example, if the Color property is set to (Red Leave Site), a user in High Contrast mode sees the ink in the system color, but a user not in High Contrast mode sees the ink drawn as the set color Red Leave Site. This functionality allows a user in High Contrast mode to view the ink in the system setting without modifying the actual stroke color.

This means that by default all ink is mapped to one color when in High Contrast mode. To disable this default color-mapping behavior and implement your own, use the ink collector's SupportHighContrastInk property (InkCollector.SupportHighContrastInk, InkOverlay.SupportHighContrastInk, or InkPicture.SupportHighContrastInk).

To effectively enable High Contrast mode, you must set the ink collector's AutoRedraw property (InkCollector.AutoRedraw, InkOverlay.AutoRedraw, or InkPicture.AutoRedraw) to true. If you set the AutoRedraw property to true, ink is redrawn when the window is invalidated. The Tablet PC application programming interface (API) does not support High Contrast mode if you set the AutoRedraw property to false.

Examples

[C#]

This C# example contains menu handlers that change the Color property of a DrawingAttributes object.

using Microsoft.Ink;
using System.Drawing;
//...
    private System.Windows.Forms.MenuItem menuInkColorRed;
    private System.Windows.Forms.MenuItem menuInkColorBlue;
    private InkCollector theInkCollector;
    private System.Windows.Forms.MenuItem checkedColor;

//...
    private void menuInkColorRed_Click(
    object sender, System.EventArgs e)
    {
        checkedColor.Checked = false;
        theInkCollector.DefaultDrawingAttributes.Color = Color.Red;
        checkedColor = menuInkColorRed;
        checkedColor.Checked = true;
        Refresh();
    }

    private void menuInkColorBlue_Click(
    object sender, System.EventArgs e)
    {
        checkedColor.Checked = false;
        theInkCollector.DefaultDrawingAttributes.Color = Color.Blue;
        checkedColor = menuInkColorBlue;
        checkedColor.Checked = true;
        Refresh();
    }
                

[VB.NET]

This Microsoft® Visual Basic® .NET example contains menu handlers that change the Color property of a DrawingAttributes object.

Imports Microsoft.Ink
Imports System.Drawing
'...
    Dim MenuInkColorRed As System.Windows.Forms.MenuItem
    Dim MenuInkColorBlue As System.Windows.Forms.MenuItem
    Dim CheckedColor As System.Windows.Forms.MenuItem
    Dim theInkCollector As InkCollector
'...
    Private Sub MenuInkColorRed_Click( _
    ByVal sender As Object, ByVal e As System.EventArgs)
        CheckedColor.Checked = False
        theInkCollector.DefaultDrawingAttributes.Color = Color.Red
        CheckedColor = MenuInkColorRed
        CheckedColor.Checked = True
        Refresh()
    End Sub

    Private Sub MenuInkColorBlue_Click( _
    ByVal sender As Object, ByVal e As System.EventArgs)
        CheckedColor.Checked = False
        theInkCollector.DefaultDrawingAttributes.Color = Color.Blue
        CheckedColor = MenuInkColorBlue
        CheckedColor.Checked = True
        Refresh()
    End Sub
                

See Also