Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.5.1 #485

Merged
merged 14 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Tests/StringMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.24">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab-Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="40087JoeFinApps.TextGrab"
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
Version="4.5.0.0" />
Version="4.5.1.0" />

<Properties>
<DisplayName>Text Grab</DisplayName>
Expand Down
8 changes: 7 additions & 1 deletion Text-Grab/Controls/FindAndReplaceWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
Padding="8,2"
Icon="{StaticResource TextGrabIcon}" />

<Grid Grid.Row="1">
<Grid x:Name="MainContentGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
Expand Down Expand Up @@ -266,5 +266,11 @@
</ListView.ItemTemplate>
</ui:ListView>
</Border>

<ui:ProgressRing
x:Name="LoadingSpinner"
Grid.Row="3"
IsIndeterminate="True"
Visibility="Collapsed" />
</Grid>
</ui:FluentWindow>
76 changes: 55 additions & 21 deletions Text-Grab/Controls/FindAndReplaceWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Text-Grab/Controls/ZoomBorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab/Extensions/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab/Pages/GeneralSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
x:Name="VersionTextblock"
VerticalAlignment="Center"
Style="{StaticResource TextBodyNormal}"
Text="Version 4.5" />
Text="Version 4.5.1" />

<ui:HyperlinkButton
x:Name="OpenExeFolderButton"
Expand Down
10 changes: 5 additions & 5 deletions Text-Grab/Text-Grab.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand Down Expand Up @@ -68,11 +68,11 @@
<ItemGroup>
<PackageReference Include="CliWrap" Version="3.6.6" />
<PackageReference Include="Dapplo.Windows.User32" Version="1.0.28" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Humanizer.Core" Version="3.0.0-beta.54" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="System.Drawing.Common" Version="9.0.0-preview.1.24081.2" />
<PackageReference Include="WPF-UI" Version="3.0.4" />
<PackageReference Include="WPF-UI.Tray" Version="3.0.4" />
<PackageReference Include="System.Drawing.Common" Version="9.0.0-preview.7.24405.4" />
<PackageReference Include="WPF-UI" Version="4.0.0-rc.2" />
<PackageReference Include="WPF-UI.Tray" Version="4.0.0-rc.2" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
</ItemGroup>
Expand Down
Loading