InkCanvasSelectionHitResult Výčet

Definice

Identifikuje různé části výběru adorner na .InkCanvas

public enum class InkCanvasSelectionHitResult
public enum InkCanvasSelectionHitResult
type InkCanvasSelectionHitResult = 
Public Enum InkCanvasSelectionHitResult
Dědičnost
InkCanvasSelectionHitResult

Pole

Bottom 6

Dolní prostřední úchyt výběru adorneru.

BottomLeft 7

Levý dolní úchyt výběru.

BottomRight 5

Pravý dolní úchyt výběru adorneru.

Left 8

Prostřední úchyt na levém okraji výběru adorneru.

None 0

Žádná část výběru adornera.

Right 4

Prostřední úchyt na pravém okraji výběru adorneru.

Selection 9

Oblast v mezích výběru adorneru.

Top 2

Horní prostřední úchyt výběru adorneru.

TopLeft 1

Levý horní úchyt výběru adorneru.

TopRight 3

Pravý horní úchyt výběru adorneru.

Příklady

Následující příklad ukazuje, jak použít HitTestSelection k určení, zda vytvořit DataObject pro zahájení přetažení přetažení. Pokud chcete implementovat přetažení mezi dvěma InkCanvas objekty, přečtěte si téma Postupy: Přetažení rukopisu.

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

Poznámky

Metoda HitTestSelection vrátí InkCanvasSelectionHitResult , která označuje, která část výběru adorner protíná nebo obklopuje Point. To je užitečné při provádění operací přetažení.

Použití textu XAML

Tato třída se obvykle nepoužívá v XAML.

Platí pro