diff --git a/src/modules/PowerOCR/PowerOCR/App.xaml.cs b/src/modules/PowerOCR/PowerOCR/App.xaml.cs index d23537d6f6..318d925f19 100644 --- a/src/modules/PowerOCR/PowerOCR/App.xaml.cs +++ b/src/modules/PowerOCR/PowerOCR/App.xaml.cs @@ -58,7 +58,7 @@ public partial class App : Application, IDisposable } catch (Exception ex) { - Debug.WriteLine(ex.Message); + Logger.LogError($"PowerOCR got an exception on start: {ex}"); } } else diff --git a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs index e8039caaa0..4148abbe2d 100644 --- a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs +++ b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs @@ -42,6 +42,8 @@ public partial class OCROverlay : Window private double xShiftDelta; private double yShiftDelta; + private const double ActiveOpacity = 0.4; + public OCROverlay() { InitializeComponent(); @@ -55,7 +57,7 @@ public partial class OCROverlay : Window KeyUp += MainWindow_KeyUp; BackgroundImage.Source = ImageMethods.GetWindowBoundsImage(this); - BackgroundBrush.Opacity = 0.4; + BackgroundBrush.Opacity = ActiveOpacity; } private void Window_Unloaded(object sender, RoutedEventArgs e) @@ -84,9 +86,6 @@ public partial class OCROverlay : Window switch (e.Key) { case Key.LeftShift: - isShiftDown = false; - clickedPoint = new Point(clickedPoint.X + xShiftDelta, clickedPoint.Y + yShiftDelta); - break; case Key.RightShift: isShiftDown = false; clickedPoint = new Point(clickedPoint.X + xShiftDelta, clickedPoint.Y + yShiftDelta); @@ -110,7 +109,7 @@ public partial class OCROverlay : Window private void RegionClickCanvas_MouseDown(object sender, MouseButtonEventArgs e) { - if (e.RightButton == MouseButtonState.Pressed) + if (e.LeftButton != MouseButtonState.Pressed) { return; } @@ -147,6 +146,7 @@ public partial class OCROverlay : Window if (scr.Bounds.Contains(formsPoint)) { CurrentScreen = scr; + break; } } } @@ -190,7 +190,7 @@ public partial class OCROverlay : Window clippingGeometry.Rect = new Rect( new Point(leftValue, topValue), - new Size(selectBorder.Width - 2, selectBorder.Height - 2)); + new Size(selectBorder.Width, selectBorder.Height)); Canvas.SetLeft(selectBorder, leftValue - 1); Canvas.SetTop(selectBorder, topValue - 1); return; @@ -235,11 +235,6 @@ public partial class OCROverlay : Window movingPoint.X = Math.Round(movingPoint.X); movingPoint.Y = Math.Round(movingPoint.Y); - if (mPt == movingPoint) - { - Debug.WriteLine("Probably on Screen 1"); - } - double xDimScaled = Canvas.GetLeft(selectBorder) * m.M11; double yDimScaled = Canvas.GetTop(selectBorder) * m.M22; @@ -262,7 +257,6 @@ public partial class OCROverlay : Window if (regionScaled.Width < 3 || regionScaled.Height < 3) { - BackgroundBrush.Opacity = 0; grabbedText = await ImageMethods.GetClickedWord(this, new Point(xDimScaled, yDimScaled)); } else @@ -272,7 +266,15 @@ public partial class OCROverlay : Window if (string.IsNullOrWhiteSpace(grabbedText) == false) { - Clipboard.SetText(grabbedText); + try + { + Clipboard.SetText(grabbedText); + } + catch (Exception ex) + { + Logger.LogError($"Clipboard.SetText exception: {ex}"); + } + WindowUtilities.CloseAllOCROverlays(); } }