From 622e959fa8904fe074b4cd2dd507353ea08f64da Mon Sep 17 00:00:00 2001 From: Benjamin Popp Date: Mon, 15 Apr 2019 13:05:07 -0500 Subject: [PATCH] if you left-click on the header, highlight the row --- src/HexManiac.WPF/Controls/HexContent.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/HexManiac.WPF/Controls/HexContent.cs b/src/HexManiac.WPF/Controls/HexContent.cs index 7080beaf..ee8de62e 100644 --- a/src/HexManiac.WPF/Controls/HexContent.cs +++ b/src/HexManiac.WPF/Controls/HexContent.cs @@ -212,7 +212,11 @@ namespace HavenSoft.HexManiac.WPF.Controls { } if (ViewPort is ViewPort editableViewPort) { - if (Keyboard.Modifiers == ModifierKeys.Shift) { + var point = e.GetPosition(this); + if (point.X < 0) { + editableViewPort.SelectionStart = downPoint; + editableViewPort.SelectionEnd = new ModelPoint(editableViewPort.Width - 1, downPoint.Y); + } else if (Keyboard.Modifiers == ModifierKeys.Shift) { editableViewPort.SelectionEnd = downPoint; } else { editableViewPort.SelectionStart = downPoint; @@ -229,8 +233,17 @@ namespace HavenSoft.HexManiac.WPF.Controls { InvalidateVisual(); } if (!IsMouseCaptured) return; + if (!(ViewPort is ViewPort viewPort)) return; + + + var point = e.GetPosition(this); + var modelPoint = ControlCoordinatesToModelCoordinates(e); + if (point.X < 0) { + viewPort.SelectionEnd = new ModelPoint(viewPort.Width - 1, modelPoint.Y); + } else { + viewPort.SelectionEnd = modelPoint; + } - ((ViewPort)ViewPort).SelectionEnd = ControlCoordinatesToModelCoordinates(e); } protected override void OnMouseUp(MouseButtonEventArgs e) { @@ -492,8 +505,8 @@ namespace HavenSoft.HexManiac.WPF.Controls { private ModelPoint ControlCoordinatesToModelCoordinates(MouseEventArgs e) { var point = e.GetPosition(this); - point = new System.Windows.Point(Math.Max(0, point.X), Math.Max(0, point.Y)); // out of bounds to the left/top clamps to 0 (useful for headers) - return new Core.Models.Point((int)(point.X / CellWidth), (int)(point.Y / CellHeight)); + point = new ScreenPoint(Math.Max(0, point.X), Math.Max(0, point.Y)); // out of bounds to the left/top clamps to 0 (useful for headers) + return new ModelPoint((int)(point.X / CellWidth), (int)(point.Y / CellHeight)); } }