UIElement.ManipulationDelta Evento
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Ocorre quando o dispositivo de entrada muda de posição durante uma manipulação.
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)
Tipo de Evento
Exemplos
O exemplo seguinte mostra um gestor de eventos para o ManipulationDelta evento. O exemplo usa a DeltaManipulation propriedade para mover, redimensionar e rodar um Rectangle. O exemplo verifica também se o ManipulationDelta evento ocorreu durante a inércia e se o retângulo está a tocar na borda de uma janela. Se esses casos forem verdadeiros, a aplicação interrompe a manipulação para impedir que o retângulo saia da área visível da aplicação. Este exemplo faz parte de um exemplo mais amplo em Walkthrough: Criar a Sua Aplicação de Primeiro Toque.
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
Observações
O ManipulationDelta evento ocorre várias vezes quando o utilizador arrasta os dedos pelo ecrã durante uma manipulação e novamente quando ocorre inércia. Pode usar a IsInertial propriedade para verificar se o evento está a ocorrer durante a inércia.
O elemento ligado ao evento ManipulationDelta não é afetado de forma alguma quando o evento ocorre. Deves fornecer a lógica ao elemento que vai ser manipulado. As CumulativeManipulation propriedades e, DeltaManipulation que são do tipo ManipulationDelta, contêm dados sobre como a posição das manipulações muda e são interpretadas como mover, redimensionar ou rodar um objeto. Aplica-se essa informação ao elemento que deve ser manipulado.
Para mais informações sobre manipulações, consulte a Visão Geral de Entrada. Para um exemplo de uma aplicação que responde a manipulações, veja Guia: Criar a Sua Aplicação de Primeiro Toque.
Informação sobre Eventos Roteados
| Iteme | Value |
|---|---|
| Campo identificador | ManipulationDeltaEvent |
| Estratégia de encaminhamento | Borbulhar |
| Delegar | EventHandler<TEventArgs> do tipo ManipulationDeltaEventArgs. |