I have a situation. In a separate menu thats in a tree, I can control the elements of a dynamic toolbar. Basically for each item chosen in the tree, the dynamic toolbar changes its tools to match the options required. I have a static toolbar that is apart of that same toolbarsManager. Basically the layout is as follow. UltraToolBarsManager consisting of two toolbars........the static one on top and dynamic one below. Here is the issue...I have a problem with the speed of the navigation because I need to clear the tools in the ultraToolBarsManager and clear the tools in the dynamic toolbar every time another option in the tree is chosen. Every time I clear the ultraToolBarsManager, I have to re-add the tools needed for the static toolbar all over again along with the "new" tools for the dynamic toolbar. The way the toolbarmanager works, when i add for eg a PopupMenuTool, I need to create a string key, give that PopupMenuTool instance that string key, add the instance to the ultraToolBarsManager.Tools and add the string key to the ultraToolBarsManager.Toolbars["DynamicToolbar"].Tools . One option is to keep an arrayList of all the keys i add to the ultraToolBarsManager and then iterate through it and delete the keys which match when its time for the toolbar items to change. Another process which could slow down the navigation. Any suggestions?
Well i created this method and its moving faster. I first added every tool added to the toolbar to a global ArrayList.
private static void ClearToolBar()
{
for (int x = 0; x < dynamicTools.Count; x++)
UltraToolBarsManager.Tools.Remove((ToolBase)(dynamicTools[x]));
}
dynamicTools = new ArrayList();
If there are any better suggestions please let me know
I am using following approach to clean toolbar completely -
while (ultraToolbarsManager1.Tools.Count > 0)
for (int i = 0; i < ultraToolbarsManager1.Tools.Count; i++ ) { ultraToolbarsManager1.Tools.RemoveAt(i); }
The while loop executes in few iterations. In For loop the Tools.Count decreases dynamically, which is taken care in next while iteration.