ManipulationDelta Класс

Определение

Содержит данные о преобразовании, накапливаемые во время событий манипуляции.

public ref class ManipulationDelta
public class ManipulationDelta
type ManipulationDelta = class
Public Class ManipulationDelta
Наследование
ManipulationDelta

Примеры

В следующем примере показан обработчик событий для ManipulationDelta события . В примере применяются Translationсвойства , Scaleи Rotation для перемещения, изменения размера и поворота Rectangleобъекта . Этот пример является частью более крупного примера в разделе Пошаговое руководство. Создание первого сенсорного приложения.

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

Комментарии

Класс ManipulationDelta содержит сведения об изменениях положения манипуляции. Windows Presentation Foundation (WPF) интерпретирует изменения как Translation, Expansionили Rotation. ManipulationDelta Когда событие возникает в UIElement, используйте свойства объекта для ManipulationDelta преобразования объекта, которым необходимо управлять. Класс ManipulationDeltaEventArgs предоставляет два свойства типа ManipulationDelta: DeltaManipulation и CumulativeManipulation.

Дополнительные сведения о манипуляциях см. в разделе Общие сведения о входных данных. Пример приложения, реагирующего на манипуляции, см. в разделе Пошаговое руководство. Создание первого сенсорного приложения.

Конструкторы

ManipulationDelta(Vector, Double, Vector, Vector)

Инициализирует новый экземпляр класса ManipulationDelta.

Свойства

Expansion

Возвращает или задает размер, измененный манипуляцией в независимых от устройства единицах (1/96 дюйма на единицу).

Rotation

Получает или задает угол поворота манипуляции в градусах.

Scale

Получает или задает величину изменения размера манипуляции в виде множителя.

Translation

Получает или задает линейное перемещение манипуляции.

Методы

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Применяется к