InkCanvasSelectionHitResult Перечисление

Определение

Определяет различные части декоратора выделения на InkCanvas.

public enum class InkCanvasSelectionHitResult
public enum InkCanvasSelectionHitResult
type InkCanvasSelectionHitResult = 
Public Enum InkCanvasSelectionHitResult
Наследование
InkCanvasSelectionHitResult

Поля

Имя Значение Описание
None 0

Ни одной части декоратора выбора.

TopLeft 1

Верхний левый дескриптор декоратора выделения.

Top 2

Верхний средний дескриптор декоратора выбора.

TopRight 3

Верхний правый дескриптор выделения.

Right 4

Средний дескриптор справа от декоратора выбора.

BottomRight 5

Нижний правый дескриптор выделения.

Bottom 6

Нижний средний дескриптор декоратора выбора.

BottomLeft 7

Нижний левый дескриптор декоратора выделения.

Left 8

Средний дескриптор слева от декоратора выбора.

Selection 9

Область в границах декоратора выбора.

Примеры

В следующем примере показано, HitTestSelection как определить, следует ли создавать DataObject перетаскивание. Чтобы реализовать перетаскивание между двумя InkCanvas объектами, см. статью "Практическое руководство. Перетаскивание рукописного ввода".

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

Комментарии

Метод HitTestSelection возвращает значение, InkCanvasSelectionHitResult указывающее, какая часть декоратора выбора пересекается или окружает объект Point. Это полезно при выполнении операций перетаскивания.

Использование текста XAML

Этот класс обычно не используется в XAML.

Применяется к