Condividi tramite


Metodo InkAnalyzer.AddStroke (Stroke)

Aggiornamento: novembre 2007

Aggiunge un oggetto Stroke a InkAnalyzer e assegna al tratto l'identificatore delle impostazioni locali del thread di input attivo.

Spazio dei nomi:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

Sintassi

'Dichiarazione
Public Function AddStroke ( _
    strokeToAdd As Stroke _
) As ContextNode
'Utilizzo
Dim instance As InkAnalyzer
Dim strokeToAdd As Stroke
Dim returnValue As ContextNode

returnValue = instance.AddStroke(strokeToAdd)
public ContextNode AddStroke(
    Stroke strokeToAdd
)
public:
ContextNode^ AddStroke(
    Stroke^ strokeToAdd
)
public ContextNode AddStroke(
    Stroke strokeToAdd
)
public function AddStroke(
    strokeToAdd : Stroke
) : ContextNode

Parametri

Valore restituito

Tipo: System.Windows.Ink.ContextNode
Oggetto ContextNode in cui è stato aggiunto l'oggetto strokeToAdd.

Note

InkAnalyzer aggiunge l'oggetto Stroke a un oggetto UnclassifiedInkNode nell'insieme SubNodes della proprietà RootNode. All'oggetto Stroke, strokeToAdd, viene assegnato lo stesso identificatore delle impostazioni locali utilizzato nel thread di input attivo. Quindi Stroke viene aggiunto al primo oggetto UnclassifiedInkNode contenente i tratti caratterizzati dallo stesso identificatore delle impostazioni locali. Se non esiste alcun oggetto UnclassifiedInkNode, viene creato un nuovo oggetto UnclassifiedInkNode e strokeToAdd viene aggiunto al nuovo oggetto UnclassifiedInkNode.

Questo metodo espande l'oggetto DirtyRegion all'unione del valore corrente dell'area e del riquadro del tratto aggiunto.

Se il tratto è già associato all'oggetto InkAnalyzer, InkAnalyzer genera un'eccezione.

Esempi

Nell'esempio seguente viene creato un nuovo oggetto InkAnalyzer e il gestore per l'evento StrokesChanged viene associato alla proprietà Strokes nell'oggetto InkCanvas denominato theInkCanvas.

theInkAnalyzer = New InkAnalyzer()

AddHandler theInkCanvas.Strokes.StrokesChanged, AddressOf Strokes_StrokesChanged
theInkAnalyzer = new InkAnalyzer();

theInkCanvas.Strokes.StrokesChanged += 
    new StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);

Nell'esempio seguente viene definito il gestore eventi Strokes_StrokesChanged che aggiunge i tratti a theInkAnalyzer, se erano già stati aggiunti a theInkCanvas. Quindi, i tratti vengono rimossi da theInkAnalyzer, se erano già stati rimossi da theInkCanvas.

' This event occurs whenever a stroke is added, removed, or partially erased
' from the InkCanvas.
Sub Strokes_StrokesChanged(ByVal sender As Object, ByVal e As StrokeCollectionChangedEventArgs) 
    If e.Added.Count > 0 Then
        theInkAnalyzer.AddStrokes(e.Added)
    End If

    If e.Removed.Count > 0 Then
        theInkAnalyzer.RemoveStrokes(e.Removed)
    End If

End Sub 'Strokes_StrokesChanged
// This event occurs whenever a stroke is added, removed, or partially erased
// from the InkCanvas.
void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
    if (e.Added.Count > 0)
    {
        theInkAnalyzer.AddStrokes(e.Added);
    }

    if (e.Removed.Count > 0)
    {
        theInkAnalyzer.RemoveStrokes(e.Removed);
    }
}

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

InkAnalyzer Classe

Membri InkAnalyzer

Overload AddStroke

Spazio dei nomi System.Windows.Ink

InkAnalyzer.AddStrokes

InkAnalyzerRemoveStroke()

InkAnalyzerRemoveStrokes()