InkCanvasSelectionHitResult Enumeración

Definición

Identifica las distintas partes de un adorno de selección en un InkCanvas.

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

Campos

Nombre Valor Description
None 0

Ninguna parte del adorno de la selección.

TopLeft 1

Controlador superior izquierdo del adorno de selección.

Top 2

Controlador central superior del adorno de selección.

TopRight 3

Controlador superior derecho del adorno de selección.

Right 4

Controlador central en el borde derecho del adorno de selección.

BottomRight 5

Controlador inferior derecho del adorno de selección.

Bottom 6

Controlador central inferior del adorno de selección.

BottomLeft 7

Identificador inferior izquierdo del adorno de selección.

Left 8

Controlador central en el borde izquierdo del adorno de selección.

Selection 9

Área dentro de los límites del adorno de selección.

Ejemplos

En el ejemplo siguiente se muestra cómo usar HitTestSelection para determinar si se va a crear un DataObject para iniciar la arrastrar y colocar. Para implementar arrastrar y colocar entre dos InkCanvas objetos, vea Cómo: Arrastrar y colocar entrada de lápiz.

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

Comentarios

El HitTestSelection método devuelve un InkCanvasSelectionHitResult para indicar qué parte del adorno de selección interseca o rodea a .Point Esto resulta útil al realizar operaciones de arrastrar y colocar.

Uso de texto XAML

Esta clase no se usa normalmente en XAML.

Se aplica a