eyemag
asked on
undo
i give my users the ability to stamp a picture on a main stage.
i want them to be able to undo the last 5 possible stamps.
each stamp is a paintpicture event:
e.g. picture1.paintpicture image1.picture, x, y
is there some type of memory logic that i use to store each of the five last events in memory.
thanks in advance.
i want them to be able to undo the last 5 possible stamps.
each stamp is a paintpicture event:
e.g. picture1.paintpicture image1.picture, x, y
is there some type of memory logic that i use to store each of the five last events in memory.
thanks in advance.
"Command" design patterns provide a convenient way to store and execute an Undo function. Each command object can remember what it just did and restore that state when
requested to do so.
You must keep a single sequential list of the commands that have been executed, and each command has to keep a list of its executions... etc. piece of cake ;-)
requested to do so.
You must keep a single sequential list of the commands that have been executed, and each command has to keep a list of its executions... etc. piece of cake ;-)
Hearing...
ASKER
azrasound-
i tried implementing with a picturebox and no luck. could you give me a full example.
thanks, if i need to increase the points let me know
i tried implementing with a picturebox and no luck. could you give me a full example.
thanks, if i need to increase the points let me know
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
? = '
Sorry there were a few typos where width and heigh got mixed up but if you need any further help with the concept I would be happy to help.
Sorry there were a few typos where width and heigh got mixed up but if you need any further help with the concept I would be happy to help.
listening...
I must admit I was wondering which way this would go, and my feelings go with [inthedark], because the structures that you tend to deal with in VB are often not conducive to 'just removing the last opration'
I have done something similar - and [inthedark]'s method seems to just 'work more often'... however the original 'stack' approach is the textbook answer, it requires that you maintain more info off the stack to recover the actual 'state of play' - as opposed to simply repeating the process from the most recent 'convenient' starting point.... of course you should also consider keeping more than one recent re-entry point for multiple undo operations.... altogether not an easy answer !!
I have done something similar - and [inthedark]'s method seems to just 'work more often'... however the original 'stack' approach is the textbook answer, it requires that you maintain more info off the stack to recover the actual 'state of play' - as opposed to simply repeating the process from the most recent 'convenient' starting point.... of course you should also consider keeping more than one recent re-entry point for multiple undo operations.... altogether not an easy answer !!
But Ark codes should works (i mean, stdpicture approach)!
Moderator, my recommended disposition is:
Accept inthedark's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
Accept inthedark's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
In a last case. a split between inthedark and ark should be nice.
Cheers
Cheers
AzraSound = Ark
Sorry, i did it again, i meant Azra and inthedark.
Thanks for the input. Modified recommendation:
Split points between inthedark and AzraSound
DanRollins -- EE database cleanup volunteer
Split points between inthedark and AzraSound
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.
Netminder
CS Moderator
AzraSound: points for you at https://www.experts-exchange.com/questions/20341070/For-AzraSound-re-various.html
Netminder
CS Moderator
AzraSound: points for you at https://www.experts-exchange.com/questions/20341070/For-AzraSound-re-various.html
Private m_picStack(1 To 5) As StdPicture
Private m_intStackPointer As Integer
Sub Push()
Dim i As Integer
If m_intStackPointer = 5 Then
'move all items down a position
For i = 2 To 5
m_picStack(i - 1) = m_picStack(i)
Next
m_picStack(5) = Image1.Picture
Else
m_intStackPointer = m_intStackPointer + 1
m_picStack(m_intStackPoint
End If
End Sub
Function Pop() As StdPicture
Pop = m_picStack(m_intStackPoint
m_intStackPointer = m_intStackPointer - 1
End Function