Bagikan melalui


ManipulationDelta Kelas

Definisi

Berisi data transformasi yang terakumulasi saat peristiwa manipulasi terjadi.

public ref class ManipulationDelta
public class ManipulationDelta
type ManipulationDelta = class
Public Class ManipulationDelta
Warisan
ManipulationDelta

Contoh

Contoh berikut menunjukkan penanganan aktivitas untuk peristiwa tersebut ManipulationDelta . Contoh menerapkan Translationproperti , Scale, dan Rotation untuk memindahkan, mengubah ukuran, dan memutar Rectangle. Contoh ini adalah bagian dari contoh yang lebih besar di Walkthrough: Membuat Aplikasi Sentuhan Pertama Anda.

void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    
    // Get the Rectangle and its RenderTransform matrix.
    Rectangle rectToMove = e.OriginalSource as Rectangle;
    Matrix rectsMatrix = ((MatrixTransform)rectToMove.RenderTransform).Matrix;

    // Rotate the Rectangle.
    rectsMatrix.RotateAt(e.DeltaManipulation.Rotation, 
                         e.ManipulationOrigin.X, 
                         e.ManipulationOrigin.Y);

    // Resize the Rectangle.  Keep it square 
    // so use only the X value of Scale.
    rectsMatrix.ScaleAt(e.DeltaManipulation.Scale.X, 
                        e.DeltaManipulation.Scale.X, 
                        e.ManipulationOrigin.X,
                        e.ManipulationOrigin.Y);

    // Move the Rectangle.
    rectsMatrix.Translate(e.DeltaManipulation.Translation.X,
                          e.DeltaManipulation.Translation.Y);

    // Apply the changes to the Rectangle.
    rectToMove.RenderTransform = new MatrixTransform(rectsMatrix);

    Rect containingRect =
        new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);

    Rect shapeBounds =
        rectToMove.RenderTransform.TransformBounds(
            new Rect(rectToMove.RenderSize));

    // Check if the rectangle is completely in the window.
    // If it is not and intertia is occuring, stop the manipulation.
    if (e.IsInertial && !containingRect.Contains(shapeBounds))
    {
        e.Complete();
    }

    e.Handled = true;
}
Private Sub Window_ManipulationDelta(ByVal sender As Object, ByVal e As ManipulationDeltaEventArgs)

    ' Get the Rectangle and its RenderTransform matrix.
    Dim rectToMove As Rectangle = e.OriginalSource
    Dim rectTransform As MatrixTransform = rectToMove.RenderTransform
    Dim rectsMatrix As Matrix = rectTransform.Matrix


    ' Rotate the shape
    rectsMatrix.RotateAt(e.DeltaManipulation.Rotation,
                         e.ManipulationOrigin.X,
                         e.ManipulationOrigin.Y)

    ' Resize the Rectangle. Keep it square 
    ' so use only the X value of Scale.
    rectsMatrix.ScaleAt(e.DeltaManipulation.Scale.X,
                        e.DeltaManipulation.Scale.X,
                        e.ManipulationOrigin.X,
                        e.ManipulationOrigin.Y)

    'move the center
    rectsMatrix.Translate(e.DeltaManipulation.Translation.X,
                          e.DeltaManipulation.Translation.Y)

    ' Apply the changes to the Rectangle.
    rectTransform = New MatrixTransform(rectsMatrix)
    rectToMove.RenderTransform = rectTransform

    Dim container As FrameworkElement = e.ManipulationContainer
    Dim containingRect As New Rect(container.RenderSize)

    Dim shapeBounds As Rect = rectTransform.TransformBounds(
                                New Rect(rectToMove.RenderSize))

    ' Check if the rectangle is completely in the window.
    ' If it is not and intertia is occuring, stop the manipulation.
    If e.IsInertial AndAlso Not containingRect.Contains(shapeBounds) Then
        e.Complete()
    End If

    e.Handled = True
End Sub

Keterangan

Kelas ManipulationDelta berisi informasi tentang perubahan posisi manipulasi. Windows Presentation Foundation (WPF) menginterpretasikan perubahan sebagai Translation, , Expansionatau Rotation. ManipulationDelta Ketika peristiwa terjadi pada UIElement, gunakan properti pada ManipulationDelta objek untuk mengubah objek yang harus dimanipulasi. Kelas ini ManipulationDeltaEventArgs menyediakan dua properti jenis ManipulationDelta: DeltaManipulation dan CumulativeManipulation.

Untuk informasi selengkapnya tentang manipulasi, lihat Gambaran Umum Input. Untuk contoh aplikasi yang merespons manipulasi, lihat Panduan: Membuat Aplikasi Sentuhan Pertama Anda.

Konstruktor

ManipulationDelta(Vector, Double, Vector, Vector)

Menginisialisasi instans baru kelas ManipulationDelta.

Properti

Expansion

Mendapatkan atau menetapkan jumlah yang telah diubah ukuran manipulasinya dalam unit independen perangkat (1/96 inci per unit).

Rotation

Mendapatkan atau mengatur rotasi manipulasi dalam derajat.

Scale

Mendapatkan atau menetapkan jumlah yang telah diubah ukuran manipulasinya sebagai pengali.

Translation

Mendapatkan atau mengatur gerakan linier manipulasi.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk