private void ShowOptionsPanel(Control control) { using (new Wait()) { IOptionsPanel optionsPanel = (control as IOptionsPanel); if (optionsPanel == null) { throw new ArgumentException("Provided control must be an IOptionsPanel.", "optionsPanel"); } optionsPlaceholderPanel.SuspendLayout(); optionsPlaceholderPanel.Controls.Add(control); control.Dock = DockStyle.Fill; propertiesToolbox.HeaderText = optionsPanel.Title + " Properties"; optionsPanel.SelectedTabIndex = this.LastShownTabPage.ValueOrDefault(optionsPanel.GetType()); optionsPanel.Saved += new SavedDelegate( delegate(object sender, EventArgs e) { _unsavedChanges = true; UpdateTitle(); RefreshSelectedNode(); }); optionsPlaceholderPanel.ResumeLayout(); } }
private void projectTreeview_AfterSelect(object sender, TreeViewEventArgs e) { using (new Wait()) { optionsPlaceholderPanel.SuspendLayout(); propertiesToolbox.HeaderText = "Properties"; while (!optionsPlaceholderPanel.Controls.IsNullOrEmpty()) { IOptionsPanel optionsPanel = (optionsPlaceholderPanel.Controls[0] as IOptionsPanel); if (optionsPanel != null) { this.LastShownTabPage[optionsPanel.GetType()] = optionsPanel.SelectedTabIndex; } optionsPlaceholderPanel.Controls[0].Dispose(); } if (e.Node is ProjectTreeNode) { ShowOptionsPanel(new ProjectOptions(((ProjectTreeNode)e.Node).Project)); } if (e.Node is ConnectionTreeNode) { ShowOptionsPanel(new ConnectionOptions(((ConnectionTreeNode)e.Node).ConnectionInfo)); } else if (e.Node is TemplateTreeNode) { ShowOptionsPanel(new TemplateOptions(((TemplateTreeNode)e.Node).Template)); } else if (e.Node is TableOrViewTreeNode) { ShowOptionsPanel(new TableOrViewOptions(((TableOrViewTreeNode)e.Node).TableMapping)); } else if (e.Node is ColumnTreeNode) { ShowOptionsPanel(new ColumnOptions(((ColumnTreeNode)e.Node).ColumnMapping)); } else if (e.Node is UniqueIndexTreeNode) { ShowOptionsPanel(new UniqueIndexOptions(((UniqueIndexTreeNode)e.Node).UniqueIndexMapping)); } else if (e.Node is ForeignKeyTreeNode) { ShowOptionsPanel(new ForeignKeyOptions(((ForeignKeyTreeNode)e.Node).ForeignKeyMapping)); } optionsPlaceholderPanel.ResumeLayout(); } }