zoom window for a vector graphics filled 90% of picturebox2 and picturebox2 is of limited size (591 x 486 pix) and all the verctors is drawn function

  • Thread starter Thread starter Hany Metry
  • Start date Start date
H

Hany Metry

Guest
Hi,

I have the following code which zoom window for a vector graphics filled 90% of picturebox2.

The form contain checkbox of name ZoomCb

The code does not draw the rectangle of zoom while I see that I have not mistake

Just copy the code into empty form. picture box2 size (593 x 486)

Private Sub PictureBox2_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox2.Paint
Private ScaleWidth As Single = 100000
Private ScaleRatio As Single = 1
Private Yoffset As Single
Private Corner As New Point(0, 0)
Private GridStep As Single = ScaleWidth / 5
Private MouseDownPt, MouseMovePt, ZoomMouseDownPt, ZoomMouseMovePt As PointF
Private MouseStatus As Integer
Private dx As Integer
Private dy As Integer
Private ToolCbCancel As Boolean = False
Xcoor(0)=200
Xcoor(1)=200
Xcoor(2)=-200
Xcoor(3)=-200
Ycoor(0)=-350
Ycoor(1)=350
Ycoor(2)=350
Ycoor(3)=-350
coorx1(0)=141
coorx1(1)=141
coorx1(2)=141
coorx1(3)=141
coorx1(4)=0
coorx1(5)=-141
coorx1(6)=-141
coorx1(7)=-141
coorx1(8)=-141
coorx1(9)=-141
coorx1(10)=0
coorx1(11)=141
coory1(0)=-145.5
coory1(1)=0
coory1(2)=145.5
coory1(3)=291
coory1(4)=291
coory1(5)=291
coory1(6)=145.5
coory1(7)=0
coory1(8)=-145.5
coory1(9)=-291
coory1(10)=-291
coory1(11)=-291
Xmax=200
Xmin=-200
Ymax=350
Ymin=-350
Numcoor=4
Numbarcoor=12
Dim vv As Integer
Dim YY As Integer
b = Xmax - Xmin
t = Ymax - Ymin
Dim sf As Single = CSng(PictureBox2.ClientSize.Width / (ScaleRatio * ScaleWidth))
e.Graphics.ScaleTransform(sf, sf)
e.Graphics.TranslateTransform(-Corner.X, -Corner.Y)
If MouseStatus = 3 Or MouseStatus = 1 Then
If (Ymax - Ymin) / (Xmax - Xmin) <= Convert.ToDouble(PictureBox2.ClientSize.Height / PictureBox2.ClientSize.Width) Then
For vv = 0 To Numcoor - 1
Xcoor11(vv) = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + ((Math.Abs(Xmin) + Xcoor(vv)) / Convert.ToDouble(b)) * 0.85 * PictureBox2.ClientSize.Width)
Ycoor11(vv) = CInt((PictureBox2.ClientSize.Height * 0.44) / sf - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - Ycoor(vv)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Next
X3a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b) - 0.085 * (PictureBox2.ClientSize.Width / sf))
X4a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b) + 0.085 * (PictureBox2.ClientSize.Width / sf))
Y3a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Y4a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax + 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Y5a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
X5a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b))
Else
For vv = 0 To Numcoor - 1
Xcoor11(vv) = CInt(0.5 * (PictureBox2.ClientSize.Width / sf) + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + Xcoor(vv)) / Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf))
Ycoor11(vv) = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - Ycoor(vv)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
Next
X3a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) - 0.1 * Convert.ToDouble(b)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf)
X4a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + 0.1 * Convert.ToDouble(b)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf)
Y3a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
Y4a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax + 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
X5a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin)) / Convert.ToDouble(t)) * (0.85 * PictureBox2.ClientSize.Height / sf))
Y5a = CInt((PictureBox2.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax) * 0.85 * (PictureBox2.Height / sf) / Convert.ToDouble(t))
End If
Dim points1(Numcoor - 1) As Point
For vv = 0 To points1.Length - 1
points1(vv).X = CInt(Xcoor11(vv))
points1(vv).Y = CInt(Ycoor11(vv))
Next
'e.Graphics.FillPolygon(mbrush1, points1)
e.Graphics.DrawPolygon(mpen3, points1)
e.Graphics.DrawLine(mpen, X3a, Y5a, X4a, Y5a)
e.Graphics.DrawLine(mpen, X5a, Y3a, X5a, Y4a)
Dim DrawFont9 As New Font("Verdana", CInt(10 / sf), FontStyle.Regular)
Dim DrawFont6 As New Font("Verdana", CInt(6 / sf), FontStyle.Regular)
e.Graphics.DrawString(Str3, DrawFont9, Brush2, CInt(X4a + 5 / sf), CInt(Y5a - 8 / sf))
e.Graphics.DrawString(Str4, DrawFont9, Brush2, CInt(X5a - 6 / sf), CInt(Y3a - 18 / sf))
Dim Str As String = CInt(b) & " x " & CInt(t) & " mm"
Dim Brush As New SolidBrush(Color.Black)
Dim textSize72 As SizeF
textSize72 = G.MeasureString(Str, DrawFont9)
XQQ17 = CInt((PictureBox2.ClientSize.Width / sf - CInt(textSize72.Width)) / 2)
e.Graphics.DrawString(Str, DrawFont9, Brush, XQQ17, CInt(0.87 * PictureBox2.ClientSize.Height / sf))
If NumBarcoor >= 1 Then
If (Ymax - Ymin) / (Xmax - Xmin) <= Convert.ToDouble(PictureBox2.ClientSize.Height / PictureBox2.ClientSize.Width) Then
For YY = 0 To NumBarcoor - 1
Diaf1(YY) = Convert.ToInt32(Dia(YY) * (PictureBox2.ClientSize.Width / sf) * 0.85 / Convert.ToSingle(b))
coorXf1(YY) = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + ((Math.Abs(Xmin) + coorx1(YY)) / Convert.ToDouble(b)) * 0.85 * (PictureBox2.ClientSize.Width / sf)) - Diaf1(YY) / 2
coorYf1(YY) = CInt((PictureBox2.ClientSize.Height * 0.44) / sf - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - coory1(YY)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b))) - Diaf1(YY) / 2
e.Graphics.FillEllipse(mbrush, CInt(coorXf1(YY)), CInt(coorYf1(YY)), CInt(Diaf1(YY)), CInt(Diaf1(YY)))
e.Graphics.DrawString(CStr(YY + 1), DrawFont6, Brush, CInt(coorXf1(YY) + Diaf1(YY) + 1 / sf), CInt(coorYf1(YY) - 8 / sf))
Next
Else
For YY = 0 To NumBarcoor - 1
Diaf1(YY) = Convert.ToInt32(Dia(YY) * (PictureBox2.ClientSize.Height / sf) * 0.85 / Convert.ToSingle(t))
coorXf1(YY) = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + coorx1(YY)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf) - Diaf1(YY) / 2
coorYf1(YY) = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - coory1(YY)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t)) - Diaf1(YY) / 2
e.Graphics.FillEllipse(mbrush, CInt(coorXf1(YY)), CInt(coorYf1(YY)), CInt(Diaf1(YY)), CInt(Diaf1(YY)))
e.Graphics.DrawString(CStr(YY + 1), DrawFont6, Brush, CInt(coorXf1(YY) + Diaf1(YY) + 1 / sf), CInt(coorYf1(YY) - 8 / sf))
Next
End If
For q = 1 To NumBarcoor
A(q) = pi * Dia(q - 1) ^ 2 / 4
Next q
Ass1 = 0
For q = 1 To NumBarcoor
Ass1 = Ass1 + A(q)
Next
Pr3 = Math.Round((Ass1 / Area1) * 100, 3)
Pr = Pr3
Dim Str1 As String = Pr3 & "% reinf"
Dim textSize19 As SizeF
textSize19 = G.MeasureString(Str1, DrawFont9)
XQQ11 = CInt((PictureBox2.ClientSize.Width / sf - textSize19.Width) / 2)
e.Graphics.DrawString(Str1, DrawFont9, Brush, XQQ11, CInt(0.92 * PictureBox2.ClientSize.Height / sf))
End If
ElseIf MouseStatus = 0 Then
If dy / dx <= Convert.ToDouble(PictureBox2.ClientSize.Height / PictureBox2.ClientSize.Width) Then
For vv = 0 To Numcoor - 1
Xcoor11(vv) = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + ((Math.Abs(Xmin) + Xcoor(vv)) / Convert.ToDouble(b)) * 0.85 * PictureBox2.ClientSize.Width)
Ycoor11(vv) = CInt((PictureBox2.ClientSize.Height * 0.44) / sf - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - Ycoor(vv)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Next
X3a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b) - 0.085 * (PictureBox2.ClientSize.Width / sf))
X4a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b) + 0.085 * (PictureBox2.ClientSize.Width / sf))
Y3a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Y4a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax + 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
Y5a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b)))
X5a = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + Math.Abs(Xmin) * 0.85 * (PictureBox2.ClientSize.Width / sf) / Convert.ToDouble(b))
Else
For vv = 0 To Numcoor - 1
Xcoor11(vv) = CInt(0.5 * (PictureBox2.ClientSize.Width / sf) + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + Xcoor(vv)) / Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf))
Ycoor11(vv) = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - Ycoor(vv)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
Next
X3a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) - 0.1 * Convert.ToDouble(b)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf)
X4a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + 0.1 * Convert.ToDouble(b)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf)
Y3a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
Y4a = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax + 0.1 * Convert.ToDouble(t)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t))
X5a = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin)) / Convert.ToDouble(t)) * (0.85 * PictureBox2.ClientSize.Height / sf))
Y5a = CInt((PictureBox2.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax) * 0.85 * (PictureBox2.Height / sf) / Convert.ToDouble(t))
End If
Dim points11(Numcoor - 1) As Point
For vv = 0 To points11.Length - 1
points11(vv).X = CInt(Xcoor11(vv))
points11(vv).Y = CInt(Ycoor11(vv))
Next
'e.Graphics.FillPolygon(mbrush1, points1)
e.Graphics.DrawPolygon(mpen3, points11)
e.Graphics.DrawLine(mpen, X3a, Y5a, X4a, Y5a)
e.Graphics.DrawLine(mpen, X5a, Y3a, X5a, Y4a)
Dim DrawFont99 As New Font("Verdana", CInt(10 / sf), FontStyle.Regular)
Dim DrawFont66 As New Font("Verdana", CInt(6 / sf), FontStyle.Regular)
e.Graphics.DrawString(Str3, DrawFont99, Brush2, CInt(X4a + 5 / sf), CInt(Y5a - 8 / sf))
e.Graphics.DrawString(Str4, DrawFont99, Brush2, CInt(X5a - 6 / sf), CInt(Y3a - 18 / sf))
Dim Str66 As String = CInt(b) & " x " & CInt(t) & " mm"
Dim Brush66 As New SolidBrush(Color.Black)
Dim textSize726 As SizeF
textSize726 = G.MeasureString(Str66, DrawFont99)
XQQ17 = CInt((PictureBox2.ClientSize.Width / sf - CInt(textSize726.Width)) / 2)
e.Graphics.DrawString(Str66, DrawFont99, Brush, XQQ17, CInt(0.87 * PictureBox2.ClientSize.Height / sf))
If NumBarcoor >= 1 Then
If dy / dx <= Convert.ToDouble(PictureBox2.ClientSize.Height / PictureBox2.ClientSize.Width) Then
For YY = 0 To NumBarcoor - 1
Diaf1(YY) = Convert.ToInt32(Dia(YY) * (PictureBox2.ClientSize.Width / sf) * 0.85 / Convert.ToSingle(b))
coorXf1(YY) = CInt((PictureBox2.ClientSize.Width / sf) * 0.075 + ((Math.Abs(Xmin) + coorx1(YY)) / Convert.ToDouble(b)) * 0.85 * (PictureBox2.ClientSize.Width / sf)) - Diaf1(YY) / 2
coorYf1(YY) = CInt((PictureBox2.ClientSize.Height * 0.44) / sf - Convert.ToDouble(t) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (2 * Convert.ToDouble(b)) + (Ymax - coory1(YY)) * 0.85 * (PictureBox2.ClientSize.Width / sf) / (Convert.ToDouble(b))) - Diaf1(YY) / 2
e.Graphics.FillEllipse(mbrush, CInt(coorXf1(YY)), CInt(coorYf1(YY)), CInt(Diaf1(YY)), CInt(Diaf1(YY)))
e.Graphics.DrawString(CStr(YY + 1), DrawFont66, Brush, CInt(coorXf1(YY) + Diaf1(YY) + 1 / sf), CInt(coorYf1(YY) - 8 / sf))
Next
Else
For YY = 0 To NumBarcoor - 1
Diaf1(YY) = Convert.ToInt32(Dia(YY) * (PictureBox2.ClientSize.Height / sf) * 0.85 / Convert.ToSingle(t))
coorXf1(YY) = CInt(0.5 * PictureBox2.ClientSize.Width / sf + ((-Convert.ToDouble(b) / 2 + Math.Abs(Xmin) + coorx1(YY)) / Convert.ToDouble(t)) * 0.85 * PictureBox2.ClientSize.Height / sf) - Diaf1(YY) / 2
coorYf1(YY) = CInt((PictureBox2.ClientSize.Height / sf) * 0.44 + (-Convert.ToDouble(t) / 2 + Ymax - coory1(YY)) * 0.85 * (PictureBox2.ClientSize.Height / sf) / Convert.ToDouble(t)) - Diaf1(YY) / 2
e.Graphics.FillEllipse(mbrush, CInt(coorXf1(YY)), CInt(coorYf1(YY)), CInt(Diaf1(YY)), CInt(Diaf1(YY)))
e.Graphics.DrawString(CStr(YY + 1), DrawFont66, Brush, CInt(coorXf1(YY) + Diaf1(YY) + 1 / sf), CInt(coorYf1(YY) - 8 / sf))
Next
End If
For q = 1 To NumBarcoor
A(q) = pi * Dia(q - 1) ^ 2 / 4
Next q
Ass1 = 0
For q = 1 To NumBarcoor
Ass1 = Ass1 + A(q)
Next
Pr3 = Math.Round((Ass1 / Area1) * 100, 3)
Pr = Pr3
Dim Str1 As String = Pr3 & "% reinf"
Dim textSize19 As SizeF
textSize19 = G.MeasureString(Str1, DrawFont99)
XQQ11 = CInt((PictureBox2.ClientSize.Width / sf - textSize19.Width) / 2)
e.Graphics.DrawString(Str1, DrawFont99, Brush, XQQ11, CInt(0.92 * PictureBox2.ClientSize.Height / sf))
End If
End If
If MouseStatus = 1 Then
If ZoomCb.Checked Then
'convert for positive yaxis and rectf
Dim rect As New Rectangle(CInt(ZoomMouseDownPt.X), CInt(ZoomMouseDownPt.Y), CInt(ZoomMouseMovePt.X) - CInt(ZoomMouseDownPt.X), CInt(ZoomMouseDownPt.Y) - CInt(ZoomMouseMovePt.Y))
e.Graphics.DrawRectangle(Pens.Red, rect)
Else
'draw other tracers if active
End If
End If
End Sub
Private Sub Form32Irregular_byCoordinates_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form32Irregular_byCoordinates_Resize(0, Nothing)
PictureBox2.Focus()
MouseStatus = 3
End Sub
Private Sub Form32Irregular_byCoordinates_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Yoffset = Convert.ToSingle(ScaleWidth * (PictureBox2.ClientSize.Height / PictureBox2.ClientSize.Width))
PictureBox2.Invalidate()
End Sub
Private Sub Picturebox2_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseDown
Dim pt As PointF = GetScalePtFromClientPt(e.Location)
If ZoomCb.Checked Then
'keep zoom independant of drawing tools to allow nesting of zoom with tools.
ZoomMouseDownPt = pt
ZoomMouseMovePt = ZoomMouseDownPt
End If
MouseStatus = 1
MouseMovePt = pt
PictureBox2.Invalidate()
PictureBox2.Focus()
End Sub
Private Sub Picturebox2_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseMove
Dim pt As PointF = GetScalePtFromClientPt(e.Location)
If MouseStatus = 1 Then
If ZoomCb.Checked Then
ZoomMouseMovePt = pt
PictureBox2.Invalidate()
End If
End If
End Sub
Private Sub Picturebox2_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseUp
Dim pt As PointF = GetScalePtFromClientPt(e.Location)
If ZoomCb.Checked Then
ZoomMouseMovePt = pt
ZoomCb.Checked = False
'set scale based on zoom rect
Select Case MouseStatus
Case 1
ZoomMouseMovePt = pt
ZoomCb.Checked = False
'set scale based on zoom rect width
dx = CInt(ZoomMouseMovePt.X - ZoomMouseDownPt.X)
dy = CInt(ZoomMouseMovePt.Y - ZoomMouseDownPt.Y)
ScaleWidth = dx
'set origin
Corner.X = CInt(ZoomMouseDownPt.X)
Corner.Y = CInt(ZoomMouseDownPt.Y)
'update yoffset etc
Form32Irregular_byCoordinates_Resize(0, Nothing)
End Select
End If
MouseStatus = 0
PictureBox2.Invalidate()
End Sub
Private Function GetScalePtFromClientPt(pt As PointF) As PointF
'convert screen pixels to scale drawing coords
Dim sf As Double = PictureBox2.ClientSize.Width / (ScaleWidth * ScaleRatio)
Return New PointF(CSng(Corner.X + (pt.X / sf)), CSng(Corner.Y + (pt.Y / sf)))
End Function
Private Sub Picturebox2_MouseWheel(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseWheel
ScaleRatio += CSng(Math.Sign(e.Delta) * 0.1)
If ScaleRatio < 0.000001 Then ScaleRatio = 0.000001
If ScaleRatio > 10000 Then ScaleRatio = 10000
PictureBox2.Invalidate()
End Sub
Private Sub Picturebox2_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox2.MouseEnter
PictureBox2.Focus()
End Sub







Hany Metry

Continue reading...
 
Back
Top