InkCanvasSelectionHitResult Enum

Definition

Identifierar de olika delarna i en markeringssmyckning på en InkCanvas.

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

Fält

Name Värde Description
None 0

Ingen del av urvalssmyckningen.

TopLeft 1

Markeringssmyckningens övre vänstra handtag.

Top 2

Markeringssmyckningens övre mitthandtag.

TopRight 3

Markeringssmyckningens övre högra handtag.

Right 4

Mitthandtaget på den högra kanten av urvalssmyckningen.

BottomRight 5

Markeringssmyckningens nedre högra handtag.

Bottom 6

Markeringssmyckningens nedre mitthandtag.

BottomLeft 7

Markeringssmyckningens nedre vänstra handtag.

Left 8

Mitthandtaget på den vänstra kanten av markeringssmyckningen.

Selection 9

Området inom gränserna för urvalssmyckningen.

Exempel

I följande exempel visas hur du använder HitTestSelection för att avgöra om du vill skapa en DataObject för att initiera dra och släppa. Information om hur du implementerar dra och släpp mellan två InkCanvas objekt finns i Så här: Dra och släpp pennanteckning.

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

Kommentarer

Metoden HitTestSelection returnerar en InkCanvasSelectionHitResult för att ange vilken del av urvalssmyckningen som korsar eller omger en Point. Detta är användbart när du utför dra och släpp-åtgärder.

XAML-textanvändning

Den här klassen används vanligtvis inte i XAML.

Gäller för