ManipulationDelta Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Obsahuje transformační data, která se nahromáždí při manipulaci s událostmi.
public ref class ManipulationDelta
public class ManipulationDelta
type ManipulationDelta = class
Public Class ManipulationDelta
- Dědičnost
-
ManipulationDelta
Příklady
Následující příklad ukazuje obslužnou rutinu ManipulationDelta události pro událost. Příklad použije Translation, Scalea Rotation vlastnosti pro přesunutí, změnu velikosti a otočení Rectangle. Tento příklad je součástí většího příkladu v návodu: Vytvoření první dotykové aplikace.
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
Poznámky
Třída ManipulationDelta obsahuje informace o změnách v pozici manipulace. Windows Presentation Foundation (WPF) interpretuje změny jako Translation, Expansionnebo Rotation. Když dojde k ManipulationDelta události v objektu UIElement, použijte vlastnosti ManipulationDelta objektu k transformaci objektu, který by měl být manipulován. Třída ManipulationDeltaEventArgs poskytuje dvě vlastnosti typu ManipulationDelta: DeltaManipulation a CumulativeManipulation.
Další informace o manipulaci najdete v přehledu vstupu. Příklad aplikace, která reaguje na manipulaci, najdete v části Návod: Vytvoření první dotykové aplikace.
Konstruktory
| Name | Description |
|---|---|
| ManipulationDelta(Vector, Double, Vector, Vector) |
Inicializuje novou instanci ManipulationDelta třídy. |
Vlastnosti
| Name | Description |
|---|---|
| Expansion |
Získá nebo nastaví velikost manipulace se změněnou velikostí v jednotkách nezávislých na zařízení (1/96 palce na jednotku). |
| Rotation |
Získá nebo nastaví otočení manipulace ve stupních. |
| Scale |
Získá nebo nastaví množství, které manipulace změnila jako násobitel. |
| Translation |
Získá nebo nastaví lineární pohyb manipulace. |
Metody
| Name | Description |
|---|---|
| Equals(Object) |
Určuje, zda je zadaný objekt roven aktuálnímu objektu. (Zděděno od Object) |
| GetHashCode() |
Slouží jako výchozí funkce hash. (Zděděno od Object) |
| GetType() |
Získá Type aktuální instance. (Zděděno od Object) |
| MemberwiseClone() |
Vytvoří mělkou kopii aktuálního Object. (Zděděno od Object) |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt. (Zděděno od Object) |