Determining the size of a path drawn image

Napivo1972

Well-known member
Joined
Aug 31, 2004
Messages
75
I use the following Paint Event to draw a vector graphics image.

Code:
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim p As New Pen(Color.Black, 1)
        e.Graphics.TranslateTransform(-hsb.Value * 10, -vsb.Value * 10)
        Dim m As New Matrix
        m.Scale(zoom, zoom)
        zoom = 1
        Dim t1 As Integer
        Dim pth As GraphicsPath
        For t1 = 0 To 0
            For Each pth In y(t1).gPaths
                pth.Transform(m)
                e.Graphics.DrawPath(p, pth)
            Next
        Next
        For t1 = 5 To 5
            For Each pth In y(t1).gPaths
                e.Graphics.DrawPath(p, pth)
            Next
        Next
    End Sub

This works great but I need to find the height and the width of the drawn picture to set the scroll bars min and max values.

Does any of you have an easy method to do this?
 
thanks Ming_Lei You put me on the right track.

Dim rect As RectangleF
rect = RectangleF.Union(rect, pth.GetBounds)

Works like a charm
 
Back
Top