Skip to content

Commit 8020978

Browse files
authored
Merge pull request #485 from TheJoeFin/dev
v4.5.1
2 parents bed6db1 + 5a52eff commit 8020978

12 files changed

+178
-101
lines changed

Tests/StringMethodTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public void ReturnWordAtCursorWithNewLines(int cursorPosition, string expectedWo
8181

8282
[Theory]
8383
[InlineData("", "")]
84-
[InlineData("Hello, world! 0123456789", "Hello, world! ol23h5678g")]
84+
[InlineData("Hello, world! 0123456789", "Hello, world! olz3hSb7Bg")]
8585
[InlineData("Foo 4r b4r", "Foo hr bhr")]
86-
[InlineData("B4zz 9zzl3", "Bhzz gzzl3")]
86+
[InlineData("B4zz5 9zzl3", "BhzzS gzzl3")]
8787
[InlineData("abcdefghijklmnop", "abcdefghijklmnop")]
8888
public void TryFixToLetters_ReplacesDigitsWithLetters_AsExpected(string input, string expected)
8989
{
@@ -106,10 +106,10 @@ public void TryFixNumOrLetters(string input, string expected)
106106

107107
[Theory]
108108
[InlineData("", "")]
109-
[InlineData("Hello, world! 0123456789", "He110, w0r1d! 0123456789")]
110-
[InlineData("Foo 4r b4r", "F00 4r b4r")]
111-
[InlineData("B4zz 9zzl3", "B4zz 9zz13")]
112-
[InlineData("abcdefghijklmnop", "ab0def9h1jk1mn0p")]
109+
[InlineData("Hello, world! 0123456789", "4e110, w0r1d! 0123456789")]
110+
[InlineData("Foo 4r b4r", "F00 4r 64r")]
111+
[InlineData("B4zzS 9zzl3", "84225 92213")]
112+
[InlineData("abcdefghijklmnopqrs", "a60def941jk1mn0pqr5")]
113113
public void TryFixToLetters_ReplacesLettersWithDigits_AsExpected(string input, string expected)
114114
{
115115
// Act

Tests/Tests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13-
<PackageReference Include="xunit" Version="2.8.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
13+
<PackageReference Include="xunit" Version="2.9.0" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.24">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
<PrivateAssets>all</PrivateAssets>
1717
</PackageReference>

Text-Grab-Package/Package.appxmanifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Identity
1212
Name="40087JoeFinApps.TextGrab"
1313
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
14-
Version="4.5.0.0" />
14+
Version="4.5.1.0" />
1515

1616
<Properties>
1717
<DisplayName>Text Grab</DisplayName>

Text-Grab/Controls/FindAndReplaceWindow.xaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
Padding="8,2"
6161
Icon="{StaticResource TextGrabIcon}" />
6262

63-
<Grid Grid.Row="1">
63+
<Grid x:Name="MainContentGrid" Grid.Row="1">
6464
<Grid.ColumnDefinitions>
6565
<ColumnDefinition Width="auto" />
6666
<ColumnDefinition Width="*" />
@@ -266,5 +266,11 @@
266266
</ListView.ItemTemplate>
267267
</ui:ListView>
268268
</Border>
269+
270+
<ui:ProgressRing
271+
x:Name="LoadingSpinner"
272+
Grid.Row="3"
273+
IsIndeterminate="True"
274+
Visibility="Collapsed" />
269275
</Grid>
270276
</ui:FluentWindow>

Text-Grab/Controls/FindAndReplaceWindow.xaml.cs

+55-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
56
using System.Text.RegularExpressions;
7+
using System.Threading.Tasks;
68
using System.Windows;
79
using System.Windows.Controls;
810
using System.Windows.Input;
@@ -190,28 +192,36 @@ private void DeleteAll_CanExecute(object sender, CanExecuteRoutedEventArgs e)
190192
e.CanExecute = false;
191193
}
192194

193-
private void DeleteAll_Executed(object sender, ExecutedRoutedEventArgs e)
195+
private async void DeleteAll_Executed(object sender, ExecutedRoutedEventArgs e)
194196
{
195197
if (Matches is null
196198
|| Matches.Count < 1
197199
|| textEditWindow is null)
198200
return;
199201

200-
var selection = ResultsListView.SelectedItems;
201-
if (selection.Count < 2)
202-
selection = ResultsListView.Items;
202+
SetWindowToLoading();
203+
204+
IList selection = ResultsListView.SelectedItems;
205+
StringBuilder stringBuilderOfText = new(textEditWindow.PassedTextControl.Text);
203206

204-
for (int j = selection.Count - 1; j >= 0; j--)
207+
await Task.Run(() =>
205208
{
206-
if (selection[j] is not FindResult selectedResult)
207-
continue;
209+
if (selection.Count < 2)
210+
selection = ResultsListView.Items;
208211

209-
textEditWindow.PassedTextControl.Select(selectedResult.Index, selectedResult.Length);
210-
textEditWindow.PassedTextControl.SelectedText = string.Empty;
211-
}
212+
for (int j = selection.Count - 1; j >= 0; j--)
213+
{
214+
if (selection[j] is not FindResult selectedResult)
215+
continue;
216+
217+
stringBuilderOfText.Remove(selectedResult.Index, selectedResult.Length);
218+
}
219+
});
220+
221+
textEditWindow.PassedTextControl.Text = stringBuilderOfText.ToString();
212222

213-
textEditWindow.PassedTextControl.Select(0, 0);
214223
SearchForText();
224+
ResetWindowLoading();
215225
}
216226

217227
private void EditTextBoxChanged(object sender, TextChangedEventArgs e)
@@ -314,27 +324,51 @@ private void Replace_Executed(object sender, ExecutedRoutedEventArgs e)
314324
SearchForText();
315325
}
316326

