Skip to content

Commit d7b0f5d

Browse files
authored
Merge pull request #516 from TheJoeFin/dev
4.8 Dev
2 parents 2c8a74f + 47e694b commit d7b0f5d

34 files changed

+1196
-163
lines changed

.editorconfig

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ dotnet_style_null_propagation = true:suggestion
1616
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
1717
dotnet_style_prefer_auto_properties = true:silent
1818
dotnet_style_object_initializer = true:suggestion
19+
dotnet_style_collection_initializer = false:suggestion
20+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
21+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
22+
dotnet_style_prefer_conditional_expression_over_return = true:silent
23+
dotnet_style_explicit_tuple_names = true:suggestion
24+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
25+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
26+
dotnet_style_prefer_compound_assignment = true:suggestion
27+
dotnet_style_prefer_simplified_interpolation = true:suggestion
1928

2029
[*.{yml,yaml,appxmanifest,manifest,config}]
2130
indent_style = space
@@ -142,7 +151,7 @@ csharp_prefer_braces = when_multiline:silent
142151
csharp_prefer_simple_using_statement = true:suggestion
143152
csharp_style_namespace_declarations = file_scoped:silent
144153
csharp_style_prefer_method_group_conversion = true:silent
145-
csharp_style_prefer_primary_constructors = true:suggestion
154+
csharp_style_prefer_primary_constructors = false:suggestion
146155
csharp_style_prefer_top_level_statements = true:silent
147156

148157
# Expression-level preferences
@@ -279,4 +288,5 @@ dotnet_diagnostic.IDE0055.severity = none
279288
dotnet_diagnostic.CA2263.severity = none
280289
dotnet_diagnostic.IDE0051.severity = none
281290
dotnet_diagnostic.IDE0052.severity = none
282-
dotnet_diagnostic.CS1591.severity = none
291+
dotnet_diagnostic.CS1591.severity = none
292+
csharp_prefer_system_threading_lock = true:suggestion

Tests/Tests.csproj

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

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
13-
<PackageReference Include="xunit" Version="2.9.2" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13+
<PackageReference Include="xunit" Version="2.9.3" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
<PrivateAssets>all</PrivateAssets>
1717
</PackageReference>
18-
<PackageReference Include="Xunit.StaFact" Version="1.2.46-alpha" />
18+
<PackageReference Include="Xunit.StaFact" Version="1.2.69" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

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.7.0.0" />
14+
Version="4.8.0.0" />
1515

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

Text-Grab/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@
154154
<setting name="WebSearchItemsJson" serializeAs="String">
155155
<value />
156156
</setting>
157+
<setting name="GrabFrameReadBarcodes" serializeAs="String">
158+
<value>True</value>
159+
</setting>
160+
<setting name="EtwShowLangPicker" serializeAs="String">
161+
<value>False</value>
162+
</setting>
157163
</Text_Grab.Properties.Settings>
158164
</userSettings>
159165
</configuration>

Text-Grab/Controls/BottomBarSettings.xaml

+8
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@
230230
Show Scrollbar
231231
</TextBlock>
232232
</ui:ToggleSwitch>
233+
<ui:ToggleSwitch
234+
x:Name="ShowLanguagePickerToggle"
235+
Margin="0,12,0,0"
236+
VerticalContentAlignment="Center">
237+
<TextBlock VerticalAlignment="Center" Style="{StaticResource TextBodyNormal}">
238+
Show Language picker
239+
</TextBlock>
240+
</ui:ToggleSwitch>
233241

234242
</StackPanel>
235243
</Grid>

