StrokeCollection.GetBounds Metoda

Definice

Vrátí hranice tahů v kolekci.

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

Návraty

Rect

A Rect , který obsahuje hranice tahů v StrokeCollection.

Příklady

Následující příklad ukazuje, jak získat hranice a StrokeCollection kreslit je na ovládací prvek. Tento příklad předpokládá, že existuje volána InkCanvas 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

Poznámky

Metoda GetBounds vrátí Rect vzhled vykresleného Strokesouboru . Pokud je například Stroke 10 zobrazených nezávislých pixelů (DIP), Rect zahrnuje celou šířku Stroke.

Platí pro