317-
private void ReplaceAll_Executed(object sender, ExecutedRoutedEventArgs e)
327+
private async void ReplaceAll_Executed(object sender, ExecutedRoutedEventArgs e)
318328
{
319329
if (Matches is null
320330
|| Matches.Count < 1
321331
|| textEditWindow is null)
322332
return;
323333

324-
var selection = ResultsListView.SelectedItems;
325-
if (selection.Count < 2)
326-
selection = ResultsListView.Items;
334+
SetWindowToLoading();
335+
336+
StringBuilder stringBuilder = new(textEditWindow.PassedTextControl.Text);
327337

328-
for (int j = selection.Count - 1; j >= 0; j--)
338+
IList selection = ResultsListView.SelectedItems;
339+
string newText = ReplaceTextBox.Text;
340+
341+
await Task.Run(() =>
329342
{
330-
if (selection[j] is not FindResult selectedResult)
331-
continue;
343+
if (selection.Count < 2)
344+
selection = ResultsListView.Items;
332345

333-
textEditWindow.PassedTextControl.Select(selectedResult.Index, selectedResult.Length);
334-
textEditWindow.PassedTextControl.SelectedText = ReplaceTextBox.Text;
335-
}
346+
for (int j = selection.Count - 1; j >= 0; j--)
347+
{
348+
if (selection[j] is not FindResult selectedResult)
349+
continue;
350+
351+
stringBuilder.Remove(selectedResult.Index, selectedResult.Length);
352+
stringBuilder.Insert(selectedResult.Index, newText);
353+
}
354+
});
355+
356+
textEditWindow.PassedTextControl.Text = stringBuilder.ToString();
336357

337358
SearchForText();
359+
ResetWindowLoading();
360+
}
361+
362+
private void ResetWindowLoading()
363+
{
364+
MainContentGrid.IsEnabled = true;
365+
LoadingSpinner.Visibility = Visibility.Collapsed;
366+
}
367+
368+
private void SetWindowToLoading()
369+
{
370+
MainContentGrid.IsEnabled = false;
371+
LoadingSpinner.Visibility = Visibility.Visible;
338372
}
339373

340374
private void ResultsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)

Text-Grab/Controls/ZoomBorder.cs

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ void Child_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
138138

139139
private void Child_MouseMove(object sender, MouseEventArgs e)
140140
{
141+
if (e.OriginalSource is TextBox)
142+
return;
143+
141144
if (child is null
142145
|| GetScaleTransform(child) is not ScaleTransform st
143146
|| st.ScaleX == 1.0

Text-Grab/Extensions/StringBuilderExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void RemoveTrailingNewlines(this StringBuilder text)
2525

2626
public static void ReplaceGreekOrCyrillicWithLatin(this StringBuilder stringBuilder)
2727
{
28-
stringBuilder.CharDictionaryReplace(StringMethods.greekCyrillicLatinMap);
28+
stringBuilder.CharDictionaryReplace(StringMethods.GreekCyrillicLatinMap);
2929
}
3030

3131
public static void TryFixToLetters(this StringBuilder stringBuilder)

Text-Grab/Pages/GeneralSettings.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
x:Name="VersionTextblock"
2828
VerticalAlignment="Center"
2929
Style="{StaticResource TextBodyNormal}"
30-
Text="Version 4.5" />
30+
Text="Version 4.5.1" />
3131

3232
<ui:HyperlinkButton
3333
x:Name="OpenExeFolderButton"

Text-Grab/Text-Grab.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
@@ -68,11 +68,11 @@
6868
<ItemGroup>
6969
<PackageReference Include="CliWrap" Version="3.6.6" />
7070
<PackageReference Include="Dapplo.Windows.User32" Version="1.0.28" />
71-
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
71+
<PackageReference Include="Humanizer.Core" Version="3.0.0-beta.54" />
7272
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
73-
<PackageReference Include="System.Drawing.Common" Version="9.0.0-preview.1.24081.2" />
74-
<PackageReference Include="WPF-UI" Version="3.0.4" />
75-
<PackageReference Include="WPF-UI.Tray" Version="3.0.4" />
73+
<PackageReference Include="System.Drawing.Common" Version="9.0.0-preview.7.24405.4" />
74+
<PackageReference Include="WPF-UI" Version="4.0.0-rc.2" />
75+
<PackageReference Include="WPF-UI.Tray" Version="4.0.0-rc.2" />
7676
<PackageReference Include="ZXing.Net" Version="0.16.9" />
7777
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
7878
</ItemGroup>

0 commit comments

Comments
 (0)