InkCanvasSelectionHitResult Enum

Definisi

Mengidentifikasi berbagai bagian dari adorner pilihan pada InkCanvas.

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

Bidang

Nama Nilai Deskripsi
None 0

Tidak ada bagian dari pemilihan yang menggemaskan.

TopLeft 1

Handel kiri atas dari adorner pilihan.

Top 2

Handel tengah atas dari adorner pilihan.

TopRight 3

Handel kanan atas dari adorner pilihan.

Right 4

Handel tengah di tepi kanan pujaan pilihan.

BottomRight 5

Handel kanan bawah dari pemilihan yang menggemaskan.

Bottom 6

Handel tengah bawah dari pemilihan yang menggemaskan.

BottomLeft 7

Handel kiri bawah dari pujaan pilihan.

Left 8

Handel tengah di tepi kiri pujaan pilihan.

Selection 9

Area dalam batas-batas pemilihan yang menggemaskan.

Contoh

Contoh berikut menunjukkan cara penggunaan HitTestSelection untuk menentukan apakah akan membuat DataObject untuk memulai seret dan letakkan. Untuk mengimplementasikan seret dan letakkan di antara dua InkCanvas objek, lihat Cara: Seret dan Jatuhkan Tinta.

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

Keterangan

Metode HitTestSelection mengembalikan InkCanvasSelectionHitResult untuk menunjukkan bagian mana dari pemilihan adorner intersects atau mengelilingi Point. Ini berguna saat melakukan operasi seret dan letakkan.

Penggunaan Teks XAML

Kelas ini biasanya tidak digunakan dalam XAML.

Berlaku untuk