Condividi tramite


StrokeCollection.GetBounds Metodo

Definizione

Restituisce i limiti dei tratti nella raccolta.

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

Restituisce

Rect

Oggetto Rect che contiene i limiti dei tratti in StrokeCollection.

Esempio

Nell'esempio seguente viene illustrato come ottenere i limiti dell'oggetto StrokeCollection e disegnarli nel controllo . In questo esempio si presuppone che sia presente un InkCanvas denominato 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

Commenti

Il GetBounds metodo restituisce un Rect oggetto che assume l'aspetto dell'oggetto di cui è stato Strokeeseguito il rendering. Ad esempio, se Stroke è largo 10 pixel indipendenti (DIP), include Rect l'intera larghezza dell'oggetto Stroke.

Si applica a