Freigeben über


DrawingAttributes.Width Property

DrawingAttributes.Width Property

Gets or sets the y-axis dimension, or width, of the pen tip when drawing ink.

Definition

Visual Basic .NET Public Property Width As Single
C# public float Width { get; set; }
Managed C++ public: __property float* get_Width();
public: __property void set_Width(float*);

Property Value

System.Single. The y-axis dimension, or width, of the pen tip when drawing ink.

This property is read/write.

53 Default. The width of the pen tip is 53 HIMETRIC units.
Single Value representing the width of the pen tip, in HIMETRIC units.

Remarks

The Width property is in HIMETRIC units.

If the tablet reports pen pressure (if the IgnorePressure property is false), the actual width of the ink varies depending on the amount of pressure applied to the drawing surface. When maximum pressure is applied, the width is 150% of the value of the Width property. When minimum pressure is applied, the width is 50% of the value of the Width property. By default, pressure from the pen is reported. To specify that pressure should not be reported (that the width of ink does not change), set the IgnorePressure property to true.

Precision is limited to one one-thousandth of a HIMETRIC unit (three digits to the right of the decimal point). For example, if you specify a value of 2.0006, the most precise measurement is 2.001.

Examples

[C#]

This C# example creates event handlers for menu items that change the Width property of a DrawingAttributes object.

using Microsoft.Ink;
//...
    private System.Windows.Forms.MenuItem menuInkWidthThin;
    private System.Windows.Forms.MenuItem menuInkWidthThick;
    private InkCollector theInkCollector;
    private System.Windows.Forms.MenuItem checkedWidth;

//...
    private void menuInkWidthThin_Click(
    object sender, System.EventArgs e)
    {
        checkedWidth.Checked = false;
        // Set the width about one pixel wide in HIMETRIC
        theInkCollector.DefaultDrawingAttributes.Width = 30;
        checkedWidth = menuInkWidthThin;
        checkedWidth.Checked = true;
        Refresh();
    }

    private void menuInkWidthThick_Click(
    object sender, System.EventArgs e)
    {
        checkedWidth.Checked = false;
        // Set the width about ten pixels wide in HIMETRIC
        theInkCollector.DefaultDrawingAttributes.Width = 300;
        checkedWidth = menuInkWidthThick;
        checkedWidth.Checked = true;
        Refresh();
    }
                

[VB.NET]

This Microsoft® Visual Basic® .NET example creates event handlers for menu items that change the Width property of a DrawingAttributes object.

Imports Microsoft.Ink
'...
    Dim MenuInkWidthThin As System.Windows.Forms.MenuItem
    Dim MenuInkWidthThick As System.Windows.Forms.MenuItem
    Dim CheckedWidth As System.Windows.Forms.MenuItem
    Dim theInkCollector As InkCollector
'...
    Private Sub MenuInkWidthThin_Click( _
    ByVal sender As Object, ByVal e As System.EventArgs)
        CheckedWidth.Checked = False
        'Set the width about one pixel wide in HIMETRIC
        theInkCollector.DefaultDrawingAttributes.Width = 30
        CheckedWidth = MenuInkWidthThin
        CheckedWidth.Checked = True
        Refresh()
    End Sub

    Private Sub MenuInkWidthThick_Click( _
    ByVal sender As Object, ByVal e As System.EventArgs)
        CheckedWidth.Checked = False
        theInkCollector.DefaultDrawingAttributes.Width = 300
        CheckedWidth = MenuInkWidthThick
        CheckedWidth.Checked = True
        Refresh()
    End Sub
                

See Also