Windows Develop Bookmark and Share   
 index > Windows Forms Designer > UndoEngine in standalone Designer
 

UndoEngine in standalone Designer

I derived from UndoEngine and implemented a AddUndoUnit Method that pushes a UndoUnit onto a stack.
My IServiceProvider is a DesignSurface with an CodeDomSerializationService (Serilazation seems to work and my stack gets bigger for any change I make on my UI).
I expected the UndoUnit.Undo() Method to desirialize the latest SerializationStore that gets popped of the stack, but it doesnt seem to work.
How is the UndoEngine meant to be implemented ?
weichsel  Tuesday, September 06, 2005 1:46 PM

I think you need to pass the IDesignerHost as the service provider, not DesignSurface. This is because the UndoUnits query service for the IDesignerHost.

Raghavendra
http://blogs.msdn.com/rprabhu

Raghavendra Prabhu MSFT  Thursday, September 08, 2005 7:21 PM
Thanks for your Reply!
I am now passing IDesignerHost and the Undo seems to do anything atleast. If I add an Control to the surface and try to Undo() it, the control remains but the selection gets set to the control that got added before. That tells me that the SelectionService got notified that an undo has taken place but the rest stays the same :(.
Any ideas?
weichsel  Monday, September 12, 2005 7:39 AM
I am currently working on the Undo() problem again.
I have the following problems:
If i try to undo the creation of a Control, the host throws an "
DesignerHostCantDestroyInheritedComponent" Exception.
If i try to undo a change ("resize","move",...) the UndoEngine reports a stack overflow. (Without any details)
I am using Visual C# Express August CTP.
Can someone help me?
weichsel  Friday, October 07, 2005 9:50 AM

Seems that UndoEngine is a way to collect changes into form design and not a service implementation (so is the name). What is not documented is that even if you try to use it seems that it can’t do the job without the presence of certain services. I identified those services:

·         INameCreationService

·         MenuCommandService

·         ComponentSerializationService

·         IDesignerSerializationService

·         UndoEngine

 

The UndoEngine can be seen in action for a short period of time in example at: http://www.geocities.com/balcanuc/TestUndoEngine.zip

 

If someone can host it to a alternative permanent location please do.

 

Also I would like to hear some feedback if I did something wrong in the sample.

On the other side I think weichsel owns me a beer. ;)

balcanuc  Saturday, December 24, 2005 12:23 AM

Hi

This is a really cool app.

Just one question how do I implement a DragEnter event onto the designform

Thanks

Kevin Dherman  Monday, January 16, 2006 9:28 AM

Why you need to handle DragEnter onto designform? You want to implement a Toolbox like drag drop of some components?

For this kind of thing you should implement IToolboxService and a GUI component to handle drag-drop. What you should put as DataObject for drag-drop operation is a ToolboxItem.

If so, there are some examples already available on the web. (examples I know are for .NET 1.1)

balcanuc  Monday, January 16, 2006 7:28 PM

Yes, I am attempting somthing similer.

I build up a treeview from an XSD document, Each tree node is a form item.

When you drag the tree node onto the form depending on the treenode a textbox or a checkbox etc...is added to the form.

Something similar to what InfoPath does.

Do think think I should still try implement IToolboxService.or should I get a DragEnter event on the design form.

Thanks in advance

Kevin Dherman

Kevin Dherman  Tuesday, January 17, 2006 4:56 AM

Start with reading:

http://geekswithblogs.net/mtreadwell/archive/2005/01/06/19342.aspx

and articles and samples refered in this article

  • Dawson- DivElements, Hosting Windows Forms Designers (June 2003)
  • MSKB - Microsoft Knowledgebase, INFO: Code Sample That Demonstrates How to Create a Custom Form Designer by Using Visual C# .NET (August 2004)
  • MSDN - MSDN Magazine, .NET Internals: Tailor Your Application by Building a Custom Forms Designer with .NET (December 2004)
  • Cristi

    balcanuc  Tuesday, January 17, 2006 6:45 PM

    Somebody knows how implement the StandardCommands.Undo command?. Using with transactions and not works....

    Regards

    Tabas  Wednesday, January 18, 2006 12:00 AM

    Did you figure this out, Tabas? I'm working on this topic now too.

    Alan

    LearnToRock  Saturday, February 18, 2006 4:23 PM

    Tabas, did you find the solution. I'm eager to know...

    Alan

    Tabas wrote:

    Somebody knows how implement the StandardCommands.Undo command?. Using with transactions and not works....

    Regards

    LearnToRock  Monday, February 27, 2006 2:09 AM

    @balcanuc

    well mate I guess i also owe u a beer at least Wink

    thx very much i didn't really know where to start with the undo/redo functionallity ...

    great example.

    Vladimir.Ilic  Thursday, November 27, 2008 4:32 PM
    What example are you referring to? I've been struggling with solving the UndoEngine riddle for days.

    Thanks in advance

    Brian
    Brian Butler  Tuesday, December 16, 2008 3:13 AM
    Hi Brian,

    sorryI didn't respond earlier, must've missed the notification,and Iguessyou probably solved it by now...

    But anyway, if someone else is wondering, I was talking about the example provided by balcanuc earlier in this post...
    I used the UndoEngineImplementation in my custom form designer hosting application.
    I added the service to DesignSurface (or rather to a class that inheritsfrom DesignSurface to add some functionallity),
    andhad all of the bellow mentionedservices already implemented and added to the same service container.

    And it worked.


    Seems that UndoEngine is a way to collect changes into form design and not a service implementation (so is the name). What is not documented is that even if you try to use it seems that it can’t do the job without the presence of certain services. I identified those services:

    · INameCreationService

    · MenuCommandService

    · ComponentSerializationService

    · IDesignerSerializationService

    · UndoEngine

    The UndoEngine can be seen in action for a short period of time in example at: http://www.geocities.com/balcanuc/TestUndoEngine.zip

    If someone can host it to a alternative permanent location please do.

    Also I would like to hear some feedback if I did something wrong in the sample.

    On the other side I think weichsel owns me a beer. ;)


    Vladimir.Ilic  Thursday, June 04, 2009 12:18 PM

    You can use google to search for other answers

    Custom Search

    More Threads

    • Develop a tool like Graphical Query Builder
    • PropertyGrid.Site
    • Designer is not getting loaded for main form??
    • Why "PropertyBinding" dosen't work with the "Checked" property of "ToolStripMenuItem"?
    • Bug in components (VB)
    • DataGridViewComboBox Column DataBinding
    • listview mess up
    • Help creating Composite User Control and Custom Designer with Container for WinForm
    • Children of a control incorrectly respond to the mouse popup menu interaction during design time.
    • Propertygrid ExpandableObjectConverter Question???