InkCanvasSelectionHitResult 列挙型

定義

InkCanvas の選択装飾のさまざまな部分を識別します。

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

フィールド

Bottom 6

選択装飾の中央下ハンドル。

BottomLeft 7

選択装飾の左下ハンドル。

BottomRight 5

選択装飾の右下ハンドル。

Left 8

選択装飾の左端にある中央ハンドル。

None 0

選択装飾のどこの部分も含まれません。

Right 4

選択装飾の右端にある中央ハンドル。

Selection 9

選択装飾の境界内の領域。

Top 2

選択装飾の中央上ハンドル。

TopLeft 1

選択装飾の左上ハンドル。

TopRight 3

選択装飾の右上ハンドル。

次の例では、 を使用 HitTestSelection して、 を作成 DataObject してドラッグ アンド ドロップを開始するかどうかを判断する方法を示します。 2 つの 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 では使用されません。

適用対象