Serializing Progamatically Created ToolWindows

Docking/MDI for WPF Forum

Posted 10 years ago by Greg Larson
Version: 9.1.0500
Avatar
Hi,
I added buttons to the ProgrammaticCreation sample to load and save serialized layouts to a file with DockSiteLayoutSerializer. Saving the default windows and loading them on startup works fine. But when I create a new ToolWindow and save the layout, it is not created when I restart. What am I missing?

I need to be able to create ToolWindows at runtime, save the layout, and have the configuration recreated. Thanks.

Greg

[Modified at 06/05/2009 05:37 PM]

Comments (10)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Greg,

This is something that we have on our TODO list to add better support for. Right now it will ignore tool windows that don't exist. What you could do is perhaps use XPath to scan the layout data for the tool window tags before you load the layout. Then ensure each a tool window with each Name exists. Finally load the layout. That would work around the problem until we add more functionality to handle this scenario.


Actipro Software Support

Posted 10 years ago by Greg Larson
Avatar
Ok, thanks. I was thinking along those lines...using LinqToXML to get the window data and create them myself.
Posted 9 years ago by Roger Rong
Avatar
My situation is a little bit difference:

Step 1: Create a set of tool windows from the coding, some of them are in the layout files but some new windows are not in it.

Step 2: Run the DockSiteLayoutSerializer.LoadFromFile(layoutFileFullPath, myDockSite) to load layout.

Then it come with a problem:

The newly created tool windows are closed because they do not exit in the current layout file.

Anyway simple workaround for this issue other than manipulating the layout XML file?


Roger
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Roger,

Probably not at this time. After we get our first Silverlight controls we plan on starting another round of Docking updates and hope to work on serialization more.

How would you like things to work better for your scenario? If you have some ideas perhaps we can write them down for when we do our enhancements.


Actipro Software Support

Posted 9 years ago by Roger Rong
Avatar
We are expecting that applying the layout does not close the newly created windows and just leave it in the current docking state without doing anything on it.

On the other hand, ignoring tool windows that don't exist is a very good behiour for our system - we love it.

As the old Actipro Windows Form Dock ocntrols that we were using a couple years ago, we had to deliberately avoid creating a tool window before applying the manully modified XML layout file. We would like to save from doing that for the WPF Dock. If possible, can I know the roughly timeframe of a new version with this improvment so that I could plan the date of including the restoring layout feature for our application pack.

Thanks,

Roger

[Modified at 05/04/2010 04:24 PM]

[Modified at 05/04/2010 04:25 PM]
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Roger,

This is a very tricky scenario and I'm not sure that we can do exactly what you are requesting. Consider when there is an existing complex tool window layout in place and half those tool windows are being reloaded from deserialization of the layout file, while the other half aren't indicated in the layout file. In that scenario the layout file could have a completely different complex layout and there would be no good way to merge the two layouts together.

One thing would be to get a list of all the tool windows that are open but don't exist in the layout file, then load the layout file, then reopen the tool windows in the list you made. The downside with this is that it will be difficult to get them in the same locations as before unless you store some layout data about them before loading the new layout.

Or the alternative is to modify the XML as you have been doing.

We're open to any other suggestions you have.


Actipro Software Support

Posted 9 years ago by Roger Rong
Avatar
>> One thing would be to get a list of all the tool windows that are open but don't
>> exist in the layout file, then load the layout file, then reopen the tool windows in
>> the list you made.

Another solution we could consider is to delay creating tool windows that do not exit in the layout file, and create them after the layout being loaded and set to the docksite. To achieve that without dealing with the XML layout file directly, it would help if a mechanism could be provided out of the box to retrieve all the tool window keys in the exiting layout file. We used to search the XML file manually for those info with the old Windows Form dock.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Roger,

The layout XML is probably easier to search in the WPF version. All the tool windows in the layout are listed right in the DockSiteLayout/ToolWindows/ToolWindow tags so they are very easy to enumerate.

Alternatively you could set an ObjectDeserializedHandler on the serializer object. That delegate gets called any time something is deserialized. So you could watch for tool windows using that mechanism if you wouldn't want to do the simple XPath on the XML.


Actipro Software Support

Posted 9 years ago by Roger Rong
Avatar
Thanks for updating. True, in the WPF version, getting all the tool windows keys is simpler than doing that with the old Window Forms dock. We would go to this soltuion - retrieve all tool windows keys from the XML layout before determining which tool windows are allowed to create immediately.

And hopefully the XML layout will stick with the format of 'DockSiteLayout/ToolWindows/ToolWindow' in the future release.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Greg,

Just fyi, we added support for lazy loading of layout data or automatically creating ToolWindows that are in the layout data, but not currently registered with the DockSite. You can see this feature in action in the current WPF Studio version available.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.