ManipulationDeltaEventArgs 類別

定義

提供 ManipulationDelta 事件的資料。

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 。 這個範例會 DeltaManipulation 使用 屬性來移動、重設大小及旋轉 Rectangle。 此範例也會檢查事件是否 ManipulationDelta 在慣性期間發生,以及矩形是否觸碰窗口邊緣。 如果這些情況成立,應用程式會停止操作,以防止矩形離開應用程式的可見區域。 本範例是逐步解說 :建立您的第一個觸控應用程式中較大範例的一部分。

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 包含操作位置變更的相關數據。 屬性 DeltaManipulation 包含上次 ManipulationDelta 發生事件之後發生的變更。 屬性 CumulativeManipulation 包含目前操作所發生的變更總數。 您可以使用其中一個屬性來轉換操作的物件。

您可以呼叫 Complete 方法來結束操作,或藉由呼叫 StartInertia 方法強制操作進入慣性。

屬性

CumulativeManipulation

取得目前操作的累計變更。

DeltaManipulation

取得目前操作最近一次的變更。

Device

取得初始化這個事件的輸入裝置。

(繼承來源 InputEventArgs)
Handled

取得或設定值,這個值表示路由事件在傳送路由時之事件處理的目前狀態。

(繼承來源 RoutedEventArgs)
IsInertial

取得值,這個值表示是否在慣性作用期間發生 ManipulationDelta 事件。

ManipulationContainer

取得容器,這個容器會定義操作的座標。

ManipulationOrigin

取得操作起源的點。

Manipulators

取得物件的集合,表示用於操作的觸控接點。

OriginalSource

在父類別進行任何可能的 Source 調整之前,取得純點擊測試所判定的原始報告來源。

(繼承來源 RoutedEventArgs)
RoutedEvent

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEvent

(繼承來源 RoutedEventArgs)
Source

取得或設定引發事件之物件的參考。

(繼承來源 RoutedEventArgs)
Timestamp

取得這個事件發生的時間。

(繼承來源 InputEventArgs)
Velocities

取得操作最近一次變更的速率。

方法

Cancel()

取消操作。

Complete()

完成操作但不使用慣性。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

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

以型別專屬的方式叫用事件處理常式,這樣做能夠提升事件系統的效率。

(繼承來源 InputEventArgs)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnSetSource(Object)

在衍生類別中覆寫時,每當執行個體的 Source 屬性值變更,便會提供通知回呼進入點。

(繼承來源 RoutedEventArgs)
ReportBoundaryFeedback(ManipulationDelta)

指定操作已經超出特定界限。

StartInertia()

藉由忽略後續接觸移動並引發 ManipulationInertiaStarting 事件,在操作上啟動慣性。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於