/// <summary> /// /// </summary> public MarkdownViewerOptions(ref MarkdownViewerConfiguration configuration) { // this.configuration = configuration; // InitializeComponent(); //Iterate over all menu items and register their classes string thisNamespace = typeof(MarkdownViewerOptions).Namespace; foreach (TreeNode node in this.treeOptions.Nodes) { AbstractOptionsPanel optionsPanel = (AbstractOptionsPanel)Activator.CreateInstance(Type.GetType(thisNamespace + "." + node.Tag.ToString())); this.SaveEvent += optionsPanel.SaveOptions; this.LoadEvent += optionsPanel.LoadOptions; //Add to map to store for changes this.optionPanels.Add(node.Tag.ToString(), optionsPanel); } // this.treeOptions.AfterSelect += treeOptions_AfterSelect; //Start with the general options panel this.splitOptions.Panel2.Controls.Add(this.optionPanels.First().Value); this.treeOptions.Select(); //Set the according dialog result to their respective buttons this.btnOptionsCancel.DialogResult = DialogResult.Cancel; this.btnOptionsSave.DialogResult = DialogResult.OK; // this.LoadEvent(this.configuration.options); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="treeNodeEvent"></param> protected void treeOptions_AfterSelect(object sender, TreeViewEventArgs treeNodeEvent) { //Remove old (if any) if (this.splitOptions.Panel2.Controls.Count > 0) { this.splitOptions.Panel2.Controls.RemoveAt(0); } //Add selected options panel AbstractOptionsPanel optionPanel = this.optionPanels.Where(entry => entry.Key == treeNodeEvent.Node.Tag.ToString()).First().Value; this.splitOptions.Panel2.Controls.Add(optionPanel); }