Reputation: 1146
Doing some work on a Drawing Canvas and I'm wanting to implement a Redo and Undo button. I tried with a stack and an array, placing the last point drawn into the array then calling it back or deleting it but I cant seem to get it to work. Any documentation on this? Thanks in advance.
To comment bellow here is what I'm talking about
this.ContentPanelCanvas.Children.Add(line);
oldPoint = currentPoint;
Point[] redoTest = { oldPoint };
the above is what i tried to store the Oldpoint..
Later to recall that point and undo it I tried this:
private void Redo_Click(object sender, EventArgs e)
{
ContentPanelCanvas.Children.Remove(redoTest);
}
That gives me an error though. Whats wrong with it?
Upvotes: 0
Views: 1000
Reputation: 3294
You may find the following sample meets your needs, it includes a method called undoLast, which will earse the last line drawn :-
http://www.windowsphonegeek.com/tips/WP7-DrawingBoard-sample-Drawing--Ink--made-easy
Add the following line to a new undo button click event handler :-
myBoard.undoLast(SimzzDev.DrawingBoard.PenMode.pen);
Upvotes: 1