UIElement.ManipulationDelta Evento

Definição

Ocorre quando o dispositivo de entrada muda de posição durante uma manipulação.Occurs when the input device changes position during a manipulation.

public:
 event EventHandler<System::Windows::Input::ManipulationDeltaEventArgs ^> ^ ManipulationDelta;
public event EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> ManipulationDelta;
member this.ManipulationDelta : EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> 
Public Custom Event ManipulationDelta As EventHandler(Of ManipulationDeltaEventArgs) 

Exemplos

O exemplo a seguir mostra um manipulador de eventos para o evento ManipulationDelta.The following example shows an event handler for the ManipulationDelta event. O exemplo usa a propriedade DeltaManipulation para mover, redimensionar e girar uma Rectangle.The example uses the DeltaManipulation property to move, resize, and rotate a Rectangle. O exemplo também verifica se o evento de ManipulationDelta ocorreu durante inércia e se o retângulo está tocando na borda de uma janela.The example also checks whether the ManipulationDelta event occurred during inertia and whether the rectangle is touching the edge of a window. Se esses casos forem verdadeiros, o aplicativo interromperá a manipulação para impedir que o retângulo deixe a área visível do aplicativo.If those cases are true, the application stops the manipulation to prevent the rectangle from leaving the visible area of the application. Este exemplo é parte de um exemplo maior em passo a passos: criando seu primeiro aplicativo de toque.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

Comentários

O evento ManipulationDelta ocorre várias vezes quando o usuário arrasta os dedos pela tela durante uma manipulação e novamente quando o inércia ocorre.The ManipulationDelta event occurs multiple times when the user drags fingers over the screen during a manipulation and again when inertia occurs. Você pode usar a propriedade IsInertial para verificar se o evento está ocorrendo durante o inércia.You can use the IsInertial property to check whether the event is occurring during inertia.

O elemento em com ManipulationDelta evento ocorre não é afetado de nenhuma maneira quando o evento ocorre.The element on with ManipulationDelta event occurs is not affected in any way when the event occurs. Você deve fornecer a lógica para o elemento que será manipulado.You must provide the logic to the element that is to be manipulated. As propriedades CumulativeManipulation e DeltaManipulation, que são do tipo ManipulationDelta, contêm dados sobre como a posição das manipulações é alterada e interpretada como mover, redimensionar ou girar um objeto.The CumulativeManipulation and DeltaManipulation properties, which are of type ManipulationDelta, contain data about how the position of the manipulations change and interpreted as moving, resizing, or rotating an object. Você aplica essas informações ao elemento que deve ser manipulado.You apply that information to the element that is to be manipulated.

Para obter mais informações sobre manipulações, consulte a visão geral de entrada.For more information about manipulations, see the Input Overview. Para obter um exemplo de um aplicativo que responde a manipulações, consulte passo a passos: criando seu primeiro aplicativo de toque.For an example of an application that responds to manipulations, see Walkthrough: Creating Your First Touch Application.

Informações Sobre Eventos RoteadosRouted Event Information

Campo de identificadorIdentifier field ManipulationDeltaEvent
Estratégia de roteamentoRouting strategy PropagaçãoBubbling
DelegadoDelegate EventHandler<TEventArgs> do tipo ManipulationDeltaEventArgs.EventHandler<TEventArgs> of type ManipulationDeltaEventArgs.

Aplica-se a