Here is how I did a undo:
Dim UndoStack As New Stack(Of Bitmap)() 'holds the backup images
'==========================================================================
' Saves the picture passed
'==========================================================================
Private Sub PushUndo(ByVal b As Bitmap)
UndoStack.Push(b)
btnUnDo.Visible = True
End Sub
'==========================================================================
' Returns the last picture saved
'==========================================================================
Private Function PopUndo() As Bitmap
If UndoStack.Count = 0 Then
Return Nothing
btnUnDo.Visible = False
Exit Function
End If
If UndoStack.Count = 1 Then btnUnDo.Visible = False
Return UndoStack.Pop
End Function To save a bitmap:
'save the current picture for undo
PushUndo(Display.Image.Clone) To undo:
'==========================================================================
' pops the last bitmat off the stack and places it in the display
'==========================================================================
Private Sub btnUnDo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnDo.Click
Dim bmp As Bitmap
bmp = PopUndo()
If bmp IsNot Nothing Then
Display.Image = bmp
End If
End Sub The second part I am going to have to find. I'll get back at you.
waynespangler
Posting Pro in Training
461 posts since Dec 2002
Reputation Points: 84
Solved Threads: 58