Application has several panels some or all of which the user may choose to have on his screen. It is very much like Visual Studio in that user may choose their own combination of panels, their layout (docking) etc. He can choose which panel to keep closed. Each open panel has one user control filling it.
When the application restarts, I want to restore the last settings i.e. the panel docking, the controls inside them. very much like Visual Studio
I am wondering :
1. how would the application know which panels were open last time and where they were placed by the user? So, panel x may have been docked to top by one user and while docked bottom by another use and a third user may have closed it completely. In other words, at app start time, I need to know which panels to open and where to dock them. I am hoping the DockManager would provide some help with that. Any samples code available?
2. once I determine the panel that are to be opened, I would then instantiate the control and add it to the panel? Is that the approach you would recommend. I know this is not an Infragistics question per se but I am hoping there is something in the toolset that I may be able to exploit.
Thanks!
- Once the user has closed a docked pane by clicking on the "x", how can I bring it back programmatically? I read somewhere that I have do a Show() on the pane. In my current design, I am dropping controls directly onto the form. How do I determine the pane I need to Show()?
- When the pane is restored programmatically, would it recover the last docking when it was closed?
- Related to the first question, to find out which panes are not visible i.e. ones which are closed using the "x". I am guessing I need to iterate over some collection and check some property. I would like to know what that collection and property is.
Try using the following code:
this.ultraDockManager1.BeginUpdate();
bool paneAddedToGroup = false;
foreach ( DockAreaPane dockArea in this.ultraDockManager1.DockAreas ){ if ( dockArea.DockedLocation != DockedLocation.DockedRight ) continue;
DockableControlPane controlPane = this.ultraDockManager1.ControlPanes.Add( this.userControl3 ); dockArea.Panes.Add( controlPane ); paneAddedToGroup = true; break;}
if ( paneAddedToGroup == false ){ this.ultraDockManager1.DockControls( new Control[ { this.userControl3 }, DockedLocation.DockedRight, ChildPaneStyle.TabGroup );}
this.ultraDockManager1.EndUpdate();
To use a named dock area, you can set the Key property of a dock area. Then when you access the DockAreas collection of the dock manager, you can specify that key instead of an index when trying to get a dock area from the collection.
Thank for the help so far Mike. Your suggestions as well the Docking Demo you suggested helped me get a whole lot further.
- Currently I have this simple code in my play app that generates a new control at runtime and TRIES to dock it as part of a existing tab group of right-docked controls. Instead of that becoming part of the tabgroup, the userControl3 just becomes a new panel docked right but sitting side-by-side to that tab group. How do I make it part of that tab group of right-docked controls?
ultraDockManager1.DockControls(new Control[1] { userControl3 }, Infragistics.Win.UltraWinDock.DockedLocation.DockedRight, Infragistics.Win.UltraWinDock.ChildPaneStyle.TabGroup);
- I see code snippet on the forum where docking is done to a named dockarea i.e. referencing DockArea by its key. It seems like a great way to logically group controls but I do not know how to use it.
vrn said:Mike, From what you are saying it seem the key is to make application know which controls were open when it last closed. That way, if the application instantiate those controls at LoadForm time, the dockmanage would do the needful to put it on the correct pane. Do you agree with conclusion?
Yes, that is correct.
vrn said:Second question, my entire application is developed as a user control. The dock manager is on the user control instead of the form. So what you said about "LoadForm" is applicable if the dockmanager is on the Form. What is event that I should be concerned about when dock manager is on the user control?
Yes, it will work with a user control as well. Also, I wasn't referring to anything called LoadForm, I was talking about the LoadFrom... methods. The dock manager has LoadFromXml and LoadFromBinary methods which load a layout file depending on what format it was saved in.
Mike Dour"]The dock manager would be able to do this if the controls were somewhere on the Form when the LoadFrom... method was called. When you load a layout file, the dock manager will initialize a DockableControlPane with the settings it was saved with.
Mike, From what you are saying it seem the key is to make application know which controls were open when it last closed. That way, if the application instantiate those controls at LoadForm time, the dockmanage would do the needful to put it on the correct pane. Do you agree with conclusion?
Second question, my entire application is developed as a user control. The dock manager is on the user control instead of the form. So what you said about "LoadForm" is applicable if the dockmanager is on the Form. What is event that I should be concerned about when dock manager is on the user control?