private void ViewerItemClick(Object sender, System.EventArgs e) { if (Tree.SelectedNode != null) { if (viewerForm == null) { viewerForm = new ViewerForm(); viewerForm.StartPosition = FormStartPosition.Manual; } DataNode node = Tree.SelectedNode.Tag as DataNode; viewerForm.Exp = node.Text; viewerForm.Value = node.Value; Form mainform = (PluginBase.MainForm as Form); viewerForm.Left = mainform.Left + mainform.Width / 2 - viewerForm.Width / 2; viewerForm.Top = mainform.Top + mainform.Height / 2 - viewerForm.Height / 2; viewerForm.ShowDialog(); } }
public DataTreeControl() { InitializeComponent(); _model = new DataTreeModel(); _tree.Model = _model; this.Controls.Add(_tree); _tree.Expanding += new EventHandler<TreeViewAdvEventArgs>(TreeExpanding); _tree.LoadOnDemand = true; _tree.AutoRowHeight = true; NameNodeTextBox.IsEditEnabledValueNeeded += new EventHandler<NodeControlValueEventArgs>(NameNodeTextBox_IsEditEnabledValueNeeded); ValueNodeTextBox.DrawText += new EventHandler<DrawEventArgs>(ValueNodeTextBox_DrawText); ValueNodeTextBox.IsEditEnabledValueNeeded += new EventHandler<NodeControlValueEventArgs>(ValueNodeTextBox_IsEditEnabledValueNeeded); ValueNodeTextBox.EditorShowing += new System.ComponentModel.CancelEventHandler(ValueNodeTextBox_EditorShowing); ValueNodeTextBox.EditorHided += new EventHandler(ValueNodeTextBox_EditorHided); _contextMenuStrip = new ContextMenuStrip(); if (PluginBase.MainForm != null && PluginBase.Settings != null) { _contextMenuStrip.Font = PluginBase.Settings.DefaultFont; } _tree.ContextMenuStrip = _contextMenuStrip; copyMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Copy"), null, new EventHandler(this.CopyItemClick)); viewerMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.Viewer"), null, new EventHandler(this.ViewerItemClick)); _contextMenuStrip.Items.AddRange(new ToolStripMenuItem[] { copyMenuItem, viewerMenuItem}); viewerForm = new ViewerForm(); viewerForm.StartPosition = FormStartPosition.Manual; }