次の方法で共有


InkCollector.CollectionMode プロパティ

インク、ジェスチャ、またはその両方がユーザーの書き込みとして認識されるかどうかを決定する収集モードを取得または設定します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
Public Property CollectionMode As CollectionMode
'使用
Dim instance As InkCollector
Dim value As CollectionMode

value = instance.CollectionMode

instance.CollectionMode = value
public CollectionMode CollectionMode { get; set; }
public:
property CollectionMode CollectionMode {
    CollectionMode get ();
    void set (CollectionMode value);
}
/** @property */
public CollectionMode get_CollectionMode()
/** @property */
public  void set_CollectionMode(CollectionMode value)
public function get CollectionMode () : CollectionMode
public function set CollectionMode (value : CollectionMode)

プロパティ値

型 : Microsoft.Ink.CollectionMode
インク、ジェスチャ、またはその両方がユーザーの書き込みとして認識されるかどうかを決定する CollectionMode

解説

ms571708.alert_note(ja-jp,VS.90).gifメモ :

InkCollector オブジェクトは、インクの収集中に CollectionMode プロパティを変更しようとするとエラーを生成します。この競合を避けるには、CollectionMode プロパティを変更する前に CollectingInk プロパティをチェックします。

使用可能なモデルの一覧については、CollectionMode 列挙体を参照してください。ただし、Tablet PC SDK がインストールされていても、認識エンジンがインストールされていないシステム上で CollectionMode プロパティを使用する場合、モードを GestureOnly または InkAndGesture に設定することはできません。

CollectionMode の値それぞれに対して次の動作が発生します。

InkOnly モード

  • インクのみが収集され、ジェスチャは収集されません。

  • Gesture イベント対象は false に設定されます (他のイベント対象はすべてそのまま維持されます)。

GestureOnly モード

  • ジェスチャのみが収集され、インクは収集されません。ストロークは、ジェスチャ認識エンジンに送信された後に削除されます。

  • Gesture イベント対象は true に設定されます (他のイベント対象はすべてそのまま維持されます)。

  • InkCollector オブジェクトでは、CursorDownStrokeNewPackets、および NewInAirPackets イベントなど、ストロークとパケットに関連するイベントは発生しません。

  • カーソル イベントが発生します。

  • インクは常に削除されます。

InkAndGesture モード

  • インクとジェスチャの両方が収集されます。

  • 単一のストローク ジェスチャのみが認識されます。

  • Gesture イベント対象は true に設定されます (他のイベント対象はすべてそのまま維持されます)。

  • Gesture イベントが最初に発生し、InkCollector オブジェクトの OnGesture イベント ハンドラが呼び出された場合にジェスチャを受け入れるかまたはキャンセルできます。ジェスチャをキャンセルするには、InkCollectorGestureEventArgs オブジェクトの継承された Cancel プロパティを true に設定します。ジェスチャをキャンセルすると InkCollector オブジェクトは強制的にインクを収集します。

収集モードの変更により、個々のジェスチャの状態が変更されることはありません。

CollectionMode プロパティが InkAndGesture に設定され、既知のジェスチャにおける InkCollector オブジェクトの対象が (SetGestureStatus メソッドを呼び出すことにより) 設定されている場合、望ましくない動作が発生することがあります。既知のジェスチャに似たインクを描画し、既知のジェスチャが認識エンジンの代替リスト内にある場合、Gesture イベントが発生し、ジェスチャが最上位代替候補にない場合でも、インクが消えます。ジェスチャの代わりにインクを収集する場合に、インクが消えないようにするには、ジェスチャの収集をキャンセルし InkCollectorGestureEventArgs オブジェクトの継承された Cancel プロパティを true に設定します。

CollectionMode プロパティが GestureOnly に設定されている場合、ユーザーがジェスチャを追加してから Gesture イベントが発生するまでのタイムアウトは固定値です。この値はプログラムによって変更できません。ジェスチャ認識は InkAndGesture モードではより速くなります。ジェスチャのみを収集し InkAndGesture モードでインクの収集を回避する方法を次に示します。

CollectionMode プロパティを InkAndGesture に設定します。

  1. Stroke イベントで、ストロークを削除します。

  2. Gesture イベントで、ジェスチャを処理します。

  3. ジェスチャ処理中のインクのフローを回避するには、DynamicRendering を false に設定します。

この C# の例では、メイン フォーム ウィンドウのステータス バーにジェスチャ イベントの情報を表示します。生成されたジェネリック アプリケーションを開始し、メイン フォームに StatusBar コントロール statusBar1 と次のコードを追加します。