Text-Grab/Controls/BottomBarSettings.xaml.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ public BottomBarSettings()
2020
{
2121
InitializeComponent();
2222

23-
List<ButtonInfo> allBtns = new(ButtonInfo.AllButtons);
23+
List<ButtonInfo> allBtns = [.. ButtonInfo.AllButtons];
2424

25-
ButtonsInRightList = new(CustomBottomBarUtilities.GetCustomBottomBarItemsSetting());
25+
ButtonsInRightList = [.. CustomBottomBarUtilities.GetCustomBottomBarItemsSetting()];
2626
RightListBox.ItemsSource = ButtonsInRightList;
2727
foreach (ButtonInfo cbutton in ButtonsInRightList)
2828
{
2929
allBtns.Remove(cbutton);
3030
}
3131

32-
ButtonsInLeftList = new(allBtns);
32+
ButtonsInLeftList = [.. allBtns];
3333
LeftListBox.ItemsSource = ButtonsInLeftList;
3434

3535
ShowCursorTextCheckBox.IsChecked = DefaultSettings.ShowCursorText;
3636
ShowScrollbarCheckBox.IsChecked = DefaultSettings.ScrollBottomBar;
37+
ShowLanguagePickerToggle.IsChecked = DefaultSettings.EtwShowLangPicker;
3738
}
3839

3940
#endregion Constructors
@@ -119,6 +120,7 @@ private void SaveBTN_Click(object sender, RoutedEventArgs e)
119120
{
120121
DefaultSettings.ShowCursorText = ShowCursorTextCheckBox.IsChecked ?? true;
121122
DefaultSettings.ScrollBottomBar = ShowScrollbarCheckBox.IsChecked ?? true;
123+
DefaultSettings.EtwShowLangPicker = ShowLanguagePickerToggle.IsChecked ?? true;
122124
DefaultSettings.Save();
123125

124126
CustomBottomBarUtilities.SaveCustomBottomBarItemsSetting(ButtonsInRightList.ToList());
@@ -129,4 +131,4 @@ private void SaveBTN_Click(object sender, RoutedEventArgs e)
129131
}
130132

131133
#endregion Methods
132-
}
134+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<UserControl
2+
x:Class="Text_Grab.Controls.LanguagePicker"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:global="clr-namespace:Windows.Globalization;assembly=Microsoft.Windows.SDK.NET"
7+
xmlns:local="clr-namespace:Text_Grab.Controls"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml"
10+
d:DesignHeight="450"
11+
d:DesignWidth="800"
12+
Loaded="UserControl_Loaded"
13+
mc:Ignorable="d">
14+
<ComboBox
15+
x:Name="MainComboBox"
16+
ItemsSource="{Binding Languages,
17+
Mode=OneWay}"
18+
SelectedItem="{Binding SelectedLanguage,
19+
Mode=TwoWay}"
20+
SelectionChanged="MainComboBox_SelectionChanged">
21+
<ComboBox.ItemTemplate>
22+
<DataTemplate DataType="global:Language">
23+
<TextBlock Text="{Binding DisplayName}" />
24+
</DataTemplate>
25+
</ComboBox.ItemTemplate>
26+
</ComboBox>
27+
</UserControl>
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.ObjectModel;
3+
using System.Windows;
4+
using System.Windows.Controls;
5+
using Text_Grab.Utilities;
6+
using Windows.Globalization;
7+
8+
namespace Text_Grab.Controls;
9+
10+
public partial class LanguagePicker : UserControl
11+
{
12+
public ObservableCollection<Language> Languages = [];
13+
14+
public event RoutedEventHandler? LanguageChanged;
15+
16+
public Language SelectedLanguage
17+
{
18+
get { return (Language)GetValue(SelectedLanguageProperty); }
19+
set { SetValue(SelectedLanguageProperty, value); }
20+
}
21+
22+
public static readonly DependencyProperty SelectedLanguageProperty =
23+
DependencyProperty.Register("SelectedLanguage", typeof(Language), typeof(LanguagePicker), new PropertyMetadata(null));
24+
25+
public LanguagePicker()
26+
{
27+
DataContext = this;
28+
InitializeComponent();
29+
}
30+
31+
private void UserControl_Loaded(object sender, RoutedEventArgs e)
32+
{
33+
Languages.Clear();
34+
35+
Language currentLanguage = LanguageUtilities.GetCurrentInputLanguage();
36+
37+
int selectedIndex = 0;
38+
int i = 0;
39+
foreach (Language language in LanguageUtilities.GetAllLanguages())
40+
{
41+
if (language.LanguageTag == currentLanguage.LanguageTag)
42+
selectedIndex = i;
43+
44+
MainComboBox.Items.Add(language);
45+
i++;
46+
}
47+
48+
MainComboBox.SelectedIndex = selectedIndex;
49+
}
50+
51+
private void MainComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
52+
{
53+
LanguageChanged?.Invoke(this, new RoutedEventArgs());
54+
}
55+
56+
internal void Select(string ietfLanguageTag)
57+
{
58+
int i = 0;
59+
foreach (object? item in MainComboBox.Items)
60+
{
61+
if (item is Language language && language.LanguageTag == ietfLanguageTag)
62+
{
63+
MainComboBox.SelectedIndex = i;
64+
break;
65+
}
66+
i++;
67+
}
68+
}
69+
}

