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.
This commit is contained in:
Lars Brubaker 2016-01-08 13:37:01 -08:00
parent 8c8a94b716
commit a4ed425ac0

View file

@ -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);