From a4ed425ac0cd74abd267a2df39a9bde1956fa33f Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 8 Jan 2016 13:37:01 -0800 Subject: [PATCH] Made the selection of library items behave like a check box on mouse up. Made the mouse up scroll behavior consider if the control has been scrolled or not rather than just the mouse position. --- Library/LibraryRowItem.cs | 55 +++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/Library/LibraryRowItem.cs b/Library/LibraryRowItem.cs index 5f8335076..3aa982d01 100644 --- a/Library/LibraryRowItem.cs +++ b/Library/LibraryRowItem.cs @@ -223,40 +223,51 @@ namespace MatterHackers.MatterControl.PrintLibrary partLabel.VAnchor = VAnchor.ParentCenter; middleColumn.AddChild(partLabel); + bool mouseDownOnMiddle = false; middleColumn.MouseDown += (sender, e) => { // Abort normal processing for view helpers - if(this.IsViewHelperItem) + if (this.IsViewHelperItem) { return; } + mouseDownOnMiddle = true; + }; - if (this.libraryDataView.EditMode) + middleColumn.MouseUp += (sender, e) => + { + if (mouseDownOnMiddle & + middleColumn.LocalBounds.Contains(e.Position)) { - if (this.IsSelectedItem) + if (this.libraryDataView.EditMode) { - libraryDataView.SelectedItems.Remove(this); - } - else - { - libraryDataView.SelectedItems.Add(this); - } - Invalidate(); - } - else - { - // we only have single selection - if (this.IsSelectedItem) - { - // It is already selected, do nothing. - } - else - { - libraryDataView.ClearSelectedItems(); - libraryDataView.SelectedItems.Add(this); + if (this.IsSelectedItem) + { + libraryDataView.SelectedItems.Remove(this); + } + else + { + libraryDataView.SelectedItems.Add(this); + } Invalidate(); } + else + { + // we only have single selection + if (this.IsSelectedItem) + { + // It is already selected, do nothing. + } + else + { + libraryDataView.ClearSelectedItems(); + libraryDataView.SelectedItems.Add(this); + Invalidate(); + } + } } + + mouseDownOnMiddle = false; }; } primaryFlow.AddChild(selectionCheckBoxContainer);