ManipulationDeltaEventArgs 類別

定義

提供 ManipulationDelta 事件的資料。Provides data for the ManipulationDelta event.

public ref class ManipulationDeltaEventArgs sealed : System::Windows::Input::InputEventArgs
public sealed class ManipulationDeltaEventArgs : System.Windows.Input.InputEventArgs
type ManipulationDeltaEventArgs = class
    inherit InputEventArgs
Public NotInheritable Class ManipulationDeltaEventArgs
Inherits InputEventArgs
繼承
ManipulationDeltaEventArgs

範例

下列範例會顯示ManipulationDelta事件的事件處理常式。The following example shows an event handler for the ManipulationDelta event. 這個範例會使用DeltaManipulation屬性來移動、調整大小和Rectangle旋轉。The example uses the DeltaManipulation property to move, resize, and rotate a Rectangle. 此範例也會檢查ManipulationDelta事件是否發生在慣性期間, 以及矩形是否觸及視窗的邊緣。The example also checks whether the ManipulationDelta event occurred during inertia and whether the rectangle is touching the edge of a window. 如果這些情況成立, 應用程式會停止操作, 防止矩形離開應用程式的可見區域。If those cases are true, the application stops the manipulation to prevent the rectangle from leaving the visible area of the application. 這個範例是逐步解說中較大範例的一部分:建立您的第一個觸控應用程式。This example is part of a larger example in Walkthrough: Creating Your First Touch Application.

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

備註

ManipulationDeltaEventArgs類別包含操作位置變更的相關資料。The ManipulationDeltaEventArgs class contains data about changes in the position of a manipulation. 屬性包含上次ManipulationDelta發生事件之後所發生的變更。 DeltaManipulationThe DeltaManipulation property contains the changes that occurred since the last ManipulationDelta event occurred. CumulativeManipulation屬性包含目前操作所發生的總變更。The CumulativeManipulation property contains the total changes that occurred for the current manipulation. 您可以使用其中一個屬性來轉換操作物件。You use one of those properties to transform the manipulated object.

您可以藉由呼叫Complete方法來結束操作, 或藉由StartInertia呼叫方法來強制操作進入慣性。You can end a manipulation by calling the Complete method or force the manipulation into inertia by calling the StartInertia method.

屬性

CumulativeManipulation

取得目前操作的累計變更。Gets the cumulated changes of the current manipulation.

DeltaManipulation

取得目前操作最近一次的變更。Gets the most recent changes of the current manipulation.

Device

取得初始化這個事件的輸入裝置。Gets the input device that initiated this event.

(繼承來源 InputEventArgs)
Handled

取得或設定值,這個值表示路由事件在傳送路由時之事件處理的目前狀態。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(繼承來源 RoutedEventArgs)
IsInertial

取得值,這個值表示是否在慣性作用期間發生 ManipulationDelta 事件。Gets a value that indicates whether the ManipulationDelta event occurs during inertia.

ManipulationContainer

取得容器,這個容器會定義操作的座標。Gets the container that defines the coordinates for the manipulation.

ManipulationOrigin

取得操作起源的點。Gets the point from which the manipulation originated.

Manipulators

取得物件的集合,表示用於操作的觸控接點。Gets a collection of objects that represents the touch contacts for the manipulation.

OriginalSource

在父類別進行任何可能的 Source 調整之前,取得純點擊測試所判定的原始報告來源。Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.

(繼承來源 RoutedEventArgs)
RoutedEvent

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(繼承來源 RoutedEventArgs)
Source

取得或設定引發事件之物件的參考。Gets or sets a reference to the object that raised the event.

(繼承來源 RoutedEventArgs)
Timestamp

取得這個事件發生的時間。Gets the time when this event occurred.

(繼承來源 InputEventArgs)
Velocities

取得操作最近一次變更的速率。Gets the rates of the most recent changes to the manipulation.

方法

Cancel()

取消操作。Cancels the manipulation.

Complete()

完成操作但不使用慣性。Completes the manipulation without inertia.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InvokeEventHandler(Delegate, Object)

以型別專屬的方式叫用事件處理常式,這樣做能夠提升事件系統的效率。Invokes event handlers in a type-specific way, which can increase event system efficiency.

(繼承來源 InputEventArgs)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnSetSource(Object)

在衍生類別中覆寫時,每當執行個體的 Source 屬性值變更,便會提供通知回呼進入點。When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.

(繼承來源 RoutedEventArgs)
ReportBoundaryFeedback(ManipulationDelta)

指定操作已經超出特定界限。Specifies that the manipulation has gone beyond certain boundaries.

StartInertia()

藉由忽略後續接觸移動並引發 ManipulationInertiaStarting 事件,在操作上啟動慣性。Starts inertia on the manipulation by ignoring subsequent contact movements and raising the ManipulationInertiaStarting event.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於