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!
vrn said: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?
The UltraDockManager has SaveAs... and LoadFrom... method which allow you to save and load layout files. This will do exactly what you ask in your first question. You would typically want to save the layout file in the FormClosed event and load it if it exists at the end of the constructor or in the Load event of the Form. The Docking Demo sample uses the layout files, but in a slightly different way. It allows you to save and load layout files from a menu. It also saves the layout when the program loads and allows the user to reset the layout by loading in the originally saved layout.
vrn said: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.
I haven't tried using it with loading layout files yet, but there is an InitializePane event which you could use to only load a control once the pane is first shown.
Mike Dour"]The UltraDockManager has SaveAs... and LoadFrom... method which allow you to save and load layout files. This will do exactly what you ask in your first question. You would typically want to save the layout file in the FormClosed event and load it if it exists at the end of the constructor or in the Load event of the Form. The Docking Demo sample uses the layout files, but in a slightly different way. It allows you to save and load layout files from a menu. It also saves the layout when the program loads and allows the user to reset the layout by loading in the originally saved layout.
Thanks Mike! When you say "Docking Demo", is that on the Infragistics sample code installed with the toolkit or something on the website? If latter, can you provide link?
Mike Dour"]I haven't tried using it with loading layout files yet, but there is an InitializePane event which you could use to only load a control once the pane is first shown.
The requirement involves having to show a new panel for each user action and fill it with a user control. So, for say 15 user actions, I will need 15 different user controls. I have two choices
1. Design 15 different panels and fill the control at InitializePanel time.
2. Dynamically generate the panels and then fill it with the controls
The advantage to the second approach is its scalability. If the application later needs to support 5 new user controls , none of the layout code needs to change.
Do you think I can achieve #2 and still save the layout? So, one user may open User Control 1(UC1), UC10 and UC11 in three dynamically generated panels. While in another scenario it was UC2, UC4 in two dynamically generated panels. Since these controls are coming up in dynamically generated panel, what would the DockManager save for the two users? Would it know how many panels to be generated at initialization, where to dock those and which controls are to be placed on those panels?
vrn said:Thanks Mike! When you say "Docking Demo", is that on the Infragistics sample code installed with the toolkit or something on the website? If latter, can you provide link?
That is one of the installed samples. I'm not sure where it is located, but it might be located in the toolbars section.
vrn said:Do you think I can achieve #2 and still save the layout? So, one user may open User Control 1(UC1), UC10 and UC11 in three dynamically generated panels. While in another scenario it was UC2, UC4 in two dynamically generated panels. Since these controls are coming up in dynamically generated panel, what would the DockManager save for the two users? Would it know how many panels to be generated at initialization, where to dock those and which controls are to be placed on those panels?
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. Then it will look at the controls on the form and try to find a control with the same Name property value as the control that was docked in the pane. If one is not found, the pane is removed. You will need to save another file with the layout file. This file will indicate to you which controls should be initialized and added to the form before loading the dock manager's layout file.
In this post, you say, "You will need to save another file with the layout file. This file will indicate to you which controls should be initialized and added to the form before loading the dock manager's layout file."
What controls need to be saved? I've tried this, saving the coltrol names, and re-initializing those same inds of controls with their previous names ('System.Windows.Forms.Panel' controls that were used) when the dock manager's 'SaveAs...' was called.
Doesn't seem to work, though.
Is there an example of how this should work?
Pat
You should save the state of any controls that need to be loaded into dock panes. Then, before you load the layout for the dock manager, you should create the controls (if they don't already exist), give them the same Name they had before, and reinitialize them with any state that you have saved. You must also add them somewhere in the control hierarchy of the Form (or UserControl) in which the UltraDockManager resides. I like to create a temporary Panel which is hidden for this purpose so you don't see any flicker on screen. I have attached a relatively simple sample which does this.