mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-08 16:06:07 +02:00
Links: .NET Desktop - framework\wpf (#109)
* Links: .NET Desktop - framework\wpf * Apply suggestions from code review Co-authored-by: Andy De George <[email protected]>
This commit is contained in:
co-authored by
Andy De George
parent
c1d6e1d23e
commit
674b773578
@@ -12,6 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 791bb2f0-4e5c-4569-ac3c-211996808d44
|
||||
---
|
||||
# Intercepting Input from the Stylus
|
||||
|
||||
The <xref:System.Windows.Input.StylusPlugIns> architecture provides a mechanism for implementing low-level control over <xref:System.Windows.Input.Stylus> input and the creation of digital ink <xref:System.Windows.Ink.Stroke> objects. The <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> class provides a mechanism for you to implement custom behavior and apply it to the stream of data coming from the stylus device for the optimal performance.
|
||||
|
||||
This topic contains the following subsections:
|
||||
@@ -25,15 +26,19 @@ The <xref:System.Windows.Input.StylusPlugIns> architecture provides a mechanism
|
||||
- [Conclusion](#Conclusion)
|
||||
|
||||
<a name="Architecture"></a>
|
||||
|
||||
## Architecture
|
||||
The <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> is the evolution of the [StylusInput](https://docs.microsoft.com/previous-versions/dotnet/netframework-3.5/ms574861(v=vs.90)) APIs, described in [Accessing and Manipulating Pen Input](https://docs.microsoft.com/previous-versions/ms818317(v%3dmsdn.10)).
|
||||
|
||||
The <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> is the evolution of the [StylusInput](/previous-versions/dotnet/netframework-3.5/ms574861(v=vs.90)) APIs, described in [Accessing and Manipulating Pen Input](/previous-versions/ms818317(v%3dmsdn.10)).
|
||||
|
||||
Each <xref:System.Windows.UIElement> has a <xref:System.Windows.UIElement.StylusPlugIns%2A> property that is a <xref:System.Windows.Input.StylusPlugIns.StylusPlugInCollection>. You can add a <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> to an element's <xref:System.Windows.UIElement.StylusPlugIns%2A> property to manipulate <xref:System.Windows.Input.StylusPoint> data as it is generated. <xref:System.Windows.Input.StylusPoint> data consists of all the properties supported by the system digitizer, including the <xref:System.Windows.Input.StylusPoint.X%2A> and <xref:System.Windows.Input.StylusPoint.Y%2A> point data, as well as <xref:System.Windows.Input.StylusPoint.PressureFactor%2A> data.
|
||||
|
||||
Your <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> objects are inserted directly into the stream of data coming from the <xref:System.Windows.Input.Stylus> device when you add the <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> to the <xref:System.Windows.UIElement.StylusPlugIns%2A> property. The order in which plug-ins are added to the <xref:System.Windows.UIElement.StylusPlugIns%2A> collection dictates the order in which they will receive <xref:System.Windows.Input.StylusPoint> data. For example, if you add a filter plug-in that restricts input to a particular region, and then add a plug-in that recognizes gestures as they are written, the plug-in that recognizes gestures will receive filtered <xref:System.Windows.Input.StylusPoint> data.
|
||||
|
||||
<a name="ImplementingStylusPlugins"></a>
|
||||
|
||||
## Implementing Stylus Plug-ins
|
||||
|
||||
To implement a plug-in, derive a class from <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn>. This class is applied o the stream of data as it comes in from the <xref:System.Windows.Input.Stylus>. In this class you can modify the values of the <xref:System.Windows.Input.StylusPoint> data.
|
||||
|
||||
> [!CAUTION]
|
||||
@@ -47,7 +52,9 @@ The <xref:System.Windows.Input.StylusPlugIns> architecture provides a mechanism
|
||||
[!code-vb[AdvancedInkTopicsSamples#3](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AdvancedInkTopicsSamples/VisualBasic/DynamicRenderer.vb#3)]
|
||||
|
||||
<a name="AddingYourPluginToAnInkCanvas"></a>
|
||||
|
||||
## Adding Your Plug-in to an InkCanvas
|
||||
|
||||
The easiest way to use your custom plug-in is to implement a class that derives from InkCanvas and add it to the <xref:System.Windows.UIElement.StylusPlugIns%2A> property.
|
||||
|
||||
The following example demonstrates a custom <xref:System.Windows.Controls.InkCanvas> that filters the ink.
|
||||
@@ -61,10 +68,12 @@ The <xref:System.Windows.Input.StylusPlugIns> architecture provides a mechanism
|
||||
[!code-csharp[AdvancedInkTopicsSamples#5](~/samples/snippets/csharp/VS_Snippets_Wpf/AdvancedInkTopicsSamples/CSharp/Window1.xaml.cs#5)]
|
||||
|
||||
<a name="Conclusion"></a>
|
||||
|
||||
## Conclusion
|
||||
|
||||
By deriving your own <xref:System.Windows.Input.StylusPlugIns.StylusPlugIn> classes and inserting them into <xref:System.Windows.Input.StylusPlugIns.StylusPlugInCollection> collections, you can greatly enhance the behavior of your digital ink. You have access to the <xref:System.Windows.Input.StylusPoint> data as it is generated, giving you the opportunity to customize the <xref:System.Windows.Input.Stylus> input. Because you have such low-level access to the <xref:System.Windows.Input.StylusPoint> data, you can implement ink collection and rendering with optimal performance for your application.
|
||||
|
||||
## See also
|
||||
|
||||
- [Advanced Ink Handling](advanced-ink-handling.md)
|
||||
- [Accessing and Manipulating Pen Input](https://docs.microsoft.com/previous-versions/ms818317(v%3dmsdn.10))
|
||||
- [Accessing and Manipulating Pen Input](/previous-versions/ms818317(v%3dmsdn.10))
|
||||
|
||||
Reference in New Issue
Block a user