Text-Grab/Controls/RegExIcon.xaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<UserControl
2+
x:Class="Text_Grab.Controls.RegExIcon"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Text_Grab.Controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
d:DesignHeight="200"
9+
d:DesignWidth="222"
10+
mc:Ignorable="d">
11+
<Viewbox>
12+
<Path Data="M148 97L117.5 149.5L87.5 128L125 82L75 71.5L86 38.5L135.5 57.5L125 0H171.5L161 57.5L210.5 38.5L221.5 71.5L171.5 82L209 128L179 149.5L148 97Z M0 129 L75 129 L 75 204 L0 204 z" Fill="{Binding IconColor}" />
13+
</Viewbox>
14+
</UserControl>

Text-Grab/Controls/RegExIcon.xaml.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
using System.Windows.Media;
4+
5+
namespace Text_Grab.Controls;
6+
7+
public partial class RegExIcon : UserControl
8+
{
9+
public SolidColorBrush IconColor
10+
{
11+
get { return (SolidColorBrush)GetValue(IconColorProperty); }
12+
set { SetValue(IconColorProperty, value); }
13+
}
14+
15+
public static readonly DependencyProperty IconColorProperty =
16+
DependencyProperty.Register("IconColor", typeof(SolidColorBrush), typeof(RegExIcon), new PropertyMetadata(null));
17+
18+
public RegExIcon()
19+
{
20+
DataContext = this;
21+
InitializeComponent();
22+
}
23+
}

Text-Grab/Controls/WordBorder.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private void MakeSingleLineMenuItem_Click(object sender, RoutedEventArgs e)
347347

348348
private void WordBorder_MouseEnter(object sender, RoutedEventArgs e)
349349
{
350-
if (OwnerGrabFrame?.isCtrlDown is true)
350+
if (OwnerGrabFrame?.IsCtrlDown is true)
351351
MoveResizeBorder.Visibility = Visibility.Visible;
352352
else
353353
MoveResizeBorder.Visibility = Visibility.Collapsed;

Text-Grab/Controls/ZoomBorder.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override UIElement Child
3737
}
3838
}
3939

40-
public bool CanPan { get; set; } = true;
40+
public bool CanPan { get; set; } = false;
4141

4242
public bool CanZoom { get; set; } = true;
4343

@@ -83,6 +83,8 @@ public void Reset()
8383
TranslateTransform tt = GetTranslateTransform(child);
8484
tt.X = 0.0;
8585
tt.Y = 0.0;
86+
87+
CanPan = false;
8688
}
8789

8890
private void Child_MouseWheel(object sender, MouseWheelEventArgs e)
@@ -109,6 +111,8 @@ private void Child_MouseWheel(object sender, MouseWheelEventArgs e)
109111

110112
tt.X = absoluteX - relative.X * st.ScaleX;
111113
tt.Y = absoluteY - relative.Y * st.ScaleY;
114+
115+
CanPan = true;
112116
}
113117

