ManipulationDelta Klasa

Definicja

Zawiera dane przekształcania, które są gromadzone w przypadku wystąpienia zdarzeń manipulowania.

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

Przykłady

W poniższym przykładzie przedstawiono procedurę obsługi zdarzeń dla ManipulationDelta zdarzenia. Przykład stosuje Translationwłaściwości , Scalei Rotation do przenoszenia, zmieniania rozmiaru i obracania obiektu Rectangle. Ten przykład jest częścią większego przykładu w przewodniku: tworzenie pierwszej aplikacji dotykowej.

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

Uwagi

Klasa ManipulationDelta zawiera informacje o zmianach w pozycji manipulowania. Windows Presentation Foundation (WPF) interpretuje zmiany jako Translation, Expansionlub Rotation. ManipulationDelta Gdy zdarzenie występuje w obiekcie UIElement, użyj właściwości obiektuManipulationDelta, aby przekształcić obiekt, który powinien być manipulowany. Klasa ManipulationDeltaEventArgs udostępnia dwie właściwości typu ManipulationDelta: DeltaManipulation i CumulativeManipulation.

Aby uzyskać więcej informacji na temat manipulacji, zobacz Omówienie danych wejściowych. Przykład aplikacji, która reaguje na manipulacje, zobacz Przewodnik: tworzenie pierwszej aplikacji dotykowej.

Konstruktory

ManipulationDelta(Vector, Double, Vector, Vector)

Inicjuje nowe wystąpienie klasy ManipulationDelta.

Właściwości

Expansion

Pobiera lub ustawia ilość zmiany rozmiaru manipulacji w jednostkach niezależnych od urządzenia (1/96 cala na jednostkę).

Rotation

Pobiera lub ustawia rotację manipulacji w stopniach.

Scale

Pobiera lub ustawia ilość zmiany rozmiaru manipulacji jako mnożnik.

Translation

Pobiera lub ustawia liniowy ruch manipulacji.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy