Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Files/UserControls/Selection/RectangleSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,26 @@ public enum SelectionState
Active
}

protected void DrawRectangle(PointerPoint currentPoint, Point originDragPointShifted)
protected void DrawRectangle(PointerPoint currentPoint, Point originDragPointShifted, UIElement uiElement)
{
// Redraw selection rectangle according to the new point
if (currentPoint.Position.X >= originDragPointShifted.X)
{
double maxWidth = uiElement.ActualSize.X - originDragPointShifted.X;
if (currentPoint.Position.Y <= originDragPointShifted.Y)
{
// Pointer was moved up and right
Canvas.SetLeft(selectionRectangle, Math.Max(0, originDragPointShifted.X));
Canvas.SetTop(selectionRectangle, Math.Max(0, currentPoint.Position.Y));
selectionRectangle.Width = Math.Max(0, currentPoint.Position.X - Math.Max(0, originDragPointShifted.X));
selectionRectangle.Width = Math.Max(0, Math.Min(currentPoint.Position.X - Math.Max(0, originDragPointShifted.X), maxWidth));
selectionRectangle.Height = Math.Max(0, originDragPointShifted.Y - Math.Max(0, currentPoint.Position.Y));
}
else
{
// Pointer was moved down and right
Canvas.SetLeft(selectionRectangle, Math.Max(0, originDragPointShifted.X));
Canvas.SetTop(selectionRectangle, Math.Max(0, originDragPointShifted.Y));
selectionRectangle.Width = Math.Max(0, currentPoint.Position.X - Math.Max(0, originDragPointShifted.X));
selectionRectangle.Width = Math.Max(0, Math.Min(currentPoint.Position.X - Math.Max(0, originDragPointShifted.X), maxWidth));
selectionRectangle.Height = Math.Max(0, currentPoint.Position.Y - Math.Max(0, originDragPointShifted.Y));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventAr
if (currentPoint.Properties.IsLeftButtonPressed)
{
var originDragPointShifted = new Point(originDragPoint.X, originDragPoint.Y - verticalOffset); // Initial drag point relative to the topleft corner
base.DrawRectangle(currentPoint, originDragPointShifted);
base.DrawRectangle(currentPoint, originDragPointShifted, uiElement);
// Selected area considering scrolled offset
var rect = new System.Drawing.Rectangle((int)Canvas.GetLeft(selectionRectangle), (int)Math.Min(originDragPoint.Y, currentPoint.Position.Y + verticalOffset), (int)selectionRectangle.Width, (int)Math.Abs(originDragPoint.Y - (currentPoint.Position.Y + verticalOffset)));
var dataGridRowsPosition = new Dictionary<DataGridRow, System.Drawing.Rectangle>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void RectangleSelection_PointerMoved(object sender, PointerRoutedEventAr
if (currentPoint.Properties.IsLeftButtonPressed)
{
var originDragPointShifted = new Point(originDragPoint.X, originDragPoint.Y - verticalOffset); // Initial drag point relative to the topleft corner
base.DrawRectangle(currentPoint, originDragPointShifted);
base.DrawRectangle(currentPoint, originDragPointShifted, uiElement);
// Selected area considering scrolled offset
var rect = new System.Drawing.Rectangle((int)Canvas.GetLeft(selectionRectangle), (int)Math.Min(originDragPoint.Y, currentPoint.Position.Y + verticalOffset), (int)selectionRectangle.Width, (int)Math.Abs(originDragPoint.Y - (currentPoint.Position.Y + verticalOffset)));
foreach (var item in uiElement.Items.ToList().Except(itemsPosition.Keys))
Expand Down