private void LoadSettings(Category category) { if (currentCategory == category) { return; } else { if (currentSettings != null) { currentSettings.Save(); if (mainPanel.Controls.Contains(currentSettings as Control)) { mainPanel.Controls.Remove(currentSettings as Control); } currentSettings.Dispose(); } } Control control = null; switch (category) { case Category.HttpServer: //control = new ServerSettings(); break; case Category.Diagram: break; case Category.Default: control = new DefaultSettings(); break; default: break; } control.Dock = DockStyle.Fill; (control as ISettings).MainForm = mainForm; (control as ISettings).Load(); mainPanel.Controls.Add(control); currentSettings = control as ISettings; currentCategory = category; }
private void LoadSettings(Category category) { if (currentCategory == category) return; else { if (currentSettings != null) { currentSettings.Save(); if(mainPanel.Controls.Contains(currentSettings as Control)) mainPanel.Controls.Remove(currentSettings as Control); currentSettings.Dispose(); } } Control control = null; switch (category) { case Category.HttpServer: //control = new ServerSettings(); break; case Category.Diagram: break; case Category.Default: control = new DefaultSettings(); break; default: break; } control.Dock = DockStyle.Fill; (control as ISettings).MainForm = mainForm; (control as ISettings).Load(); mainPanel.Controls.Add(control); currentSettings = control as ISettings; currentCategory = category; }