InkCanvasSelectionHitResult 枚举

定义

InkCanvas 上标识选择装饰器的各个部分。Identifies the various parts of a selection adorner on an InkCanvas.

public enum class InkCanvasSelectionHitResult
public enum InkCanvasSelectionHitResult
type InkCanvasSelectionHitResult = 
Public Enum InkCanvasSelectionHitResult
继承
InkCanvasSelectionHitResult

字段

Bottom 6

选择装饰器的中部下方控点。The lower middle handle of the selection adorner.

BottomLeft 7

选择装饰器的左下方控点。The lower left handle of the selection adorner.

BottomRight 5

选择装饰器的右下方控点。The lower right handle of the selection adorner.

Left 8

选择装饰器的左侧边缘中间的控点。The middle handle on the left edge of the selection adorner.

None 0

无选择装饰器的任何部分。No part of the selection adorner.

Right 4

选择装饰器的右侧边缘中间的控点。The middle handle on the right edge of the selection adorner.

Selection 9

选择装饰器边界以内的区域。The area within the bounds of the selection adorner.

Top 2

选择装饰器的中部上方的控点。The upper middle handle of the selection adorner.

TopLeft 1

选择装饰器的左上方控点。The upper left handle of the selection adorner.

TopRight 3

选择装饰器的右上方控点。The upper right handle of the selection adorner.

示例

下面的示例演示如何使用HitTestSelection来确定是否DataObject创建来启动拖放操作。The following example demonstrates how use HitTestSelection to determine whether to create a DataObject to initiate drag and drop. 若要在两个InkCanvas对象之间实现拖放, 请参阅如何:拖放墨迹To implement drag and drop between two InkCanvas objects, see How to: Drag and Drop Ink.

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

注解

方法返回, 以指示选择Point装饰器的哪个部分与相交或包围。 InkCanvasSelectionHitResult HitTestSelectionThe HitTestSelection method returns an InkCanvasSelectionHitResult to indicate which part of the selection adorner intersects or surrounds a Point. 执行拖放操作时, 这非常有用。This is useful when performing drag-and-drop operations.

XAML 文本用法XAML Text Usage

此类通常不在 XAML 中使用。This class is not typically used in XAML.

适用于