public SettingsStub(ToolStrip toolStrip) { this.ToolStripPanelName = string.Empty; ToolStripPanel parent = toolStrip.Parent as ToolStripPanel; if (parent != null) { if (!string.IsNullOrEmpty(parent.Name)) { this.ToolStripPanelName = parent.Name; } else if ((parent.Parent is ToolStripContainer) && !string.IsNullOrEmpty(parent.Parent.Name)) { this.ToolStripPanelName = parent.Parent.Name + "." + parent.Dock.ToString(); } } this.Visible = toolStrip.Visible; this.Size = toolStrip.Size; this.Location = toolStrip.Location; this.Name = toolStrip.Name; this.ItemOrder = ToolStripSettingsManager.GetItemOrder(toolStrip); }
/// <devdoc> /// Saves settings for the given form with the given settings key. /// </devdoc> public static void SaveSettings(Form sourceForm, string key) { if (sourceForm == null) { throw new ArgumentNullException("sourceForm"); } if (String.IsNullOrEmpty(key)) { throw new ArgumentNullException("key"); } ToolStripSettingsManager settingsManager = new ToolStripSettingsManager(sourceForm, key); ; settingsManager.Save(); }
/// <devdoc> /// Loads settings for the given Form with the given settings key. /// </devdoc> public static void LoadSettings(Form targetForm, string key) { if (targetForm == null) { throw new ArgumentNullException("targetForm"); } if (String.IsNullOrEmpty(key)) { throw new ArgumentNullException("key"); } ToolStripSettingsManager settingsManager = new ToolStripSettingsManager(targetForm, key); settingsManager.Load(); }