Condividi tramite


Proprietà InkPicture.CollectionMode

Aggiornamento: novembre 2007

Ottiene o imposta la modalità di raccolta che determina se l'input penna, il movimento o entrambi vengono riconosciuti mentre l'utente scrive.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Sintassi

'Dichiarazione
<BrowsableAttribute(True)> _
Public Property CollectionMode As CollectionMode
'Utilizzo
Dim instance As InkPicture
Dim value As CollectionMode

value = instance.CollectionMode

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

Valore proprietà

Tipo: Microsoft.Ink.CollectionMode
Uno dei valori CollectionMode.

Note

Nota

Il controllo InkPicture genera un errore se si tenta di modificare la proprietà CollectionMode mentre l'input penna viene raccolto. Per evitare questo conflitto, controllare la proprietà CollectingInk prima di modificare la proprietà CollectionMode.

Per un elenco delle modalità utilizzabili, vedere l'enumerazione CollectionMode. Tuttavia, in caso di utilizzo della proprietà CollectionMode in un sistema in cui è installato l'SDK di Tablet PC, ma non il sistema di riconoscimento, la modalità non può essere impostata su GestureOnly o su InkAndGesture.

Si verificano i comportamenti seguenti per ognuno dei valori CollectionMode.

Modalità InkOnly

  • Viene raccolto solo l'input penna, non i movimenti.

  • L'interesse dell'evento Gesture viene impostato su false (tutti gli altri interessi dell'evento rimangono inalterati).

Modalità GestureOnly

  • Vengono raccolti solo i movimenti, non l'input penna. I tratti vengono eliminati dopo l'invio al sistema di riconoscimento del movimento.

  • L'interesse dell'evento Gesture viene impostato su true (tutti gli altri interessi dell'evento rimangono inalterati).

  • Il controllo InkPicture non genera i seguenti eventi correlati al tratto e al pacchetto: CursorDown, Stroke, NewPackets e NewInAirPackets.

  • Vengono generati eventi del cursore.

Modalità InkAndGesture

  • Vengono raccolti sia l'input penna sia i movimenti.

  • Vengono riconosciuti solo i movimenti a tratto singolo.

  • L'interesse dell'evento Gesture viene impostato su true (tutti gli altri interessi dell'evento rimangono inalterati).

  • Viene generato prima l'evento Gesture, che consente di accettare o annullare il movimento quando si richiama il gestore eventi OnGesture del controllo InkPicture. Per annullare il movimento, impostare la proprietà Cancel ereditata dell'oggetto InkCollectorGestureEventArgs su true. Con l'annullamento del movimento si impone al controllo InkPicture di raccogliere l'input penna.

La modifica della modalità di raccolta non altera lo stato dei singoli movimenti.

Potrebbero verificarsi comportamenti imprevisti quando si imposta la proprietà CollectionModesu InkAndGesture e si esprime un interesse del controllo InkPicture in un movimento noto (tramite una chiamata al metodo SetGestureStatus). Se l'input penna disegnato assomiglia al movimento noto e quest'ultimo è incluso nell'elenco di alternative del sistema di riconoscimento, viene generato l'evento Gesture e l'input penna viene rimosso dalla visualizzazione, anche se tale movimento non rappresenta la prima alternativa. Per evitare la cancellazione dell'input penna quando si desidera raccogliere l'input penna anziché il movimento, annullare la raccolta del movimento e impostare la proprietà Cancel ereditata dell'oggetto InkCollectorGestureEventArgs su true.

Quando la proprietà CollectionMode è impostata su GestureOnly, il timeout tra l'aggiunta di un movimento da parte dell'utente e la generazione dell'evento Gesture è un valore fisso che non può essere modificato a livello di codice. Il riconoscimento del movimento è più veloce in modalità InkAndGesture. Per raccogliere solo i movimenti e impedire la raccolta dell'input penna nella modalità InkAndGesture, è possibile:

  1. Impostare la proprietà CollectionMode su InkAndGesture.

  2. Nell'evento Stroke, eliminare il tratto.

  3. Nell'evento Gesture, elaborare il movimento.

  4. Impostare la proprietà DynamicRendering su false per evitare il flusso di input penna durante l'esecuzione di movimenti.

Esempi

In questo esempio di C# vengono visualizzate le informazioni sull'evento di movimento nella barra di stato della finestra del form principale. Partendo da un'applicazione generata generica, aggiungere un controllo StatusBar, statusBar1 e un controllo InkPicture, theInkPicture, al form principale e al codice seguente.

[C#]

//...
using Microsoft.Ink;

namespace CollectionMode_CS
{
    public class CollectionModeForm : System.Windows.Forms.Form
    {
        // ... The generated code will be here.
        //Add this code following the implementation of Main():

        private void CollectionModeForm_Load(object sender, System.EventArgs e)
        {
            // Initialize the InkPicture object.
            theInkPicture.CollectionMode = CollectionMode.InkAndGesture;
            ClearAppGestures();

            // Turn on interest in the ChevronDown application gesture.
            theInkPicture.SetGestureStatus(ApplicationGesture.ChevronDown, true);
            theInkPicture.SetGestureStatus(ApplicationGesture.ChevronUp, true);
            theInkPicture.Gesture += new InkCollectorGestureEventHandler(theInkPicture_Gesture);
            theInkPicture.SystemGesture +=
            new InkCollectorSystemGestureEventHandler(theInkPicture_SystemGesture);
            theInkPicture.Enabled = true;
        }

        private void theInkPicture_Gesture(object sender,
            Microsoft.Ink.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 theInkPicture_SystemGesture(object sender,
            Microsoft.Ink.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()
        {
        ApplicationGesture test = ApplicationGesture.NoGesture;
            Array theGestures = System.Enum.GetValues(test.GetType());
            foreach (ApplicationGesture theGesture in theGestures)
            {
               theInkPicture.SetGestureStatus(theGesture, false);
            }
        }
    }
}

In questo esempio di Microsoft® Visual Basic® .NET vengono visualizzate le informazioni sull'evento di movimento nella barra di stato della finestra del form principale. Partendo da un'applicazione generata generica, aggiungere un controllo StatusBar, statusBar1, e un controllo InkPicture, theInkPicture, al form principale e al codice seguente.

Imports Microsoft.Ink

Public Class CollectionModeForm
    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, and an InkPicture control, the InkPicture.
#End Region

    Private Sub CollectionModeForm_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
        'Set the InkPicture to collect both ink and gestures.
        theInkPicture.CollectionMode = CollectionMode.InkAndGesture
        'Clear interest in all of the application gestures
        ClearAppGestures()
        'Set our interest in only two gestures.
        theInkPicture.SetGestureStatus(ApplicationGesture.ChevronDown, True)
        theInkPicture.SetGestureStatus(ApplicationGesture.ChevronUp, True)
        'Add the handlers for application and system gestures.
        AddHandler theInkPicture.Gesture, AddressOf theInkPicture_Gesture
        AddHandler theInkPicture.SystemGesture, AddressOf theInkPicture_SystemGesture
        theInkPicture.Enabled = True
    End Sub

    Private Sub theInkPicture_Gesture(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 theInkPicture_SystemGesture( _
        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 InkPicture 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
            theInkPicture.SetGestureStatus(theGesture, False)
        Next
    End Sub
End Class

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

InkPicture Classe

Membri InkPicture

Spazio dei nomi Microsoft.Ink

CollectionMode

InkPicture.Stroke

InkPicture.Gesture

InkPicture.CursorDown

InkPicture.NewPackets

InkPicture.NewInAirPackets

InkPicture.SetGestureStatus