StrokeCollection.GetBounds Método

Definição

Devolve os limites dos traços na coleção.

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

Devoluções

A Rect que contém os limites dos traços no StrokeCollection.

Exemplos

O exemplo seguinte demonstra como obter os limites de e StrokeCollection desenhá-los no controlo. Este exemplo assume que existe um InkCanvas chamado 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

Observações

O GetBounds método retorna a Rect que assume a aparência do renderizado Stroke. Por exemplo, se Stroke tem 10 píxeis independentes do ecrã (DIP) de largura, o Rect inclui toda a largura do Stroke.

Aplica-se a