//...
using Microsoft.Ink;

namespace CSGestureEvents
{
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.StatusBar statusBar1;
        // ... The generated code will be here.
        //Add this code following the implementation of Main():
        InkCollector theInkCollector;

        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Initialize the InkCollector object.
            theInkCollector = new InkCollector(Handle);
            theInkCollector.CollectionMode = CollectionMode.InkAndGesture;
            ClearAppGestures(theInkCollector);
            // Turn on interest in the ChevronDown application gesture.
            theInkCollector.SetGestureStatus(ApplicationGesture.ChevronDown, true);
            theInkCollector.SetGestureStatus(ApplicationGesture.ChevronUp, true);
            theInkCollector.Gesture += new InkCollectorGestureEventHandler(Gesture_Event);
            theInkCollector.SystemGesture += new InkCollectorSystemGestureEventHandler(SystemGesture_Event);
            theInkCollector.Enabled = true;
        }

        private void Gesture_Event(object sender,
            InkCollectorGestureEventArgs e)
        {
            Gesture theGesture = e.Gestures[0];
            statusBar1.Text = theGesture.Id.ToString();
            // Cancelling the gesture will cause the ink to remain.
            if (theGesture.Id == ApplicationGesture.ChevronDown)
                e.Cancel = true;
        }

        private void SystemGesture_Event(object sender,
            InkCollectorSystemGestureEventArgs e)
        {
            SystemGesture theGesture = e.Id;
            statusBar1.Text = "System: " + theGesture.ToString() +
                " " + e.Point.ToString();
        }

        // Set all of the ApplicationGestures' status
        // to false on the InkCollector object.
        private void ClearAppGestures(InkCollector theInkCollector)
        {
            ApplicationGesture test = ApplicationGesture.NoGesture;
            Array theGestures = System.Enum.GetValues(test.GetType());
            foreach (ApplicationGesture theGesture in theGestures)
            {
                theInkCollector.SetGestureStatus(theGesture, false);
            }
        }
    }
}

この Microsoft Visual Basic .NET の例では、メイン フォーム ウィンドウのステータス バーにジェスチャ イベント情報を表示します。生成されたジェネリック アプリケーションを開始し、メイン フォームに StatusBar コントロール statusBar1 と次のコードを追加します。

Imports Microsoft.Ink
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
'This contains the standard generated form code, with
'the addition of a Status Bar, StatusBar1.
#End Region

    Dim theInkCollector As InkCollector

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Initialize InkCollector.
        theInkCollector = New InkCollector(Handle)
        'Set the InkCollector to collect both ink and gestures.
        theInkCollector.CollectionMode = CollectionMode.InkAndGesture
        'Clear interest in all of the application gestures
        ClearAppGestures(theInkCollector)
        'Set our interest in only two gestures.
        theInkCollector.SetGestureStatus(ApplicationGesture.ChevronDown, True)
        theInkCollector.SetGestureStatus(ApplicationGesture.ChevronUp, True)
        'Add the handlers for application and system gestures.
        AddHandler theInkCollector.Gesture, AddressOf Gesture_Event
        AddHandler theInkCollector.SystemGesture, AddressOf SystemGesture_Event
        theInkCollector.Enabled = True
    End Sub

    Private Sub Gesture_Event(ByVal sender As Object, _
        ByVal e As InkCollectorGestureEventArgs)
        Dim theGesture As Gesture = e.Gestures(0)
        StatusBar1.Text = theGesture.Id.ToString()
        'Cancelling the gesture will cause the ink to remain.
        If theGesture.Id = ApplicationGesture.ChevronDown Then
            e.Cancel = True
        End If
     End Sub

    Private Sub SystemGesture_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorSystemGestureEventArgs)
        StatusBar1.Text = "System: " + e.Id.ToString() + "   " + e.Point.ToString()
    End Sub

    ' Set all of the ApplicationGestures' status
    ' to false on the InkCollector object.
    Private Sub ClearAppGestures()
        Dim test As ApplicationGesture = ApplicationGesture.NoGesture
        Dim theGestures As Array = System.Enum.GetValues(test.GetType())
        Dim theGesture As ApplicationGesture
        For Each theGesture In theGestures
            theInkCollector.SetGestureStatus(theGesture, False)
        Next
    End Sub
End Class

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

InkCollector クラス

InkCollector メンバ

Microsoft.Ink 名前空間

InkCollector.Enabled

InkCollector.CollectingInk

CollectionMode