GestureRecognizer 构造函数

初始化 GestureRecognizer 类的新实例。

命名空间:  Microsoft.StylusInput
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub New
用法

Dim instance As New GestureRecognizer()
public GestureRecognizer()
public:
GestureRecognizer()
public GestureRecognizer()
public function GestureRecognizer()

示例

此 C# 示例是窗体的 Load 事件处理程序中的代码段,它创建一个 GestureRecognizerDynamicRenderer 以及两个 RealTimeStylus 对象,在级联的 RealTimeStylus 模型中附加对象,并通过 RealTimeStylus 启用动态呈现、笔势识别和 Tablet 笔数据收集。GestureRecognizer 对象设置为可识别单笔画笔势,并且仅识别 RightChevronRightArrowRight 应用程序笔势。主 RealTimeStylus 对象的 WindowInputRectangle 属性显式设置为使用 RealTimeStylus 对象附加到的整个控件。窗体本身实现 IStylusAsyncPlugin 接口,并附加到 RealTimeStylus 对象。

using Microsoft.Ink;
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;

// ...

// The panel where the tablet pen data is collected.
private System.Windows.Forms.Panel thePanel;

// Declare the RealTimeStylus objects, the GestureRecognizer plugin,
// and the DynamicRenderer plug-in.
private Microsoft.StylusInput.RealTimeStylus thePrimaryRealTimeStylus = null;
private Microsoft.StylusInput.RealTimeStylus theSecondaryRealTimeStylus = null;
private Microsoft.StylusInput.GestureRecognizer theGestureRecognizer = null;
private Microsoft.StylusInput.DynamicRenderer theDynamicRenderer = null;

// The form's Load event handler.
private void theForm_Load(object sender, System.EventArgs e)
{
    // ...

    // Create a DynamicRenderer attached to the drawing area ,
    // and enable dynamic rendering.
    this.theDynamicRenderer = new DynamicRenderer(this.thePanel);
    this.theDynamicRenderer.Enabled = true;

    // Create a GestureRecognizer, and set it to recognize single-stroke gestures.
    this.theGestureRecognizer = new GestureRecognizer();
    this.theGestureRecognizer.MaxStrokeCount = 1;

    // Allow gesture recognition for specific gestures.
    this.theGestureRecognizer.EnableGestures( new ApplicationGesture[]
        {
            ApplicationGesture.Right,
            ApplicationGesture.ChevronRight,
            ApplicationGesture.ArrowRight
        } );

    // Enable gesture recognition.
    this.theGestureRecognizer.Enabled = true;

    // Create the primary and secondary RealTimeStylus objects.
    this.thePrimaryRealTimeStylus = new RealTimeStylus(this.thePanel);
    this.theSecondaryRealTimeStylus = new RealTimeStylus();

    // Add the secondary RealTimeStylus to the primary's asynchronous plug-in collection.
    this.thePrimaryRealTimeStylus.AsyncPluginCollection.Add(
        this.theSecondaryRealTimeStylus);

    // Add the dynamic renderer to the primary's synchronous plug-in collection.
    this.thePrimaryRealTimeStylus.SyncPluginCollection.Add(this.theDynamicRenderer);

    // Add the gesture recognizer to the secondary's synchronous plug-in collection.
    this.theSecondaryRealTimeStylus.SyncPluginCollection.Add(this.theGestureRecognizer);

    // Add the form to the secondary's asynchronous plug-in colleciton.
    this.theSecondaryRealTimeStylus.AsyncPluginCollection.Add(this);

    // Set the input rectangle to the entire panel for the RealTimeStylus.
    this.thePrimaryRealTimeStylus.WindowInputRectangle = new Rectangle(0,0,0,0);

    // Enable the RealTimeStylus, which allows notifications to flow to the plug-ins.
    this.thePrimaryRealTimeStylus.Enabled = true;

    // ...
}

平台

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

GestureRecognizer 类

GestureRecognizer 成员

Microsoft.StylusInput 命名空间