Hey, took me quite a while
I had to change your picturebox so that it would be a square (has to have the same width and height, otherwise it's a little hard to change the scale).
Anyways, I added two functions, createGraphicsEx and setScale. I replaced all of your picturebox.creategraphics with my own function. The way you had it, your graph would disappear after a paint event. (it wont now )
setScale is supposed to zoom correctly, but there is something that you have to do yourself before it works:
VB Code:
Private minMag As Integer = Integer.MaxValue ' Leave the initial values like this
Private m***** As Integer = Integer.MinValue
Private Sub setScale(ByVal gr As Graphics)
' You need a code that would determine the correct value of minMag and m*****
minMag = -5
m***** = picResult.Width / 2
Dim newSize As Integer = m***** - minMag
Dim drawScale As Single = picResult.ClientSize.Width / newSize
' Zoom in
gr.ScaleTransform(drawScale, drawScale)
Dim screenTop As Integer = picResult.ClientSize.Height \ 2 - m*****
Dim screenLeft As Integer = picResult.ClientSize.Width \ 2 + minMag
' Locate the vectors
gr.TranslateTransform(-screenLeft, -screenTop)
End Sub
minMag and m***** are supposed to be the minimum and maximum.... what you have to do is to get the x and y component of ALL the vectors. then you have to do something like this:
VB Code:
for each vector...
' get the start and end point coordinate of each vector
' for example (x1,y1) is the start point and (x2,y2) is the end point of the vector
'..... missing code
if x1< minmag then minmag = x1
if y1< minmag then minmag = y1
if x2>m***** then m***** = x2
if y2>m***** then m***** = y2
next
btw I'm assuming that you may have some vectors that wont start from 0,0
right now, the way your program is, (x1, y1) would always be (0,0)
minMag is supposed to be the smallest component in the vectors (x or y component of the vector), and m***** is supposed to be the largest component in all the vector (x or y component)
I hope it makes sense. Right now if you run the program and add any vector, it will zoom from (-5,-5) to (width/2,width/2)
btw if you comment the setScale sub,it will do exactly what your program was doing before
Last edited by MrPolite; Jan 20th, 2003 at 03:56 PM.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
it's totally not professional though
it's zooming the whole thing, which means that your graphed lines will be thicker too, which isnt' quite good..
edit: aah I'm sure there are better ways.... take a look at the drawing2d.matrix class also
Last edited by MrPolite; Jan 20th, 2003 at 07:21 PM.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!