Ler em inglês

Partilhar via


UIElement.ManipulationDelta Evento

Definição

Ocorre quando o dispositivo de entrada muda de posição durante uma manipulação.

C#
public event EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> ManipulationDelta;

Tipo de evento

Exemplos

O exemplo a seguir mostra um manipulador de eventos para o ManipulationDelta evento. O exemplo usa a DeltaManipulation propriedade para mover, redimensionar e girar um Rectangle. O exemplo também verifica se o ManipulationDelta evento ocorreu durante a inércia e se o retângulo está tocando a borda de uma janela. Se esses casos forem verdadeiros, o aplicativo interromperá a manipulação para impedir que o retângulo deixe a área visível do aplicativo. Este exemplo faz parte de um exemplo maior em Passo a passo: Criando seu primeiro aplicativo touch.

C#
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;
}

Comentários

O ManipulationDelta evento ocorre várias vezes quando o usuário arrasta os dedos sobre a tela durante uma manipulação e novamente quando ocorre inércia. Você pode usar a IsInertial propriedade para marcar se o evento está ocorrendo durante a inércia.

O elemento em com ManipulationDelta evento ocorre não é afetado de forma alguma quando o evento ocorre. Você deve fornecer a lógica para o elemento que deve ser manipulado. As CumulativeManipulation propriedades 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. Você aplica essas informações ao elemento que deve ser manipulado.

Para obter mais informações sobre manipulações, consulte Visão geral de entrada. Para obter um exemplo de um aplicativo que responde a manipulações, consulte Passo a passo: criando seu primeiro aplicativo touch.

Informações de evento encaminhado

Campo Identificador ManipulationDeltaEvent
Estratégia de roteamento Borbulhando
Delegar EventHandler<TEventArgs> do tipo ManipulationDeltaEventArgs.

Aplica-se a

Produto Versões
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9