Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Undo Redo Logic with Delete Button Problem Command Pattern ?
 

Undo Redo Logic with Delete Button Problem Command Pattern ?

Hi msdn .,

I am implementing custom Undo/ Redo for my Control editor type application Which looks small type Visual Basic Design Editor .

While creating a control i am saving info in arraylistas " C " with control name.WHile postion of control or resizes i am storing that information as a property action "B " with control name .


Now if Ctrl +Z based on the information present in data in Arraylist i.e., the min item in list and letter C or B
C - As Creation of control/s
B - As Bounds of control /s Changes

For these ,there is no problem i did the UNDO / REDO for my application . But the problem comes with " Delete Button "
if i give letter "D" in arraylist

D - Delete the control/s

Undo AL arraylist

REDo AL arraylist

Here goes the in the order

C

D

Ctrl Z means if D then i am creating again if C comes i am deleting the control again . NO PROBLEM

then both rows moved to AL REDO

if again ctrl Y D Comes first i am creating the cotnrol then again CTRL Y then Deleting the control . "D"

if i press again i created the control . then control is moved Ctrl infor added in Undo list . "P"

then if i press delete 1 more record added into Undo List . "D"

Here comes the duplication of Control Information . So i am creating Multiple controls with same with this logic .

If i dont maintain the Delete KEY record the problem is ::

i created 3 controls 1 2 3 then Ctrl A , Removed the controls if i CTRL Z i dont know To createall the 3 controls back ie..,Record again if Multiple Controls Exist .

I create only for the last control which is not correct

So is there any way to track the DELETE Button Control/s Infor and do exactly like MS is doing

Eagerly Waiting for your response.


VS
SilverPlate  Friday, May 22, 2009 11:46 AM
Thanks For the Reply .

i got the solution .

Regards
VS
  • Marked As Answer bySilverPlate Thursday, May 28, 2009 3:49 PM
  •  
SilverPlate  Thursday, May 28, 2009 3:24 PM
Hi SilverPlate,

Based on my thought, you can use a Stack to record the deletion. Each item in the stack is List<Controls>. When there's an deletion, I will add all the deleted controls in the list. At last, push this list into the stack.

When we press ctrl+z to restore the deleted controls, we only need to popup the stack, and add the controls in the top list.

Let me know if you have any different views.


Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Wednesday, May 27, 2009 10:15 AM
Thanks For the Reply .

i got the solution .

Regards
VS
  • Marked As Answer bySilverPlate Thursday, May 28, 2009 3:49 PM
  •  
SilverPlate  Thursday, May 28, 2009 3:24 PM

You can use google to search for other answers

Custom Search

More Threads

• Disable value tooltip in Properties?
• ZOrder
• Do we still need to implement designerhost with the arrival of designsurface
• Expression field in .XSD view
• Child is not a Child Control of this Parent
• problem in CheckBOx checkedchanged event..
• how to display images in DataGridView?
• Custom textbox designer
• datagridview help
• problem with AddRange()