diff --git a/Tests/StringMethodTests.cs b/Tests/StringMethodTests.cs index afbed776..3ce59f6d 100644 --- a/Tests/StringMethodTests.cs +++ b/Tests/StringMethodTests.cs @@ -81,9 +81,9 @@ public void ReturnWordAtCursorWithNewLines(int cursorPosition, string expectedWo [Theory] [InlineData("", "")] - [InlineData("Hello, world! 0123456789", "Hello, world! ol23h5678g")] + [InlineData("Hello, world! 0123456789", "Hello, world! olz3hSb7Bg")] [InlineData("Foo 4r b4r", "Foo hr bhr")] - [InlineData("B4zz 9zzl3", "Bhzz gzzl3")] + [InlineData("B4zz5 9zzl3", "BhzzS gzzl3")] [InlineData("abcdefghijklmnop", "abcdefghijklmnop")] public void TryFixToLetters_ReplacesDigitsWithLetters_AsExpected(string input, string expected) { @@ -106,10 +106,10 @@ public void TryFixNumOrLetters(string input, string expected) [Theory] [InlineData("", "")] - [InlineData("Hello, world! 0123456789", "He110, w0r1d! 0123456789")] - [InlineData("Foo 4r b4r", "F00 4r b4r")] - [InlineData("B4zz 9zzl3", "B4zz 9zz13")] - [InlineData("abcdefghijklmnop", "ab0def9h1jk1mn0p")] + [InlineData("Hello, world! 0123456789", "4e110, w0r1d! 0123456789")] + [InlineData("Foo 4r b4r", "F00 4r 64r")] + [InlineData("B4zzS 9zzl3", "84225 92213")] + [InlineData("abcdefghijklmnopqrs", "a60def941jk1mn0pqr5")] public void TryFixToLetters_ReplacesLettersWithDigits_AsExpected(string input, string expected) { // Act diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 959ba6bb..792d45d7 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -9,9 +9,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Text-Grab-Package/Package.appxmanifest b/Text-Grab-Package/Package.appxmanifest index 830c216a..1955af12 100644 --- a/Text-Grab-Package/Package.appxmanifest +++ b/Text-Grab-Package/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="4.5.1.0" /> Text Grab diff --git a/Text-Grab/Controls/FindAndReplaceWindow.xaml b/Text-Grab/Controls/FindAndReplaceWindow.xaml index 1be850d6..51664835 100644 --- a/Text-Grab/Controls/FindAndReplaceWindow.xaml +++ b/Text-Grab/Controls/FindAndReplaceWindow.xaml @@ -60,7 +60,7 @@ Padding="8,2" Icon="{StaticResource TextGrabIcon}" /> - + @@ -266,5 +266,11 @@ + + diff --git a/Text-Grab/Controls/FindAndReplaceWindow.xaml.cs b/Text-Grab/Controls/FindAndReplaceWindow.xaml.cs index db23ad3d..afa63844 100644 --- a/Text-Grab/Controls/FindAndReplaceWindow.xaml.cs +++ b/Text-Grab/Controls/FindAndReplaceWindow.xaml.cs @@ -1,8 +1,10 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -190,28 +192,36 @@ private void DeleteAll_CanExecute(object sender, CanExecuteRoutedEventArgs e) e.CanExecute = false; } - private void DeleteAll_Executed(object sender, ExecutedRoutedEventArgs e) + private async void DeleteAll_Executed(object sender, ExecutedRoutedEventArgs e) { if (Matches is null || Matches.Count < 1 || textEditWindow is null) return; - var selection = ResultsListView.SelectedItems; - if (selection.Count < 2) - selection = ResultsListView.Items; + SetWindowToLoading(); + + IList selection = ResultsListView.SelectedItems; + StringBuilder stringBuilderOfText = new(textEditWindow.PassedTextControl.Text); - for (int j = selection.Count - 1; j >= 0; j--) + await Task.Run(() => { - if (selection[j] is not FindResult selectedResult) - continue; + if (selection.Count < 2) + selection = ResultsListView.Items; - textEditWindow.PassedTextControl.Select(selectedResult.Index, selectedResult.Length); - textEditWindow.PassedTextControl.SelectedText = string.Empty; - } + for (int j = selection.Count - 1; j >= 0; j--) + { + if (selection[j] is not FindResult selectedResult) + continue; + + stringBuilderOfText.Remove(selectedResult.Index, selectedResult.Length); + } + }); + + textEditWindow.PassedTextControl.Text = stringBuilderOfText.ToString(); - textEditWindow.PassedTextControl.Select(0, 0); SearchForText(); + ResetWindowLoading(); } private void EditTextBoxChanged(object sender, TextChangedEventArgs e) @@ -314,27 +324,51 @@ private void Replace_Executed(object sender, ExecutedRoutedEventArgs e) SearchForText(); } - private void ReplaceAll_Executed(object sender, ExecutedRoutedEventArgs e) + private async void ReplaceAll_Executed(object sender, ExecutedRoutedEventArgs e) { if (Matches is null || Matches.Count < 1 || textEditWindow is null) return; - var selection = ResultsListView.SelectedItems; - if (selection.Count < 2) - selection = ResultsListView.Items; + SetWindowToLoading(); + + StringBuilder stringBuilder = new(textEditWindow.PassedTextControl.Text); - for (int j = selection.Count - 1; j >= 0; j--) + IList selection = ResultsListView.SelectedItems; + string newText = ReplaceTextBox.Text; + + await Task.Run(() => { - if (selection[j] is not FindResult selectedResult) - continue; + if (selection.Count < 2) + selection = ResultsListView.Items; - textEditWindow.PassedTextControl.Select(selectedResult.Index, selectedResult.Length); - textEditWindow.PassedTextControl.SelectedText = ReplaceTextBox.Text; - } + for (int j = selection.Count - 1; j >= 0; j--) + { + if (selection[j] is not FindResult selectedResult) + continue; + + stringBuilder.Remove(selectedResult.Index, selectedResult.Length); + stringBuilder.Insert(selectedResult.Index, newText); + } + }); + + textEditWindow.PassedTextControl.Text = stringBuilder.ToString(); SearchForText(); + ResetWindowLoading(); + } + + private void ResetWindowLoading() + { + MainContentGrid.IsEnabled = true; + LoadingSpinner.Visibility = Visibility.Collapsed; + } + + private void SetWindowToLoading() + { + MainContentGrid.IsEnabled = false; + LoadingSpinner.Visibility = Visibility.Visible; } private void ResultsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/Text-Grab/Controls/ZoomBorder.cs b/Text-Grab/Controls/ZoomBorder.cs index 952c6f20..a3a30fa2 100644 --- a/Text-Grab/Controls/ZoomBorder.cs +++ b/Text-Grab/Controls/ZoomBorder.cs @@ -138,6 +138,9 @@ void Child_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) private void Child_MouseMove(object sender, MouseEventArgs e) { + if (e.OriginalSource is TextBox) + return; + if (child is null || GetScaleTransform(child) is not ScaleTransform st || st.ScaleX == 1.0 diff --git a/Text-Grab/Extensions/StringBuilderExtensions.cs b/Text-Grab/Extensions/StringBuilderExtensions.cs index 2c8fc94b..d5cbd513 100644 --- a/Text-Grab/Extensions/StringBuilderExtensions.cs +++ b/Text-Grab/Extensions/StringBuilderExtensions.cs @@ -25,7 +25,7 @@ public static void RemoveTrailingNewlines(this StringBuilder text) public static void ReplaceGreekOrCyrillicWithLatin(this StringBuilder stringBuilder) { - stringBuilder.CharDictionaryReplace(StringMethods.greekCyrillicLatinMap); + stringBuilder.CharDictionaryReplace(StringMethods.GreekCyrillicLatinMap); } public static void TryFixToLetters(this StringBuilder stringBuilder) diff --git a/Text-Grab/Pages/GeneralSettings.xaml b/Text-Grab/Pages/GeneralSettings.xaml index 8cc38b3c..17d06dbd 100644 --- a/Text-Grab/Pages/GeneralSettings.xaml +++ b/Text-Grab/Pages/GeneralSettings.xaml @@ -27,7 +27,7 @@ x:Name="VersionTextblock" VerticalAlignment="Center" Style="{StaticResource TextBodyNormal}" - Text="Version 4.5" /> + Text="Version 4.5.1" /> + WinExe @@ -68,11 +68,11 @@ - + - - - + + + diff --git a/Text-Grab/Utilities/StringMethods.cs b/Text-Grab/Utilities/StringMethods.cs index 1806eb9f..d53ed248 100644 --- a/Text-Grab/Utilities/StringMethods.cs +++ b/Text-Grab/Utilities/StringMethods.cs @@ -8,13 +8,15 @@ namespace Text_Grab.Utilities; public static class StringMethods { - public static readonly List specialCharList = new() - { '\\', ' ', '.', ',', '$', '^', '{', '[', '(', '|', ')', '*', '+', '?', '=' }; + public static readonly List specialCharList = [ + '\\', ' ', '.', ',', '$', '^', '{', '[', '(', '|', ')', + '*', '+', '?', '=' ]; - public static readonly List ReservedChars = new() - { ' ', '"', '*', '/', ':', '<', '>', '?', '\\', '|', '+', ',', '.', ';', '=', '[', ']', '!', '@' }; + public static readonly List ReservedChars = [ + ' ', '"', '*', '/', ':', '<', '>', '?', '\\', '|', '+', + ',', '.', ';', '=', '[', ']', '!', '@' ]; - public static readonly Dictionary greekCyrillicLatinMap = new() + public static readonly Dictionary GreekCyrillicLatinMap = new() { // Similar Looking Greek characters {'Γ', 'r'}, {'Δ', 'A'}, {'Θ', 'O'}, {'Λ', 'A'}, {'Ξ', 'E'}, @@ -43,41 +45,42 @@ public static class StringMethods {'ø', 'e'}, }; - public static Dictionary NumbersToLetters = new() + public static readonly Dictionary NumbersToLetters = new() { - {'0', 'o'}, {'4', 'h'}, {'9', 'g'}, {'1', 'l'} + {'0', 'o'}, {'4', 'h'}, {'9', 'g'}, {'1', 'l'}, {'8', 'B'}, + {'5', 'S'}, {'6', 'b'}, {'2', 'z' } }; - public static Dictionary LettersToNumbers = new() + public static readonly Dictionary LettersToNumbers = new() { {'o', '0'}, {'O', '0'}, {'Q', '0'}, {'c', '0'}, {'C', '0'}, - {'i', '1'}, {'I', '1'}, {'l', '1'}, {'g', '9'} + {'i', '1'}, {'I', '1'}, {'l', '1'}, {'g', '9'}, {'G', '9'}, + {'h', '4'}, {'H', '4'}, {'s', '5'}, {'S', '5'}, {'B', '8'}, + {'b', '6'}, {'z', '2'}, {'Z', '2'} }; public static string ReplaceWithDictionary(this string str, Dictionary dict) { - var sb = new StringBuilder(); + StringBuilder sb = new(); foreach (char c in str) - { - sb.Append(dict.ContainsKey(c) ? dict[c] : c); - } + sb.Append(dict.TryGetValue(c, out char value) ? value : c); return sb.ToString(); } public static string ReplaceGreekOrCyrillicWithLatin(this string str) { - return str.ReplaceWithDictionary(greekCyrillicLatinMap); + return str.ReplaceWithDictionary(GreekCyrillicLatinMap); } - public static IEnumerable AllIndexesOf(this string str, string searchstring) + public static IEnumerable AllIndexesOf(this string str, string searchString) { - int minIndex = str.IndexOf(searchstring); + int minIndex = str.IndexOf(searchString); while (minIndex != -1) { yield return minIndex; - minIndex = str.IndexOf(searchstring, minIndex + searchstring.Length); + minIndex = str.IndexOf(searchString, minIndex + searchString.Length); } } @@ -102,7 +105,7 @@ public static (int, int) CursorWordBoundaries(this string input, int cursorPosit // Check if the cursor is at a space if (char.IsWhiteSpace(input[cursorPosition])) - cursorPosition = findNearestLetterIndex(input, cursorPosition); + cursorPosition = FindNearestLetterIndex(input, cursorPosition); // Find the start and end of the word by moving the cursor // backwards and forwards until we find a non-letter character. @@ -132,7 +135,7 @@ public static string GetWordAtCursorPosition(this string input, int cursorPositi return input.Substring(start, length); } - private static int findNearestLetterIndex(string input, int cursorPosition) + private static int FindNearestLetterIndex(string input, int cursorPosition) { Math.Clamp(cursorPosition, 0, input.Length - 1); @@ -242,14 +245,14 @@ public static string TryFixNumberLetterErrors(this string stringToFix) public static string TryFixEveryWordLetterNumberErrors(this string stringToFix) { string[] listOfWords = stringToFix.Split(' '); - List fixedWords = new(); + List fixedWords = []; foreach (string word in listOfWords) { string newWord = word.TryFixNumberLetterErrors(); fixedWords.Add(newWord); } - string joinedString = string.Join(' ', fixedWords.ToArray()); + string joinedString = string.Join(' ', [.. fixedWords]); joinedString = joinedString.Replace("\t ", "\t"); joinedString = joinedString.Replace("\r ", "\r"); joinedString = joinedString.Replace("\n ", "\n"); @@ -276,7 +279,7 @@ public static string MakeStringSingleLine(this string textToEdit) if (workingString[0] == ' ') workingString.Remove(0, 1); - if (workingString[workingString.Length - 1] == ' ') + if (workingString[^1] == ' ') workingString.Remove(workingString.Length - 1, 1); return workingString.ToString(); @@ -344,8 +347,8 @@ public enum CharType { Letter, Number, Space, Special, Other }; public class CharRun { public CharType TypeOfChar { get; set; } - public Char Character { get; set; } - public int numberOfRun { get; set; } + public char Character { get; set; } + public int NumberOfRun { get; set; } } public static string ReplaceReservedCharacters(this string stringToClean) @@ -353,7 +356,7 @@ public static string ReplaceReservedCharacters(this string stringToClean) StringBuilder sb = new(); sb.Append(stringToClean); - foreach (Char reservedChar in ReservedChars) + foreach (char reservedChar in ReservedChars) sb.Replace(reservedChar, '-'); return Regex.Replace(sb.ToString(), @"-+", "-"); @@ -382,13 +385,13 @@ public static string ExtractSimplePattern(this string stringToExtract) foreach (char c in stringToExtract) { CharType thisCharType = CharType.Other; - if (Char.IsWhiteSpace(c)) + if (char.IsWhiteSpace(c)) thisCharType = CharType.Space; else if (specialCharList.Contains(c)) thisCharType = CharType.Special; - else if (Char.IsLetter(c)) + else if (char.IsLetter(c)) thisCharType = CharType.Letter; - else if (Char.IsNumber(c)) + else if (char.IsNumber(c)) thisCharType = CharType.Number; if (thisCharType == charRunList.LastOrDefault()?.TypeOfChar) @@ -396,11 +399,11 @@ public static string ExtractSimplePattern(this string stringToExtract) if (thisCharType == CharType.Other) { if (c == charRunList.Last().Character) - charRunList.Last().numberOfRun++; + charRunList.Last().NumberOfRun++; } else { - charRunList.Last().numberOfRun++; + charRunList.Last().NumberOfRun++; } } else @@ -408,7 +411,7 @@ public static string ExtractSimplePattern(this string stringToExtract) CharRun newRun = new() { Character = c, - numberOfRun = 1, + NumberOfRun = 1, TypeOfChar = thisCharType }; charRunList.Add(newRun); @@ -416,7 +419,6 @@ public static string ExtractSimplePattern(this string stringToExtract) } StringBuilder sb = new(); - // sb.Append("("); foreach (CharRun ct in charRunList) { @@ -441,9 +443,9 @@ public static string ExtractSimplePattern(this string stringToExtract) break; } - if (ct.numberOfRun > 1) + if (ct.NumberOfRun > 1) { - sb.Append('{').Append(ct.numberOfRun).Append('}'); + sb.Append('{').Append(ct.NumberOfRun).Append('}'); } } @@ -500,7 +502,7 @@ private static string ShortenRegexPattern(this string pattern) sb.Clear(); } - possibleShortenedPatterns = possibleShortenedPatterns.OrderBy(p => p.Length).ToList(); + possibleShortenedPatterns = [.. possibleShortenedPatterns.OrderBy(p => p.Length)]; return possibleShortenedPatterns.First(); } @@ -574,14 +576,14 @@ public static string UnstackGroups(this string stringGroupedToUnstack, int numbe public static string RemoveDuplicateLines(this string stringToDeduplicate) { - string[] splitString = stringToDeduplicate.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.TrimEntries); - List uniqueLines = new(); + string[] splitString = stringToDeduplicate.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries); + List uniqueLines = []; foreach (string originalLine in splitString) if (!uniqueLines.Contains(originalLine)) uniqueLines.Add(originalLine); - return string.Join(Environment.NewLine, uniqueLines.ToArray()); + return string.Join(Environment.NewLine, [.. uniqueLines]); } public static string RemoveAllInstancesOf(this string stringToBeEdited, string stringToRemove) @@ -592,7 +594,7 @@ public static string RemoveAllInstancesOf(this string stringToBeEdited, string s public static string RemoveFromEachLine(this string stringToEdit, int numberOfChars, SpotInLine spotInLine) { - string[] splitString = stringToEdit.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None); + string[] splitString = stringToEdit.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); StringBuilder sb = new(); foreach (string line in splitString) @@ -607,10 +609,10 @@ public static string RemoveFromEachLine(this string stringToEdit, int numberOfCh switch (spotInLine) { case SpotInLine.Beginning: - sb.AppendLine(line.Substring(numberOfChars)); + sb.AppendLine(line[numberOfChars..]); break; case SpotInLine.End: - sb.AppendLine(line.Substring(0, lineLength - numberOfChars)); + sb.AppendLine(line[..(lineLength - numberOfChars)]); break; default: break; @@ -661,7 +663,7 @@ public static string LimitCharactersPerLine(this string stringToEdit, int charac } if (spotInLine== SpotInLine.Beginning) - returnStringBuilder.AppendLine(line.Substring(0, lineLimit)); + returnStringBuilder.AppendLine(line[..lineLimit]); else returnStringBuilder.AppendLine(line.Substring(line.Length - (lineLimit), lineLimit)); } @@ -689,7 +691,7 @@ public static string GetCharactersToLeftOfNewLine(ref string mainString, int ind int newLineIndex = GetNewLineIndexToLeft(ref mainString, index); if (newLineIndex < 1) - return mainString.Substring(0, index); + return mainString[..index]; newLineIndex++; @@ -709,13 +711,13 @@ public static string GetCharactersToRightOfNewLine(ref string mainString, int in { int newLineIndex = GetNewLineIndexToRight(ref mainString, index); if (newLineIndex < 1) - return mainString.Substring(index); + return mainString[index..]; if (newLineIndex - index > numberOfCharacters) return string.Concat(mainString.AsSpan(index, numberOfCharacters), "..."); if (newLineIndex == mainString.Length) - return mainString.Substring(index); + return mainString[index..]; return string.Concat(mainString.AsSpan(index, newLineIndex - index), "..."); } diff --git a/Text-Grab/Utilities/WindowUtilities.cs b/Text-Grab/Utilities/WindowUtilities.cs index 7437ffa8..2d2f3016 100644 --- a/Text-Grab/Utilities/WindowUtilities.cs +++ b/Text-Grab/Utilities/WindowUtilities.cs @@ -1,7 +1,9 @@ using Dapplo.Windows.User32; +using Fasetto.Word; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -31,7 +33,7 @@ public static void SetWindowPosition(Window passedWindow) storedPositionString = AppUtilities.TextGrabSettings.EditTextWindowSizeAndPosition; if (passedWindow is GrabFrame) - storedPositionString = AppUtilities.TextGrabSettings.GrabFrameWindowSizeAndPosition; + storedPositionString = AppUtilities.TextGrabSettings.GrabFrameWindowSizeAndPosition; List storedPosition = new(storedPositionString.Split(',')); @@ -286,4 +288,35 @@ public static void ShouldShutDown() if (shouldShutDown) Application.Current.Shutdown(); } -} + + public static bool GetMousePosition(out Point mousePosition) + { + if (GetCursorPos(out POINT point)) + { + mousePosition = new Point(point.X, point.Y); + return true; + } + mousePosition = default; + return false; + } + + public static bool IsMouseInWindow(this Window window) + { + GetMousePosition(out Point mousePosition); + + DpiScale dpi = System.Windows.Media.VisualTreeHelper.GetDpi(window); + Point absPosPoint = window.GetAbsolutePosition(); + Rect windowRect = new(absPosPoint.X, absPosPoint.Y, + window.ActualWidth * dpi.DpiScaleX, + window.ActualHeight * dpi.DpiScaleY); + return windowRect.Contains(mousePosition); + } + + #region DLLImport + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool GetCursorPos(out POINT lpPoint); + + #endregion +} \ No newline at end of file diff --git a/Text-Grab/Views/FullscreenGrab.xaml.cs b/Text-Grab/Views/FullscreenGrab.xaml.cs index ccd338ef..84557286 100644 --- a/Text-Grab/Views/FullscreenGrab.xaml.cs +++ b/Text-Grab/Views/FullscreenGrab.xaml.cs @@ -232,8 +232,8 @@ private async void FreezeUnfreeze(bool Activate) RegionClickCanvas.ContextMenu.IsOpen = false; await Task.Delay(150); SetImageToBackground(); - - if (IsMouseOver) + + if (this.IsMouseInWindow()) TopButtonsStackPanel.Visibility = Visibility.Visible; } else @@ -423,10 +423,10 @@ private void PanSelection(System.Windows.Point movingPoint) if (CurrentScreen is not null && dpiScale is not null) { - double currentScreenLeft = CurrentScreen.Bounds.Left; // Should always be 0 - double currentScreenRight = CurrentScreen.Bounds.Right / dpiScale.Value.DpiScaleX; - double currentScreenTop = CurrentScreen.Bounds.Top; // Should always be 0 - double currentScreenBottom = CurrentScreen.Bounds.Bottom / dpiScale.Value.DpiScaleY; + double currentScreenLeft = 0; + double currentScreenTop = 0; + double currentScreenRight = CurrentScreen.Bounds.Width / dpiScale.Value.DpiScaleX; + double currentScreenBottom = CurrentScreen.Bounds.Height / dpiScale.Value.DpiScaleY; leftValue = Math.Clamp(leftValue, currentScreenLeft, (currentScreenRight - selectBorder.Width)); topValue = Math.Clamp(topValue, currentScreenTop, (currentScreenBottom - selectBorder.Height)); @@ -495,8 +495,8 @@ private void RegionClickCanvas_MouseDown(object sender, MouseButtonEventArgs e) RegionClickCanvas.CaptureMouse(); CursorClipper.ClipCursor(this); clickedPoint = e.GetPosition(this); - selectBorder.Height = 1; - selectBorder.Width = 1; + selectBorder.Height = 2; + selectBorder.Width = 2; dpiScale = VisualTreeHelper.GetDpi(this); @@ -509,13 +509,12 @@ private void RegionClickCanvas_MouseDown(object sender, MouseButtonEventArgs e) Canvas.SetLeft(selectBorder, clickedPoint.X); Canvas.SetTop(selectBorder, clickedPoint.Y); - DisplayInfo[] screens = DisplayInfo.AllDisplayInfos; - System.Windows.Point formsPoint = new((int)clickedPoint.X, (int)clickedPoint.Y); - foreach (DisplayInfo scr in screens) + WindowUtilities.GetMousePosition(out System.Windows.Point mousePoint); + foreach (DisplayInfo? screen in DisplayInfo.AllDisplayInfos) { - Rect bound = scr.ScaledBounds(); - if (bound.Contains(formsPoint)) - CurrentScreen = scr; + Rect bound = screen.ScaledBounds(); + if (bound.Contains(mousePoint)) + CurrentScreen = screen; } } @@ -597,7 +596,7 @@ private async void RegionClickCanvas_MouseUp(object sender, MouseButtonEventArgs if (LanguagesComboBox.SelectedItem is TessLang tessLang) tessTag = tessLang.LanguageTag; - bool isSmallClick = (regionScaled.Width < 3 || regionScaled.Height < 3); + bool isSmallClick = (selectBorder.Width < 3 || selectBorder.Height < 3); bool isSingleLine = SingleLineMenuItem is not null && SingleLineMenuItem.IsChecked; bool isTable = TableMenuItem is not null && TableMenuItem.IsChecked;