diff --git a/Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml.cs b/Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml.cs index 07a32b6..fb87f5d 100644 --- a/Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml.cs +++ b/Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml.cs @@ -428,68 +428,23 @@ private void imageGrid_MouseMove(object sender, System.Windows.Input.MouseEventA { if (m_pointDown[0] != point.X || m_pointDown[1] != point.Y) { - double ox = m_pointDown[0]; - double oy = m_pointDown[1]; + double originx = m_pointDown[0]; + double originy = m_pointDown[1]; double x = Math.Min(Math.Max(point.X, 0), image.ActualWidth); double y = Math.Min(Math.Max(point.Y, 0), image.ActualHeight); - double w = Math.Abs(x - ox); - double h = Math.Abs(y - oy); + double width = Math.Abs(x - originx); + double height = Math.Abs(y - originy); - double prop = h / w; - double iProp = image.ActualHeight / image.ActualWidth; - if (prop < iProp) - h = iProp * w; - else if (prop > iProp) - w = h / iProp; + if (originx > x) { originx -= width; } + if (originy > y) { originy -= height; } - double l = ox; - double t = oy; + Canvas.SetLeft(m_selectionRect, originx); + m_selectionRect.Width = width; + Canvas.SetTop(m_selectionRect, originy); + m_selectionRect.Height = height; - if (ox <= x) - { - if (ox + w > image.ActualWidth) - { - w = image.ActualWidth - ox; - h = iProp * w; - } - } - else - { - if (ox - w < 0) - { - w = ox; - h = iProp * w; - } - l = ox - w; - } - - if (oy <= y) - { - if (oy + h > image.ActualHeight) - { - h = image.ActualHeight - oy; - w = h / iProp; - } - } - else - { - if (oy - h < 0) - { - h = oy; - w = h / iProp; - } - t = oy - h; - } + m_selectionRect.Visibility = Visibility.Visible; - if (w > 0 && h > 0) - { - Canvas.SetLeft(m_selectionRect, l); - Canvas.SetTop(m_selectionRect, t); - m_selectionRect.Width = w; - m_selectionRect.Height = h; - - m_selectionRect.Visibility = Visibility.Visible; - } } } } @@ -568,4 +523,4 @@ private void colorTextBlock_MouseDown(object sender, System.Windows.Input.MouseB } } } -} \ No newline at end of file +}