# HG changeset patch # User moel.mich # Date 1305495820 0 # Node ID a35a89a35532672f2d89ac7a5336459f7cc647d5 # Parent 1f5cf5d533e6764a71c07592ec7745f7c1e7154a Improved the selection dragging on the tree view. The selection moves now only when the dragging starts on the tree view. With the old implementation, double-clicking the gadget would change the selection, because the mouse is still pressed when the main window is shown. diff -r 1f5cf5d533e6 -r a35a89a35532 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Sun May 15 20:48:52 2011 +0000 +++ b/GUI/MainForm.Designer.cs Sun May 15 21:43:40 2011 +0000 @@ -463,7 +463,9 @@ this.treeView.UseColumns = true; this.treeView.NodeMouseDoubleClick += new System.EventHandler(this.treeView_NodeMouseDoubleClick); this.treeView.Click += new System.EventHandler(this.treeView_Click); + this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown); this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove); + this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp); // // plotPanel // diff -r 1f5cf5d533e6 -r a35a89a35532 GUI/MainForm.cs --- a/GUI/MainForm.cs Sun May 15 20:48:52 2011 +0000 +++ b/GUI/MainForm.cs Sun May 15 21:43:40 2011 +0000 @@ -76,6 +76,8 @@ private WmiProvider wmiProvider; + private bool selectionDragging = false; + public MainForm() { InitializeComponent(); @@ -629,9 +631,19 @@ } private void treeView_MouseMove(object sender, MouseEventArgs e) { - if ((e.Button & (MouseButtons.Left | MouseButtons.Right)) > 0) { - treeView.SelectedNode = treeView.GetNodeAt(e.Location); - } + selectionDragging = selectionDragging & + (e.Button & (MouseButtons.Left | MouseButtons.Right)) > 0; + + if (selectionDragging) + treeView.SelectedNode = treeView.GetNodeAt(e.Location); + } + + private void treeView_MouseDown(object sender, MouseEventArgs e) { + selectionDragging = true; + } + + private void treeView_MouseUp(object sender, MouseEventArgs e) { + selectionDragging = false; } } }