Skip to content

Commit

Permalink
Show selected items size details when selecting by dragging the mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKordiukiewicz committed Jun 2, 2022
1 parent 2025184 commit bcc1aaf
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -21,6 +21,7 @@ public class RectangleSelection_ListViewBase : RectangleSelection
private Point originDragPoint;
private Dictionary<object, System.Drawing.Rectangle> itemsPosition;
private List<object> prevSelectedItems;
private List<object> prevSelectedItemsDrag;
private ItemSelectionStrategy selectionStrategy;

public RectangleSelection_ListViewBase(ListViewBase uiElement, Rectangle selectionRectangle, SelectionChangedEventHandler selectionChanged = null)
Expand Down Expand Up @@ -92,6 +93,17 @@ private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventAr
var scrollIncrement = Math.Min(20 - currentPoint.Position.Y, 40);
scrollViewer.ChangeView(null, verticalOffset - scrollIncrement, null, false);
}

if (selectionChanged != null)
{
var currentSelectedItemsDrag = uiElement.SelectedItems.Cast<object>().ToList();
if (prevSelectedItemsDrag == null || !prevSelectedItemsDrag.SequenceEqual(currentSelectedItemsDrag))
{
// Trigger SelectionChanged event if the selection has changed
selectionChanged(sender, null);
prevSelectedItemsDrag = currentSelectedItemsDrag;
}
}
}
}

Expand Down Expand Up @@ -195,6 +207,8 @@ private void RectangleSelection_PointerReleased(object sender, PointerRoutedEven
selectionStrategy = null;
selectionState = SelectionState.Inactive;

prevSelectedItemsDrag = null;

e.Handled = true;
}

Expand Down

0 comments on commit bcc1aaf

Please sign in to comment.