diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index c72a359a..7ac0ae07 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 d8206dcf..79891a93 100644
--- a/Text-Grab-Package/Package.appxmanifest
+++ b/Text-Grab-Package/Package.appxmanifest
@@ -11,7 +11,7 @@
+ Version="4.7.0.0" />
Text Grab
diff --git a/Text-Grab-Package/Text-Grab-Package.wapproj b/Text-Grab-Package/Text-Grab-Package.wapproj
index fa97345d..ccba0d23 100644
--- a/Text-Grab-Package/Text-Grab-Package.wapproj
+++ b/Text-Grab-Package/Text-Grab-Package.wapproj
@@ -161,5 +161,10 @@
True
+
+
+
+
+
\ No newline at end of file
diff --git a/Text-Grab/App.config b/Text-Grab/App.config
index f852fa6e..d6361c43 100644
--- a/Text-Grab/App.config
+++ b/Text-Grab/App.config
@@ -145,6 +145,15 @@
Resize
+
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Text-Grab/Controls/BottomBarSettings.xaml b/Text-Grab/Controls/BottomBarSettings.xaml
index 906121bf..113a0121 100644
--- a/Text-Grab/Controls/BottomBarSettings.xaml
+++ b/Text-Grab/Controls/BottomBarSettings.xaml
@@ -74,7 +74,8 @@
Margin="0,0,8,0"
d:Symbol="Diamond24"
FontSize="24"
- Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
+ Symbol="{Binding Path=SymbolIcon,
+ Mode=TwoWay}" />
@@ -173,7 +174,8 @@
Margin="0,0,8,0"
d:Symbol="Diamond24"
FontSize="24"
- Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
+ Symbol="{Binding Path=SymbolIcon,
+ Mode=TwoWay}" />
diff --git a/Text-Grab/Controls/CollapsibleButton.xaml b/Text-Grab/Controls/CollapsibleButton.xaml
index 0f0059b5..a29f0dcc 100644
--- a/Text-Grab/Controls/CollapsibleButton.xaml
+++ b/Text-Grab/Controls/CollapsibleButton.xaml
@@ -24,7 +24,9 @@
+ Symbol="{Binding Path=ButtonSymbol,
+ Mode=TwoWay,
+ ElementName=CollapsibleButtonUserControl}" />
+ Text="{Binding ElementName=CollapsibleButtonUserControl,
+ Path=ButtonText,
+ Mode=TwoWay}" />
@@ -40,7 +44,8 @@
Name="ChangeButtonLayout"
Click="ChangeButtonLayout_Click"
Header="Change Style"
- IsEnabled="{Binding ElementName=CollapsibleButtonUserControl, Path=CanChangeStyle}" />
+ IsEnabled="{Binding ElementName=CollapsibleButtonUserControl,
+ Path=CanChangeStyle}" />
diff --git a/Text-Grab/Models/ButtonInfo.cs b/Text-Grab/Models/ButtonInfo.cs
index 3f7cdab2..cb3d6419 100644
--- a/Text-Grab/Models/ButtonInfo.cs
+++ b/Text-Grab/Models/ButtonInfo.cs
@@ -200,33 +200,9 @@ public ButtonInfo(string buttonText, string symbolText, string background, strin
new()
{
OrderNumber = 1.7,
- ButtonText = "Google...",
+ ButtonText = "Web Search",
SymbolText = "",
- Command = "GoogleSearchCmd",
- SymbolIcon = SymbolRegular.GlobeSearch24
- },
- new()
- {
- OrderNumber = 1.8,
- ButtonText = "Bing...",
- SymbolText = "",
- Command = "BingSearchCmd",
- SymbolIcon = SymbolRegular.GlobeSearch24
- },
- new()
- {
- OrderNumber = 1.9,
- ButtonText = "Duck Duck Go...",
- SymbolText = "",
- Command = "DuckDuckGoSearchCmd",
- SymbolIcon = SymbolRegular.GlobeSearch24
- },
- new()
- {
- OrderNumber = 1.91,
- ButtonText = "Search GitHub...",
- SymbolText = "",
- Command = "GitHubSearchCmd",
+ Command = "DefaultWebSearchCmd",
SymbolIcon = SymbolRegular.GlobeSearch24
},
new()
diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs
index 3beebb5b..64102818 100644
--- a/Text-Grab/Models/LookupItem.cs
+++ b/Text-Grab/Models/LookupItem.cs
@@ -1,11 +1,37 @@
-using System;
+using Humanizer;
+using System;
namespace Text_Grab.Models;
+public enum LookupItemKind
+{
+ Simple = 0,
+ EditWindow = 1,
+ GrabFrame = 2,
+ Link = 3,
+}
+
public class LookupItem : IEquatable
{
- public string shortValue { get; set; } = string.Empty;
- public string longValue { get; set; } = string.Empty;
+ public string ShortValue { get; set; } = string.Empty;
+ public string LongValue { get; set; } = string.Empty;
+
+ public Wpf.Ui.Controls.SymbolRegular UiSymbol
+ {
+ get
+ {
+ return Kind switch
+ {
+ LookupItemKind.Simple => Wpf.Ui.Controls.SymbolRegular.Copy20,
+ LookupItemKind.EditWindow => Wpf.Ui.Controls.SymbolRegular.Window24,
+ LookupItemKind.GrabFrame => Wpf.Ui.Controls.SymbolRegular.PanelBottom20,
+ LookupItemKind.Link => Wpf.Ui.Controls.SymbolRegular.Link24,
+ _ => Wpf.Ui.Controls.SymbolRegular.Copy20,
+ };
+ }
+ }
+
+ public LookupItemKind Kind { get; set; } = LookupItemKind.Simple;
public LookupItem()
{
@@ -14,13 +40,34 @@ public LookupItem()
public LookupItem(string sv, string lv)
{
- shortValue = sv;
- longValue = lv;
+ ShortValue = sv;
+ LongValue = lv;
}
- public override string ToString() => $"{shortValue} {longValue}";
+ public LookupItem(HistoryInfo historyInfo)
+ {
+ ShortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F");
+ LongValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100].Trim() + "…" : historyInfo.TextContent.Trim();
+
+ HistoryItem = historyInfo;
+
+ if (string.IsNullOrEmpty(historyInfo.ImagePath))
+ Kind = LookupItemKind.EditWindow;
+ else
+ Kind = LookupItemKind.GrabFrame;
+ }
+
+ public HistoryInfo? HistoryItem { get; set; }
+
+ public override string ToString()
+ {
+ if (HistoryItem is not null)
+ return $"{HistoryItem.CaptureDateTime:F} {HistoryItem.TextContent}";
+
+ return $"{ShortValue} {LongValue}";
+ }
- public string ToCSVString() => $"{shortValue},{longValue}";
+ public string ToCSVString() => $"{ShortValue},{LongValue}";
public bool Equals(LookupItem? other)
{
@@ -32,4 +79,4 @@ public bool Equals(LookupItem? other)
return false;
}
-}
\ No newline at end of file
+}
diff --git a/Text-Grab/Models/WebSearchUrlModel.cs b/Text-Grab/Models/WebSearchUrlModel.cs
new file mode 100644
index 00000000..7053d22f
--- /dev/null
+++ b/Text-Grab/Models/WebSearchUrlModel.cs
@@ -0,0 +1,98 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using Text_Grab.Utilities;
+
+namespace Text_Grab.Models;
+
+public record WebSearchUrlModel
+{
+ public string Name { get; set; } = string.Empty;
+ public string Url { get; set; } = string.Empty;
+
+ private WebSearchUrlModel? defaultSearcher;
+
+ public WebSearchUrlModel DefaultSearcher
+ {
+ get
+ {
+ defaultSearcher ??= GetDefaultSearcher();
+ return defaultSearcher;
+ }
+ set
+ {
+ defaultSearcher = value;
+ SaveDefaultSearcher(defaultSearcher);
+ }
+ }
+
+ public override string ToString() => Name;
+
+ private List webSearchers = [];
+
+ public List WebSearchers
+ {
+ get
+ {
+ if (webSearchers.Count == 0)
+ webSearchers = GetWebSearchUrls();
+
+ return webSearchers;
+ }
+ set
+ {
+ webSearchers = value;
+ SaveWebSearchUrls(webSearchers);
+ }
+ }
+
+ private WebSearchUrlModel GetDefaultSearcher()
+ {
+ string searcherName = AppUtilities.TextGrabSettings.DefaultWebSearch;
+ if (string.IsNullOrWhiteSpace(searcherName))
+ return WebSearchers[0];
+
+ WebSearchUrlModel? searcher = WebSearchers
+ .FirstOrDefault(searcher => searcher.Name == searcherName);
+
+ return searcher ?? WebSearchers[0];
+ }
+
+ private void SaveDefaultSearcher(WebSearchUrlModel webSearchUrl)
+ {
+ AppUtilities.TextGrabSettings.DefaultWebSearch = webSearchUrl.Name;
+ AppUtilities.TextGrabSettings.Save();
+ }
+
+ private static List GetDefaultWebSearchUrls()
+ {
+ return
+ [
+ new() { Name = "Google", Url = "https://www.google.com/search?q=" },
+ new() { Name = "Bing", Url = "https://www.bing.com/search?q=" },
+ new() { Name = "DuckDuckGo", Url = "https://duckduckgo.com/?q=" },
+ new() { Name = "Brave", Url = "https://search.brave.com/search?q=" },
+ new() { Name = "GitHub Code", Url = "https://github.com/search?type=code&q=" },
+ new() { Name = "GitHub Repos", Url = "https://github.com/search?type=repositories&q=" },
+ ];
+ }
+
+ public static List GetWebSearchUrls()
+ {
+ string json = AppUtilities.TextGrabSettings.WebSearchItemsJson;
+ if (string.IsNullOrWhiteSpace(json))
+ return GetDefaultWebSearchUrls();
+ List? webSearchUrls = JsonSerializer.Deserialize>(json);
+ if (webSearchUrls is null || webSearchUrls.Count == 0)
+ return GetDefaultWebSearchUrls();
+
+ return webSearchUrls;
+ }
+
+ public static void SaveWebSearchUrls(List webSearchUrls)
+ {
+ string json = JsonSerializer.Serialize(webSearchUrls);
+ AppUtilities.TextGrabSettings.WebSearchItemsJson = json;
+ AppUtilities.TextGrabSettings.Save();
+ }
+}
diff --git a/Text-Grab/Pages/GeneralSettings.xaml b/Text-Grab/Pages/GeneralSettings.xaml
index ae144ccf..39ade307 100644
--- a/Text-Grab/Pages/GeneralSettings.xaml
+++ b/Text-Grab/Pages/GeneralSettings.xaml
@@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Text_Grab.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:models="clr-namespace:Text_Grab.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="GeneralSettings"
d:DesignHeight="1450"
@@ -27,7 +28,7 @@
x:Name="VersionTextblock"
VerticalAlignment="Center"
Style="{StaticResource TextBodyNormal}"
- Text="Version 4.6.0" />
+ Text="Version 4.7.0" />
+
+
+
+
+
+
+
+
+
searcherSettings = Singleton.Instance.WebSearchers;
+
+ foreach (WebSearchUrlModel searcher in searcherSettings)
+ WebSearchersComboBox.Items.Add(searcher);
+
+ WebSearchersComboBox.SelectedItem = Singleton.Instance.DefaultSearcher;
+
ShowToastCheckBox.IsChecked = DefaultSettings.ShowToast;
RunInBackgroundChkBx.IsChecked = DefaultSettings.RunInTheBackground;
@@ -356,4 +366,14 @@ private void ShowToastCheckBox_Unchecked(object sender, RoutedEventArgs e)
DefaultSettings.ShowToast = false;
}
+
+ private void WebSearchersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!settingsSet
+ || sender is not ComboBox comboBox
+ || comboBox.SelectedItem is not WebSearchUrlModel newDefault)
+ return;
+
+ Singleton.Instance.DefaultSearcher = newDefault;
+ }
}
diff --git a/Text-Grab/Properties/Settings.Designer.cs b/Text-Grab/Properties/Settings.Designer.cs
index 95b517f6..d5a18153 100644
--- a/Text-Grab/Properties/Settings.Designer.cs
+++ b/Text-Grab/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace Text_Grab.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -574,5 +574,41 @@ public string GrabFrameScrollBehavior {
this["GrabFrameScrollBehavior"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool LookupSearchHistory {
+ get {
+ return ((bool)(this["LookupSearchHistory"]));
+ }
+ set {
+ this["LookupSearchHistory"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string DefaultWebSearch {
+ get {
+ return ((string)(this["DefaultWebSearch"]));
+ }
+ set {
+ this["DefaultWebSearch"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string WebSearchItemsJson {
+ get {
+ return ((string)(this["WebSearchItemsJson"]));
+ }
+ set {
+ this["WebSearchItemsJson"] = value;
+ }
+ }
}
}
diff --git a/Text-Grab/Properties/Settings.settings b/Text-Grab/Properties/Settings.settings
index fc262f6b..a9a2887f 100644
--- a/Text-Grab/Properties/Settings.settings
+++ b/Text-Grab/Properties/Settings.settings
@@ -140,5 +140,14 @@
Resize
+
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Text-Grab/Services/HistoryService.cs b/Text-Grab/Services/HistoryService.cs
index 5271b12d..fafcd154 100644
--- a/Text-Grab/Services/HistoryService.cs
+++ b/Text-Grab/Services/HistoryService.cs
@@ -23,9 +23,9 @@ public class HistoryService
private static readonly int maxHistoryTextOnly = 100;
private static readonly int maxHistoryWithImages = 10;
- private List HistoryTextOnly = new();
- private List HistoryWithImage = new();
- private DispatcherTimer saveTimer = new();
+ private List HistoryTextOnly = [];
+ private List HistoryWithImage = [];
+ private readonly DispatcherTimer saveTimer = new();
private readonly Settings DefaultSettings = AppUtilities.TextGrabSettings;
#endregion Fields
@@ -119,7 +119,7 @@ public async Task LoadHistories()
public async Task PopulateMenuItemWithRecentGrabs(MenuItem recentGrabsMenuItem)
{
List grabsHistory = GetRecentGrabs();
- grabsHistory = grabsHistory.OrderByDescending(x => x.CaptureDateTime).ToList();
+ grabsHistory = [.. grabsHistory.OrderByDescending(x => x.CaptureDateTime)];
recentGrabsMenuItem.Items.Clear();
@@ -244,6 +244,23 @@ public void WriteHistory()
WriteHistoryFiles(HistoryWithImage, nameof(HistoryWithImage), maxHistoryWithImages);
}
}
+
+ public void RemoveTextHistoryItem(HistoryInfo historyItem)
+ {
+ HistoryTextOnly.Remove(historyItem);
+
+ saveTimer.Stop();
+ saveTimer.Start();
+ }
+
+ public void RemoveImageHistoryItem(HistoryInfo historyItem)
+ {
+ HistoryWithImage.Remove(historyItem);
+
+ saveTimer.Stop();
+ saveTimer.Start();
+ }
+
#endregion Public Methods
#region Private Methods
@@ -252,14 +269,14 @@ private static async Task> LoadHistory(string fileName)
{
string rawText = await FileUtilities.GetTextFileAsync($"{fileName}.json", FileStorageKind.WithHistory);
- if (string.IsNullOrWhiteSpace(rawText)) return new List();
+ if (string.IsNullOrWhiteSpace(rawText)) return [];
List? tempHistory = JsonSerializer.Deserialize>(rawText);
if (tempHistory is List jsonList && jsonList.Count > 0)
return tempHistory;
- return new List();
+ return [];
}
private static void WriteHistoryFiles(List history, string fileName, int maxNumberToSave)
@@ -310,5 +327,6 @@ private void SaveTimer_Tick(object? sender, EventArgs e)
WriteHistory();
CachedBitmap = null;
}
+
#endregion Private Methods
}
diff --git a/Text-Grab/Styles/ButtonStyles.xaml b/Text-Grab/Styles/ButtonStyles.xaml
index 184df4d8..4edc2705 100644
--- a/Text-Grab/Styles/ButtonStyles.xaml
+++ b/Text-Grab/Styles/ButtonStyles.xaml
@@ -218,7 +218,8 @@
x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
- IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
+ IsOpen="{Binding IsSubmenuOpen,
+ RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=templateRoot}"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
@@ -237,9 +238,12 @@
VerticalAlignment="Top">
+ Width="{Binding ActualWidth,
+ ElementName=SubMenuBorder}"
+ Height="{Binding ActualHeight,
+ ElementName=SubMenuBorder}"
+ Fill="{Binding Background,
+ ElementName=SubMenuBorder}" />
@@ -469,9 +474,12 @@
VerticalAlignment="Top">
+ Width="{Binding ActualWidth,
+ ElementName=SubMenuBorder}"
+ Height="{Binding ActualHeight,
+ ElementName=SubMenuBorder}"
+ Fill="{Binding Background,
+ ElementName=SubMenuBorder}" />
+ Visibility="{Binding HeadersVisibility,
+ ConverterParameter={x:Static DataGridHeadersVisibility.Row},
+ Converter={x:Static DataGrid.HeadersVisibilityConverter},
+ RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
@@ -155,4 +161,4 @@
-
\ No newline at end of file
+
diff --git a/Text-Grab/Styles/TextBoxStyles.xaml b/Text-Grab/Styles/TextBoxStyles.xaml
index c2555038..16bd0c4b 100644
--- a/Text-Grab/Styles/TextBoxStyles.xaml
+++ b/Text-Grab/Styles/TextBoxStyles.xaml
@@ -169,7 +169,8 @@
x:Name="Arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
- Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}">
+ Data="{Binding Content,
+ RelativeSource={RelativeSource TemplatedParent}}">
@@ -359,4 +360,4 @@
-
\ No newline at end of file
+
diff --git a/Text-Grab/Text-Grab.csproj b/Text-Grab/Text-Grab.csproj
index 757c06f9..6ccd2424 100644
--- a/Text-Grab/Text-Grab.csproj
+++ b/Text-Grab/Text-Grab.csproj
@@ -68,11 +68,11 @@
-
+
-
+
diff --git a/Text-Grab/Utilities/CustomBottomBarUtilities.cs b/Text-Grab/Utilities/CustomBottomBarUtilities.cs
index 90293561..840993f5 100644
--- a/Text-Grab/Utilities/CustomBottomBarUtilities.cs
+++ b/Text-Grab/Utilities/CustomBottomBarUtilities.cs
@@ -20,14 +20,15 @@ public static List GetCustomBottomBarItemsSetting()
if (string.IsNullOrWhiteSpace(json))
return ButtonInfo.DefaultButtonList;
- List? customBottomBarItems = new();
+ List? customBottomBarItems = [];
customBottomBarItems = JsonSerializer.Deserialize>(json);
if (customBottomBarItems is null || customBottomBarItems.Count == 0)
return ButtonInfo.DefaultButtonList;
- // check to see if the first element is using the default symbol, Diamond24, which is unused by any button
+ // check to see if the first element is using the default symbol of Diamond24
+ // which is unused by any button
if (customBottomBarItems.First().SymbolIcon == SymbolRegular.Diamond24)
{
// Migrate to the new SymbolRegular instead of the old symbols.
@@ -37,14 +38,12 @@ public static List GetCustomBottomBarItemsSetting()
buttonInfo.SymbolIcon = buttonDictionary[buttonInfo.ButtonText];
}
-
return customBottomBarItems;
}
- // a method to save a list of collapsible buttons to the settings as json
public static void SaveCustomBottomBarItemsSetting(List bottomBarButtons)
{
- List customButtons = new();
+ List customButtons = [];
foreach (CollapsibleButton collapsible in bottomBarButtons)
customButtons.Add(new(collapsible));
@@ -54,23 +53,20 @@ public static void SaveCustomBottomBarItemsSetting(List botto
public static void SaveCustomBottomBarItemsSetting(List bottomBarButtons)
{
- // serialize the list of custom bottom bar items to json
string json = JsonSerializer.Serialize(bottomBarButtons);
-
- // save the json string to the settings
AppUtilities.TextGrabSettings.BottomButtonsJson = json;
-
- // save the settings
AppUtilities.TextGrabSettings.Save();
}
public static List GetBottomBarButtons(EditTextWindow editTextWindow)
{
- List bottomBarButtons = new();
- Dictionary _localRoutedCommands = new();
+ List bottomBarButtons = [];
+ Dictionary _localRoutedCommands = [];
List methods = GetMethods(editTextWindow);
Dictionary routedCommands = EditTextWindow.GetRoutedCommands();
+ int index = 1;
+
foreach (ButtonInfo buttonItem in GetCustomBottomBarItemsSetting())
{
CollapsibleButton button = new()
@@ -78,7 +74,7 @@ public static List GetBottomBarButtons(EditTextWindow editTex
ButtonText = buttonItem.ButtonText,
IsSymbol = buttonItem.IsSymbol,
CustomButton = buttonItem,
- ToolTip = buttonItem.ButtonText,
+ ToolTip = $"{buttonItem.ButtonText} (ctrl + {index})",
ButtonSymbol = buttonItem.SymbolIcon
};
@@ -97,18 +93,17 @@ public static List GetBottomBarButtons(EditTextWindow editTex
button.Command = routedCommand;
bottomBarButtons.Add(button);
+ index++;
}
return bottomBarButtons;
}
- // a method which returns a list of all methods in this class
private static List GetMethods(object obj)
{
- return obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).ToList();
+ return [.. obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)];
}
- // using the above method match a method name to a string parameter
private static MethodInfo? GetMethodInfoForName(string methodName, List methods)
{
foreach (MethodInfo method in methods)
@@ -118,7 +113,6 @@ private static List GetMethods(object obj)
return null;
}
- // a method to match a command name to a string parameter
private static RoutedCommand? GetCommandBinding(string commandName, Dictionary routedCommands)
{
foreach (string commandKey in routedCommands.Keys)
diff --git a/Text-Grab/Utilities/StringMethods.cs b/Text-Grab/Utilities/StringMethods.cs
index 11c162c5..d9a7b39e 100644
--- a/Text-Grab/Utilities/StringMethods.cs
+++ b/Text-Grab/Utilities/StringMethods.cs
@@ -122,6 +122,15 @@ public static (int, int) CursorWordBoundaries(this string input, int cursorPosit
if (cursorPosition < 0)
cursorPosition = 0;
+ try
+ {
+ char check = input[cursorPosition];
+ }
+ catch (IndexOutOfRangeException)
+ {
+ return (cursorPosition, 0);
+ }
+
// Check if the cursor is at a space
if (char.IsWhiteSpace(input[cursorPosition]))
cursorPosition = FindNearestLetterIndex(input, cursorPosition);
diff --git a/Text-Grab/Views/EditTextWindow.xaml b/Text-Grab/Views/EditTextWindow.xaml
index cf95f750..f741192a 100644
--- a/Text-Grab/Views/EditTextWindow.xaml
+++ b/Text-Grab/Views/EditTextWindow.xaml
@@ -129,20 +129,12 @@
Executed="MakeQrCodeExecuted" />
+ Command="{x:Static local:EditTextWindow.WebSearchCmd}"
+ Executed="WebSearchExecuted" />
-
-
+ Command="{x:Static local:EditTextWindow.DefaultWebSearchCmd}"
+ Executed="DefaultWebSearchExecuted" />
@@ -269,21 +261,10 @@
Click="FindAndReplaceMenuItem_Click"
Header="Find and Replace" />
-
-
-
+ x:Name="DefaultWebSearch"
+ Command="{x:Static local:EditTextWindow.DefaultWebSearchCmd}"
+ Header="Default Web Search" />
+