This topic has not yet been rated - Rate this topic

StylusDevice.Inverted Property

Gets or sets a value that indicates whether the stylus is inverted.

Namespace:  System.Windows.Input
Assembly:  System.Windows (in System.Windows.dll)
public bool Inverted { get; }

Property Value

Type: System.Boolean
true if the stylus is inverted; otherwise, false. The default is false.

For mouse input that is used for ink support instead of a stylus, the Inverted value is always false.

The following code example simulates a stylus that can be used as a highlighter when it is inverted.


//A new stroke object MyStroke is created and is added to the StrokeCollection 
//object of the InkPresenter MyIP
private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e)
{
    MyIP.CaptureMouse();
    StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
    MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
    MyStroke = new Stroke(MyStylusPointCollection);
    MyStroke.DrawingAttributes = CloneDrawingAttributes(MyDA,e);
    MyIP.Strokes.Add(MyStroke);
}


...


//Set DrawingAttributes based on the stylus status
private DrawingAttributes CloneDrawingAttributes(DrawingAttributes attributes, MouseEventArgs e)
{
    DrawingAttributes cloneAttribute = new DrawingAttributes();
    if (attributes == null)
        return attributes;

    //Stylus is inverted. So set drawing attributes for a highlighter
    if (e.StylusDevice.Inverted == true)
    {
        cloneAttribute.Width = 25;
        cloneAttribute.Height = 5;
        cloneAttribute.Color = Colors.Yellow;
        cloneAttribute.OutlineColor = Colors.Yellow;
        return cloneAttribute;
    }

    //Stylus is not inverted. So set the default drawing attribute.
    else
    {

        cloneAttribute.Color = attributes.Color;
        cloneAttribute.Height = attributes.Height;
        cloneAttribute.OutlineColor = attributes.OutlineColor;
        cloneAttribute.Width = attributes.Width;
        return cloneAttribute;
    }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