public static FindToolStrip ( string toolStripName ) : |
||
toolStripName | string | |
return |
private void ApplySettings(ArrayList toolStripSettingsToApply) { if (toolStripSettingsToApply.Count != 0) { this.SuspendAllLayout(this.form); Dictionary <string, ToolStrip> itemLocationHash = this.BuildItemOriginationHash(); Dictionary <object, List <SettingsStub> > dictionary2 = new Dictionary <object, List <SettingsStub> >(); foreach (SettingsStub stub in toolStripSettingsToApply) { object key = !string.IsNullOrEmpty(stub.ToolStripPanelName) ? stub.ToolStripPanelName : null; if (key == null) { if (!string.IsNullOrEmpty(stub.Name)) { ToolStrip toolStrip = ToolStripManager.FindToolStrip(this.form, stub.Name); this.ApplyToolStripSettings(toolStrip, stub, itemLocationHash); } } else { if (!dictionary2.ContainsKey(key)) { dictionary2[key] = new List <SettingsStub>(); } dictionary2[key].Add(stub); } } foreach (ToolStripPanel panel in this.FindToolStripPanels(true, this.form.Controls)) { foreach (Control control in panel.Controls) { control.Visible = false; } string name = panel.Name; if ((string.IsNullOrEmpty(name) && (panel.Parent is ToolStripContainer)) && !string.IsNullOrEmpty(panel.Parent.Name)) { name = panel.Parent.Name + "." + panel.Dock.ToString(); } panel.BeginInit(); if (dictionary2.ContainsKey(name)) { List <SettingsStub> list2 = dictionary2[name]; if (list2 != null) { foreach (SettingsStub stub2 in list2) { if (!string.IsNullOrEmpty(stub2.Name)) { ToolStrip strip2 = ToolStripManager.FindToolStrip(this.form, stub2.Name); this.ApplyToolStripSettings(strip2, stub2, itemLocationHash); panel.Join(strip2, stub2.Location); } } } } panel.EndInit(); } this.ResumeAllLayout(this.form, true); } }
private void ApplySettings(ArrayList toolStripSettingsToApply) { if (toolStripSettingsToApply.Count == 0) { return; } SuspendAllLayout(form); // iterate through all the toolstrips and build up a hash of where the items // are right now. Dictionary <string, ToolStrip> itemLocationHash = BuildItemOriginationHash(); // build up a hash of where we want the ToolStrips to go Dictionary <object, List <SettingsStub> > toolStripPanelDestinationHash = new Dictionary <object, List <SettingsStub> >(); foreach (SettingsStub toolStripSettings in toolStripSettingsToApply) { object destinationPanel = !string.IsNullOrEmpty(toolStripSettings.ToolStripPanelName) ? toolStripSettings.ToolStripPanelName : null; if (destinationPanel == null) { // Not in a panel. if (!string.IsNullOrEmpty(toolStripSettings.Name)) { // apply the toolstrip settings. ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, toolStripSettings.Name); ApplyToolStripSettings(toolStrip, toolStripSettings, itemLocationHash); } } else { // This toolStrip is in a ToolStripPanel. We will process it below. if (!toolStripPanelDestinationHash.ContainsKey(destinationPanel)) { toolStripPanelDestinationHash[destinationPanel] = new List <SettingsStub>(); } toolStripPanelDestinationHash[destinationPanel].Add(toolStripSettings); } } // build up a list of the toolstrippanels to party on ArrayList toolStripPanels = FindToolStripPanels(true, form.Controls); foreach (ToolStripPanel toolStripPanel in toolStripPanels) { // set all the controls to visible false/ foreach (Control c in toolStripPanel.Controls) { c.Visible = false; } string toolStripPanelName = toolStripPanel.Name; // Handle the ToolStripPanels inside a ToolStripContainer if (string.IsNullOrEmpty(toolStripPanelName) && toolStripPanel.Parent is ToolStripContainer && !string.IsNullOrEmpty(toolStripPanel.Parent.Name)) { toolStripPanelName = toolStripPanel.Parent.Name + "." + toolStripPanel.Dock.ToString(); } toolStripPanel.BeginInit(); // get the associated toolstrips for this panel if (toolStripPanelDestinationHash.ContainsKey(toolStripPanelName)) { List <SettingsStub> stubSettings = toolStripPanelDestinationHash[toolStripPanelName]; if (stubSettings != null) { foreach (SettingsStub settings in stubSettings) { if (!string.IsNullOrEmpty(settings.Name)) { // apply the toolstrip settings. ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, settings.Name); ApplyToolStripSettings(toolStrip, settings, itemLocationHash); toolStripPanel.Join(toolStrip, settings.Location); } } } } toolStripPanel.EndInit(); } ResumeAllLayout(form, true); }