114118
private void Child_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
@@ -158,4 +162,4 @@ private void Child_MouseMove(object sender, MouseEventArgs e)
158162
tt.X = origin.X - v.X;
159163
tt.Y = origin.Y - v.Y;
160164
}
161-
}
165+
}

Text-Grab/Models/ButtonInfo.cs

+9-15
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ public override bool Equals(object? obj)
3131

3232
public override int GetHashCode()
3333
{
34-
int hash = 17;
35-
hash = (hash * 23) + ButtonText.GetHashCode();
36-
hash = (hash * 23) + SymbolText.GetHashCode();
37-
hash = (hash * 23) + Background.GetHashCode();
38-
hash = (hash * 23) + Command.GetHashCode();
39-
hash = (hash * 23) + ClickEvent.GetHashCode();
40-
return hash;
34+
return System.HashCode.Combine(ButtonText, SymbolText, Background, Command, ClickEvent);
4135
}
4236

4337
// a constructor which takes a collapsible button
@@ -71,8 +65,8 @@ public ButtonInfo(string buttonText, string symbolText, string background, strin
7165
IsSymbol = isSymbol;
7266
}
7367

74-
public static List<ButtonInfo> DefaultButtonList { get; set; } = new()
75-
{
68+
public static List<ButtonInfo> DefaultButtonList { get; set; } =
69+
[
7670
new()
7771
{
7872
ButtonText = "Copy and Close",
@@ -122,15 +116,15 @@ public ButtonInfo(string buttonText, string symbolText, string background, strin
122116
new()
123117
{
124118
ButtonText = "Edit Bottom Bar",
125-
SymbolText = "",
119+
SymbolText = "",
126120
ClickEvent = "EditBottomBarMenuItem_Click",
127121
IsSymbol = true,
128-
SymbolIcon = SymbolRegular.CalendarEdit24
122+
SymbolIcon = SymbolRegular.CalendarSettings24
129123
},
130-
};
124+
];
131125

132-
public static List<ButtonInfo> AllButtons { get; set; } = new()
133-
{
126+
public static List<ButtonInfo> AllButtons { get; set; } =
127+
[
134128
new()
135129
{
136130
OrderNumber = 1.1,
@@ -449,7 +443,7 @@ public ButtonInfo(string buttonText, string symbolText, string background, strin
449443
ClickEvent = "SettingsMenuItem_Click",
450444
SymbolIcon = SymbolRegular.Settings24
451445
},
452-
};
446+
];
453447
}
454448

455449

Text-Grab/Models/LookupItem.cs

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Humanizer;
22
using System;
3+
using System.Linq;
34

45
namespace Text_Grab.Models;
56

@@ -9,6 +10,8 @@ public enum LookupItemKind
910
EditWindow = 1,
1011
GrabFrame = 2,
1112
Link = 3,
13+
Command = 4,
14+
Dynamic = 5,
1215
}
1316

1417
public class LookupItem : IEquatable<LookupItem>
@@ -26,6 +29,8 @@ public Wpf.Ui.Controls.SymbolRegular UiSymbol
2629
LookupItemKind.EditWindow => Wpf.Ui.Controls.SymbolRegular.Window24,
2730
LookupItemKind.GrabFrame => Wpf.Ui.Controls.SymbolRegular.PanelBottom20,
2831
LookupItemKind.Link => Wpf.Ui.Controls.SymbolRegular.Link24,
32+
LookupItemKind.Command => Wpf.Ui.Controls.SymbolRegular.WindowConsole20,
33+
LookupItemKind.Dynamic => Wpf.Ui.Controls.SymbolRegular.Flash24,
2934
_ => Wpf.Ui.Controls.SymbolRegular.Copy20,
3035
};
3136
}
@@ -38,6 +43,8 @@ public LookupItem()
3843

3944
}
4045

46+
public string FirstLettersString => string.Join("", ShortValue.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => s[0])).ToLower();
47+
4148
public LookupItem(string sv, string lv)
4249
{
4350
ShortValue = sv;

0 commit comments

Comments
 (0)