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.

This commit is contained in:
Michael Möller 2011-05-15 21:43:40 +00:00
parent 58fcb67dcd
commit c62fb23f99
2 changed files with 17 additions and 3 deletions

View File

@ -463,7 +463,9 @@ namespace OpenHardwareMonitor.GUI {
this.treeView.UseColumns = true;
this.treeView.NodeMouseDoubleClick += new System.EventHandler<Aga.Controls.Tree.TreeNodeAdvMouseEventArgs>(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
//

View File

@ -76,6 +76,8 @@ namespace OpenHardwareMonitor.GUI {
private WmiProvider wmiProvider;
private bool selectionDragging = false;
public MainForm() {
InitializeComponent();
@ -629,9 +631,19 @@ namespace OpenHardwareMonitor.GUI {
}
private void treeView_MouseMove(object sender, MouseEventArgs e) {
if ((e.Button & (MouseButtons.Left | MouseButtons.Right)) > 0) {
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;
}
}
}