Hi
I have a problem with my code
after I click undo I can't draw on the image and I don't know why
this is my code
Imports
System.Drawing.GraphicsImports
System.Drawing.BitmapImports
System.DrawingPublic
Class FrmChild Dim Xstart As Short Dim Ystart As Short Dim Xend As Short Dim Yend As Short Dim BoolErasing As Boolean = False Dim BoolDrawing As Boolean = False Dim Image As New Bitmap(1500, 1200) Public GraphFun As Graphics = Graphics.FromImage(Image) Dim ErasingPen As New Pen(Drawing.Color.White, 3) Dim DrawingPen As New Pen(Drawing.Color.Black, 3) Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDownundo.Push(Image.Clone())
redo.Clear()
btnredo.Enabled =
False If Not btnundo.Enabled Then btnundo.Enabled = TrueXstart = e.X
Ystart = e.Y
If btnEraser ThenBoolErasing =
True ElseIf btnPencil ThenBoolDrawing =
True End If End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If BoolErasing ThenGraphFun.DrawLine(ErasingPen, Xstart, Ystart, e.X, e.Y)
ElseIf BoolDrawing ThenGraphFun.DrawLine(DrawingPen, Xstart, Ystart, e.X, e.Y)
End IfXstart = e.X
Ystart = e.Y
PictureBox1.Image = Image
End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUpXend = e.X
Yend = e.Y
BoolErasing =
FalseBoolDrawing =
FalsePictureBox1.Image = Image
End SubPrivate Sub Btnundo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnundo.Click If Not btnredo.Enabled Then btnredo.Enabled = True
redo.Push(Image.Clone())
Image = undo.Pop()
PictureBox1.Image = Image
If undo.Count = 0 Thenbtnundo.Enabled =
False End If End SubPrivate Sub FrmChild_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnundo.Enabled =
Falsebtnredo.Enabled =
False End Sub Private Sub btnredo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnredo.Click If Not btnundo.Enabled Then btnundo.Enabled = Trueundo.Push(Image.Clone())
Image = redo.Pop()
PictureBox1.Image = Image
If redo.Count = 0 Then btnredo.Enabled = False End SubEnd
Class
pleas help me
Replies
Know the answer? Post it — somebody with the same question will find it here.