ManipulationDeltaEventArgs.ReportBoundaryFeedback(ManipulationDelta) ManipulationDeltaEventArgs.ReportBoundaryFeedback(ManipulationDelta) ManipulationDeltaEventArgs.ReportBoundaryFeedback(ManipulationDelta) ManipulationDeltaEventArgs.ReportBoundaryFeedback(ManipulationDelta) Method

Definition

Gibt an, dass die Manipulation über bestimmte Grenzen hinausgegangen ist.Specifies that the manipulation has gone beyond certain boundaries.

public:
 void ReportBoundaryFeedback(System::Windows::Input::ManipulationDelta ^ unusedManipulation);
public void ReportBoundaryFeedback (System.Windows.Input.ManipulationDelta unusedManipulation);
member this.ReportBoundaryFeedback : System.Windows.Input.ManipulationDelta -> unit
Public Sub ReportBoundaryFeedback (unusedManipulation As ManipulationDelta)

Parameter

unusedManipulation
ManipulationDelta ManipulationDelta ManipulationDelta ManipulationDelta

Der Teil der Bearbeitung, die das Verschieben über die Begrenzung hinaus darstellt.The portion of the manipulation that represents moving beyond the boundary.

Ausnahmen

unusedManipulation ist null.unusedManipulation is null.

Beispiele

Das folgende Beispiel zeigt einen Ereignishandler für das ManipulationDelta -Ereignis, das ReportBoundaryFeedback die-Methode aufruft, wenn der Benutzer das Element über den Rand seines Containers verschiebt.The following example shows an event handler for the ManipulationDelta event that calls the ReportBoundaryFeedback method when the user moves the element over the edge of its container. Um dieses Beispiel zu testen, führen Sie die Schritte in Exemplarische Vorgehensweise aus: Erstellen Sie Ihre erste Finger Eingabe Anwendung, und ersetzen Sie den Code in Schritt 5 durch diesen Code.To test this example, follow the steps in Walkthrough: Creating Your First Touch Application and replace the code in step 5 with this code.

void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{

    Rectangle rectToMove = e.OriginalSource as Rectangle;
    Vector overshoot;

    // When the element crosses the boundary of the window, check whether 
    // the manipulation is in inertia.  If it is, complete the manipulation.
    // Otherwise, report the boundary feedback.
    if (CalculateOvershoot(rectToMove, e.ManipulationContainer, out overshoot))
    {
        if (e.IsInertial)
        {
            e.Complete();
            e.Handled = true;
            return;
        }
        else
        {
            //Report that the element hit the boundary
            e.ReportBoundaryFeedback(new ManipulationDelta(overshoot, 0, new Vector(), new Vector()));

        }
    }
  
    // Move the element as usual.

    // Get the Rectangle and its RenderTransform matrix.
    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);

    e.Handled = true;
}

private bool CalculateOvershoot(UIElement element, IInputElement container, out Vector overshoot)
{
    // Get axis aligned element bounds
    var elementBounds = element.RenderTransform.TransformBounds(
                  VisualTreeHelper.GetDrawing(element).Bounds);

    //double extraX = 0.0, extraY = 0.0;
    overshoot = new Vector();

    FrameworkElement parent = container as FrameworkElement;
    if (parent == null)
    {
        return false;
    }

    // Calculate overshoot.  
    if (elementBounds.Left < 0)
        overshoot.X = elementBounds.Left;
    else if (elementBounds.Right > parent.ActualWidth)
        overshoot.X = elementBounds.Right - parent.ActualWidth;

    if (elementBounds.Top < 0)
        overshoot.Y = elementBounds.Top;
    else if (elementBounds.Bottom > parent.ActualHeight)
        overshoot.Y = elementBounds.Bottom - parent.ActualHeight;

    // Return false if Overshoot is empty; otherwsie, return true.
    return !Vector.Equals(overshoot, new Vector());
}
Private Sub Window_ManipulationDelta(ByVal sender As Object, ByVal e As ManipulationDeltaEventArgs)

    Dim rectToMove As Rectangle = TryCast(e.OriginalSource, Rectangle)
    Dim overshoot As Vector

    ' When the element crosses the boundary of the window, check whether 
    ' the manipulation is in inertia. If it is, complete the manipulation.
    ' Otherwise, report the boundary feedback.
    If CalculateOvershoot(rectToMove, e.ManipulationContainer, overshoot) Then
        If e.IsInertial Then
            e.Complete()
            e.Handled = True
            Exit Sub
        Else
            'Report that the element hit the boundary

            e.ReportBoundaryFeedback(New ManipulationDelta(overshoot, 0, New Vector(), New Vector()))
        End If
    End If

    ' Move the element as usual.

    ' Get the Rectangle and its RenderTransform matrix.
    Dim rectsMatrix As Matrix = DirectCast(rectToMove.RenderTransform, MatrixTransform).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)

    e.Handled = True
End Sub

Private Function CalculateOvershoot(ByVal element As UIElement, ByVal container As IInputElement, ByRef overshoot As Vector) As Boolean
    ' Get axis aligned element bounds
    Dim elementBounds = element.RenderTransform.TransformBounds(VisualTreeHelper.GetDrawing(element).Bounds)

    'double extraX = 0.0, extraY = 0.0;
    overshoot = New Vector()

    Dim parent As FrameworkElement = TryCast(container, FrameworkElement)
    If parent Is Nothing Then
        Return False
    End If

    ' Calculate overshoot. 
    If elementBounds.Left < 0 Then
        overshoot.X = elementBounds.Left
    ElseIf elementBounds.Right > parent.ActualWidth Then
        overshoot.X = elementBounds.Right - parent.ActualWidth
    End If

    If elementBounds.Top < 0 Then
        overshoot.Y = elementBounds.Top
    ElseIf elementBounds.Bottom > parent.ActualHeight Then
        overshoot.Y = elementBounds.Bottom - parent.ActualHeight
    End If

    ' Return false if Overshoot is empty; otherwsie, return true.
    Return Not Vector.Equals(overshoot, New Vector())
End Function

Hinweise

Verwenden Sie ReportBoundaryFeedback die-Methode, um anzugeben, dass ein Element über eine bestimmte Grenze hinaus verschoben wurde.Use the ReportBoundaryFeedback method to indicate that an element has moved beyond a certain boundary. Wenn ein Benutzer beispielsweise ein Element außerhalb der Begrenzungen Windoweines verschiebt, können Sie diese Methode zum Melden des Fensters an das Fenster aufzurufen.For example, if a user moves an element outside of the bounds of a Window, you can call this method to report that to the window. Wenn Sie aufzurufen ReportBoundaryFeedback, ManipulationBoundaryFeedback tritt das-Ereignis auf.When you call ReportBoundaryFeedback, the ManipulationBoundaryFeedback event occurs. Standardmäßig Window abonniert ManipulationBoundaryFeedback das-Ereignis, um dem Benutzer visuelles Feedback zu geben, dass eine Grenze erreicht wurde.By default, the Window subscribes to the ManipulationBoundaryFeedback event to provide visual feedback to the user that a boundary has been reached. Sie können abonnieren, ManipulationBoundaryFeedback um benutzerdefiniertes Verhalten zu implementieren.You can subscribe to ManipulationBoundaryFeedback to implement custom behavior.

Gilt für: