dear all
i have a picture box then draw a rectangle in it and make it permanent using a user form
then i add a circle to this rectangle by other user form and make it permanent also
the problem is when i try to modify the location of the circle it draw a new one and do not remove old one
and if i draw a new rectangle the all circles disappears
(i want to modify the circles location and remove old one, i want to modify the rectangle dimensions without remove the existing circles)
my code as follow:
Module Module2
Public canvas As Bitmap
Public mygraphics As Graphics
Public Sub draw_rec(ByVal points(,) As Double)
Dim canavas_x As Integer = frm_main.pb_preview.Width
Dim canavas_y As Integer = frm_main.pb_preview.Height / 2
canvas = New Bitmap(canavas_x, canavas_y)
mygraphics = Graphics.FromImage(canvas)
Dim myPen As System.Drawing.Pen
myPen = New System.Drawing.Pen(System.Drawing.Color.Black)
myPen.Width = 0.0
mygraphics.Clear(Color.White)
mygraphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For k = 0 To UBound(points, 1) - 1
mygraphics.DrawLine(myPen, Convert.ToSingle(points(k, 0)), Convert.ToSingle(points(k, 1)), Convert.ToSingle(points(k + 1, 0)), Convert.ToSingle(points(k + 1, 1)))
Next
frm_main.pb_preview.Image = canvas
End Sub
Public Sub draw_cir()
Dim myPen As System.Drawing.Pen
myPen = New System.Drawing.Pen(System.Drawing.Color.Black)
myPen.Width = 0.0
Dim mygraphics1 = Graphics.FromImage(canvas)
mygraphics1.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For k = 0 To UBound(cicles, 1) - 1
x = Convert.ToSingle(cicles(k, 1) - 0.5 * cicles(k, 3))
y = Convert.ToSingle(cicles(k, 2) - 0.5 * cicles(k, 3))
mygraphics1.DrawEllipse(myPen, x, y, Convert.ToSingle(cicles(k, 3)), Convert.ToSingle(cicles(k, 3)))
Next
frm_main.pb_preview.Image = canvas
End Sub
End Module