StrokeCollection.GetBounds Método

Definición

Devuelve los límites de los trazos en la colección.

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

Devoluciones

Rect

Rect que contiene los límites de los trazos en StrokeCollection.

Ejemplos

En el ejemplo siguiente se muestra cómo obtener los límites de StrokeCollection y dibujarlos en el control . En este ejemplo se supone que hay un InkCanvas elemento denominado 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

Comentarios

El GetBounds método devuelve un Rect objeto que toma la apariencia del objeto Strokerepresentado. Por ejemplo, si Stroke tiene un ancho de 10 píxeles independientes de pantalla (DIP), Rect incluye todo el ancho de Stroke.

Se aplica a