UIElement.ManipulationDelta Evento
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Si verifica quando il dispositivo di input cambia posizione durante una manipolazione.
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 evento
Esempio
Nell'esempio seguente viene illustrato un gestore eventi per l'evento ManipulationDelta . Nell'esempio viene utilizzata la DeltaManipulation proprietà per spostare, ridimensionare e ruotare un oggetto Rectangle. L'esempio controlla inoltre se l'evento si è verificato durante l'inerzia ManipulationDelta e se il rettangolo sta toccando il bordo di una finestra. Se questi casi sono true, l'applicazione interrompe la manipolazione per impedire al rettangolo di uscire dall'area visibile dell'applicazione. Questo esempio fa parte di un esempio più ampio in Procedura dettagliata: Creazione della prima applicazione touch.
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
Commenti
L'evento ManipulationDelta si verifica più volte quando l'utente trascina le dita sullo schermo durante una manipolazione e di nuovo quando si verifica l'inerzia. È possibile utilizzare la IsInertial proprietà per verificare se l'evento si verifica durante l'inerzia.
L'elemento su con ManipulationDelta evento si verifica in alcun modo quando si verifica l'evento. È necessario fornire la logica all'elemento da modificare. Le CumulativeManipulation proprietà e DeltaManipulation , di tipo ManipulationDelta, contengono dati sulla modalità di modifica della posizione delle manipolazioni e interpretate come spostamento, ridimensionamento o rotazione di un oggetto. Si applicano tali informazioni all'elemento da modificare.
Per altre informazioni sulle manipolazioni, vedere Panoramica dell'input. Per un esempio di applicazione che risponde alle modifiche, vedere Procedura dettagliata: Creazione della prima applicazione touch.
Informazioni sugli eventi indirizzati
| Elemento | Valore |
|---|---|
| Campo Identificatore | ManipulationDeltaEvent |
| Strategia di routing | Bubbling |
| Delegato | EventHandler<TEventArgs> di tipo ManipulationDeltaEventArgs. |