InkCanvasSelectionHitResult Wyliczenie

Definicja

Identyfikuje różne części adoratora zaznaczenia na obiekcie InkCanvas.

public enum class InkCanvasSelectionHitResult
public enum InkCanvasSelectionHitResult
type InkCanvasSelectionHitResult = 
Public Enum InkCanvasSelectionHitResult
Dziedziczenie
InkCanvasSelectionHitResult

Pola

Bottom 6

Dolny środkowy uchwyt adoratora zaznaczenia.

BottomLeft 7

Lewy dolny uchwyt adoratora zaznaczenia.

BottomRight 5

Prawy dolny uchwyt adoratora zaznaczenia.

Left 8

Środkowy uchwyt na lewej krawędzi adoratora zaznaczenia.

None 0

Brak części adoratora wyboru.

Right 4

Środkowy uchwyt na prawej krawędzi adoratora zaznaczenia.

Selection 9

Obszar w granicach adoratora zaznaczenia.

Top 2

Górny środkowy uchwyt adoratora zaznaczenia.

TopLeft 1

Lewy górny uchwyt adoratora zaznaczenia.

TopRight 3

Prawy górny uchwyt adoratora zaznaczenia.

Przykłady

W poniższym przykładzie pokazano, jak użyć HitTestSelection metody , aby określić, czy utworzyć element DataObject do zainicjowania przeciągania i upuszczania. Aby zaimplementować przeciąganie i upuszczanie między dwoma InkCanvas obiektami, zobacz Instrukcje: przeciąganie i upuszczanie pisma odk.

void InkCanvas_PreviewMouseDown(object sender, MouseEventArgs e)
{
    InkCanvas ic = (InkCanvas)sender;
    
    Point pt = e.GetPosition(ic);

    // If the user is moving selected strokes, prepare the strokes to be
    // moved to another InkCanvas.
    if (ic.HitTestSelection(pt) == 
        InkCanvasSelectionHitResult.Selection)
    {
        StrokeCollection selectedStrokes = ic.GetSelectedStrokes();
        StrokeCollection strokesToMove = selectedStrokes.Clone();
    
        // Remove the offset of the selected strokes so they
        // are positioned when the strokes are dropped.
        Rect inkBounds = strokesToMove.GetBounds();
        TranslateStrokes(strokesToMove, -inkBounds.X, -inkBounds.Y);
        
        // Perform drag and drop.
        MemoryStream ms = new MemoryStream();
        strokesToMove.Save(ms);
        DataObject dataObject = new DataObject(
            StrokeCollection.InkSerializedFormat, ms);
        
        DragDropEffects effects = 
            DragDrop.DoDragDrop(ic, dataObject, 
                                DragDropEffects.Move);

        if ((effects & DragDropEffects.Move) == 
             DragDropEffects.Move)
        {
            // Remove the selected strokes 
            // from the current InkCanvas.
            ic.Strokes.Remove(selectedStrokes);
        }
    }
}
Private Sub InkCanvas_PreviewMouseDown(ByVal sender As Object, _
                               ByVal e As MouseButtonEventArgs)

    Dim ic As InkCanvas = CType(sender, InkCanvas)

    Dim pt As Point = e.GetPosition(ic)

    ' If the user is moving selected strokes, prepare the strokes to be
    ' moved to another InkCanvas.
    If ic.HitTestSelection(pt) = InkCanvasSelectionHitResult.Selection Then

        Dim selectedStrokes As StrokeCollection = _
                               ic.GetSelectedStrokes()

        Dim strokesToMove As StrokeCollection = _
                             selectedStrokes.Clone()

        ' Remove the offset of the selected strokes so they
        ' are positioned when the strokes are dropped.
        Dim inkBounds As Rect = strokesToMove.GetBounds()
        TranslateStrokes(strokesToMove, -inkBounds.X, -inkBounds.Y)

        ' Perform drag and drop.
        Dim ms As New MemoryStream()
        strokesToMove.Save(ms)

        Dim dataObject As New DataObject _
            (StrokeCollection.InkSerializedFormat, ms)

        Dim effects As DragDropEffects = _
            DragDrop.DoDragDrop(ic, dataObject, DragDropEffects.Move)

        If (effects And DragDropEffects.Move) = DragDropEffects.Move Then

            ' Remove the selected strokes from the current InkCanvas.
            ic.Strokes.Remove(selectedStrokes)
        End If
    End If

End Sub

Uwagi

Metoda HitTestSelection zwraca wartość , InkCanvasSelectionHitResult aby wskazać, która część adoratora zaznaczenia przecina lub otacza obiekt Point. Jest to przydatne podczas wykonywania operacji przeciągania i upuszczania.

Użycie tekstu w języku XAML

Ta klasa nie jest zwykle używana w języku XAML.

Dotyczy