Condividi tramite


Evento InkCollector.CursorDown

Aggiornamento: novembre 2007

Si verifica quando la punta del cursore tocca la superficie della tavoletta grafica.

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

Sintassi

'Dichiarazione
Public Event CursorDown As InkCollectorCursorDownEventHandler
'Utilizzo
Dim instance As InkCollector
Dim handler As InkCollectorCursorDownEventHandler

AddHandler instance.CursorDown, handler
public event InkCollectorCursorDownEventHandler CursorDown
public:
 event InkCollectorCursorDownEventHandler^ CursorDown {
    void add (InkCollectorCursorDownEventHandler^ value);
    void remove (InkCollectorCursorDownEventHandler^ value);
}
/** @event */
public void add_CursorDown (InkCollectorCursorDownEventHandler value)
/** @event */
public void remove_CursorDown (InkCollectorCursorDownEventHandler value)
JScript non supporta gli eventi.

Note

Il gestore eventi riceve un argomento di tipo InkCollectorCursorDownEventArgs contenente i dati relativi a questo evento.

Quando si crea un delegato InkCollectorCursorDownEventHandler, viene identificato il metodo che gestisce l'evento. Per associare l'evento al gestore eventi in uso, aggiungere all'evento un'istanza del delegato. Il gestore eventi viene chiamato ogni volta che si verifica l'evento, a meno che non si rimuova il delegato. Per motivi di prestazioni, l'interesse dell'evento predefinito è disattivato, ma viene attivato automaticamente se si aggiunge un gestore eventi.

Questo evento può avere un effetto negativo sulle prestazioni dell'input penna se viene eseguito troppo codice nei gestori eventi. Per migliorare le prestazioni dell'input penna in tempo reale, nascondere il cursore del mouse durante l'immissione dell'input penna. A tale scopo, nascondere il cursore del mouse nel gestore per l'evento MouseDown e visualizzarlo nel gestore per l'evento MouseUp.

Esempi

In questo esempio viene illustrato come sottoscrivere l'evento CursorDown e l'evento Stroke per calcolare il tempo richiesto per la creazione di un tratto da parte dell'utente.

All'inizio di un tratto, viene generato l'evento CursorDown. L'ora corrente viene posizionata nell'insieme ExtendedProperties dell'oggetto Stroke.

Private Sub mInkObject_CursorDown(ByVal sender As Object, ByVal e As InkCollectorCursorDownEventArgs)
    ' add extended property indicating the time the stroke started
    ' STROKE_START_GUID is class level string via GUID generator
    e.Stroke.ExtendedProperties.Add(New Guid(STROKE_START_GUID), DateTime.Now)
End Sub
private void mInkObject_CursorDown(object sender, InkCollectorCursorDownEventArgs e)
{
    // add extended property indicating the time the stroke started
    // STROKE_START_GUID is class level string via GUID generator
    e.Stroke.ExtendedProperties.Add(new Guid(STROKE_START_GUID), DateTime.Now);
}

Al termine del tratto, viene generato l'evento Stroke. L'ora di inizio viene recuperata dall'insieme ExtendedProperties dell'oggetto Stroke e utilizzata per calcolare il tempo trascorso.

Private Sub mInkObject_Stroke1(ByVal sender As Object, ByVal e As InkCollectorStrokeEventArgs)
    ' check to see if extended property for start time exists
    ' Attempting to access an extended property that hasn't been created throws an exception
    ' STROKE_START_GUID is class level string via GUID generator
    If (e.Stroke.ExtendedProperties.DoesPropertyExist(New Guid(STROKE_START_GUID))) Then

        Dim startTime As DateTime = DirectCast(e.Stroke.ExtendedProperties(New Guid(STROKE_START_GUID)).Data, DateTime)
        Dim endTime As DateTime = DateTime.Now
        Dim span As TimeSpan = New TimeSpan(endTime.Ticks - startTime.Ticks)

        ' add extended property indicating the time the stroke ended
        ' STROKE_END_GUID is class level string via GUID generator
        e.Stroke.ExtendedProperties.Add(New Guid(STROKE_END_GUID), endTime)

        ' display the number of seconds in creating this stroke
        Me.statusLabelStrokeTime.Text = span.TotalSeconds.ToString()
    End If
End Sub
private void mInkObject_Stroke1(object sender, InkCollectorStrokeEventArgs e)
{
    // check to see if extended property for start time exists
    // Attempting to access an extended property that hasn't been created throws an exception
    // STROKE_START_GUID is class level string via GUID generator
    if (e.Stroke.ExtendedProperties.DoesPropertyExist(new Guid(STROKE_START_GUID)))
    {
        DateTime startTime = (DateTime)e.Stroke.ExtendedProperties[new Guid(STROKE_START_GUID)].Data;
        DateTime endTime = DateTime.Now;
        TimeSpan span = new TimeSpan(endTime.Ticks - startTime.Ticks);

        // add extended property indicating the time the stroke ended
        // STROKE_END_GUID is class level string via GUID generator
        e.Stroke.ExtendedProperties.Add(new Guid(STROKE_END_GUID), endTime);

        // display the number of seconds in creating this stroke
        this.statusLabelStrokeTime.Text = span.TotalSeconds.ToString();
    }
}

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

InkCollector Classe

Membri InkCollector

Spazio dei nomi Microsoft.Ink

Cursor

CursorButton

InkCollector.CursorButtonUp

InkCollector.CursorDown