ManipulationDelta Klass

Definition

Innehåller transformeringsdata som ackumuleras när manipuleringshändelser inträffar.

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

Exempel

I följande exempel visas en händelsehanterare för ManipulationDelta händelsen. Exemplet använder Translationegenskaperna , Scaleoch Rotation för att flytta, ändra storlek på och rotera en Rectangle. Det här exemplet är en del av ett större exempel i Genomgång: Skapa ditt First Touch-program.

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

Kommentarer

Klassen ManipulationDelta innehåller information om ändringarna i en manipulationsposition. Windows Presentation Foundation (WPF) tolkar ändringarna som en Translation, Expansion eller Rotation. När händelsen ManipulationDelta inträffar på en UIElementanvänder du egenskaperna för ett ManipulationDelta objekt för att transformera det objekt som ska manipuleras. Klassen ManipulationDeltaEventArgs innehåller två egenskaper av typen ManipulationDelta: DeltaManipulation och CumulativeManipulation.

Mer information om manipuleringar finns i Översikt över indata. Ett exempel på ett program som svarar på manipulationer finns i Genomgång: Skapa ditt First Touch-program.

Konstruktorer

Name Description
ManipulationDelta(Vector, Double, Vector, Vector)

Initierar en ny instans av ManipulationDelta klassen.

Egenskaper

Name Description
Expansion

Hämtar eller anger hur mycket manipuleringen har ändrat storlek på i enhetsoberoende enheter (1/96 tum per enhet).

Rotation

Hämtar eller anger rotationen av manipuleringen i grader.

Scale

Hämtar eller anger det belopp som manipulationen har ändrat storlek på som en multiplikator.

Translation

Hämtar eller anger den linjära rörelsen för manipuleringen.

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för