Hello, Im trying to create a undo function for a image editor but I having troubles. What Im trying to do is push each brush stroke through a stack then use stackName.Pop() to undo but I can't seem to add the brush stroke to the stack. Here is my code:
Stack undoStack = new Stack();
bool mouseDown = false;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown == true)
{
int width = 50;
int height = 50 + 1;
int top = e.Location.X - width / 2;
int left = e.Location.Y - height / 2;
Color theColor = Color.Navy;
SolidBrush brush = new SolidBrush(theColor);
System.Drawing.Graphics graphObj = Graphics.FromHwnd(pictureBox1.Handle);
graphObj.FillEllipse(brush, new Rectangle(top, left, width, height));
undoStack.Push(graphObj);//What Do I push here?
}
}
But I don't know what to push into the stack. Please Help thank you!