StrokeCollection.GetBounds Méthode

Définition

Retourne les limites des traits dans la collection.

public:
 System::Windows::Rect GetBounds();
public System.Windows.Rect GetBounds ();
member this.GetBounds : unit -> System.Windows.Rect
Public Function GetBounds () As Rect

Retours

Rect

Rect qui contient les limites des traits dans StrokeCollection.

Exemples

L’exemple suivant montre comment obtenir les limites du StrokeCollection contrôle et les dessiner sur le contrôle. Cet exemple suppose qu’il existe un InkCanvas appel inkCanvas1.

public void GetBounds()
{
    Rect bounds = inkCanvas1.Strokes.GetBounds();

    Rectangle boundsShape = new Rectangle();
    boundsShape.Width = bounds.Width;
    boundsShape.Height = bounds.Height;
    boundsShape.Stroke = Brushes.Red;

    InkCanvas.SetTop(boundsShape, bounds.Top);
    InkCanvas.SetLeft(boundsShape, bounds.Left);

    inkCanvas1.Children.Add(boundsShape);
}
Public Sub GetBounds()
    Dim bounds As Rect = inkCanvas1.Strokes.GetBounds()

    Dim boundsShape As Rectangle = New Rectangle()
    boundsShape.Width = bounds.Width
    boundsShape.Height = bounds.Height
    boundsShape.Stroke = Brushes.Red

    InkCanvas.SetTop(boundsShape, bounds.Top)
    InkCanvas.SetLeft(boundsShape, bounds.Left)

    inkCanvas1.Children.Add(boundsShape)
End Sub

Remarques

La GetBounds méthode retourne un Rect qui prend l’apparence du rendu Stroke. Par exemple, s’il Stroke s’agit de 10 pixels indépendants (DIP), il Rect inclut la largeur entière du Stroke.

S’applique à