Compartir a través de


DrawingAttributes.Color Property

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

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Property Color As Color
'Usage
Dim instance As DrawingAttributes
Dim value As Color

value = instance.Color

instance.Color = value
public Color Color { get; set; }
public:
property Color Color {
    Color get ();
    void set (Color value);
}
/** @property */
public Color get_Color ()

/** @property */
public void set_Color (Color value)
public function get Color () : Color

public function set Color (value : Color)
Not applicable.

Property Value

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

Value

Meaning

Black

Ink is rendered in Black.

System.Drawing.Color

The ink is rendered in the color of the selected Color object.

Remarks

In High Contrast mode, ink always appears with the system color setting (WindowTextWindowText), 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), 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. 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.

Example

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

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

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

DrawingAttributes Class
DrawingAttributes Members
Microsoft.Ink Namespace
InkCollector.AutoRedraw
InkOverlay.AutoRedraw
InkPicture.AutoRedraw
InkCollector.SupportHighContrastInk
InkOverlay.SupportHighContrastInk
InkPicture.SupportHighContrastInk
Microsoft.Ink.Renderer.Draw