diff --git a/Text-Grab/App.config b/Text-Grab/App.config
index 646b884d..d6361c43 100644
--- a/Text-Grab/App.config
+++ b/Text-Grab/App.config
@@ -148,6 +148,12 @@
True
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Text-Grab/Models/WebSearchUrlModel.cs b/Text-Grab/Models/WebSearchUrlModel.cs
index f39bb7d6..ef59bbbc 100644
--- a/Text-Grab/Models/WebSearchUrlModel.cs
+++ b/Text-Grab/Models/WebSearchUrlModel.cs
@@ -1,25 +1,97 @@
using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using Text_Grab.Utilities;
namespace Text_Grab.Models;
public record WebSearchUrlModel
{
- public required string Name { get; set; }
- public required string Url { get; set; }
+ public string Name { get; set; } = string.Empty;
+ public string Url { get; set; } = string.Empty;
+ private WebSearchUrlModel? defaultSearcher;
- public static List GetDefaultWebSearchUrls()
+ public WebSearchUrlModel DefaultSearcher
+ {
+ get
+ {
+ defaultSearcher ??= GetDefaultSearcher();
+ return defaultSearcher;
+ }
+ set
+ {
+ defaultSearcher = value;
+ SaveDefaultSearcher(defaultSearcher);
+ }
+ }
+
+
+ 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 = "Yahoo", Url = "https://search.yahoo.com/search?p=" },
- new() { Name = "Yandex", Url = "https://yandex.com/search/?text=" },
- new() { Name = "Baidu", Url = "https://www.baidu.com/s?wd=" },
+ 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/Properties/Settings.Designer.cs b/Text-Grab/Properties/Settings.Designer.cs
index 2e79afb9..d5a18153 100644
--- a/Text-Grab/Properties/Settings.Designer.cs
+++ b/Text-Grab/Properties/Settings.Designer.cs
@@ -586,5 +586,29 @@ public bool LookupSearchHistory {
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 99ca662d..a9a2887f 100644
--- a/Text-Grab/Properties/Settings.settings
+++ b/Text-Grab/Properties/Settings.settings
@@ -143,5 +143,11 @@
True
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Text-Grab/Utilities/CustomBottomBarUtilities.cs b/Text-Grab/Utilities/CustomBottomBarUtilities.cs
index 59814293..840993f5 100644
--- a/Text-Grab/Utilities/CustomBottomBarUtilities.cs
+++ b/Text-Grab/Utilities/CustomBottomBarUtilities.cs
@@ -27,7 +27,8 @@ public static List GetCustomBottomBarItemsSetting()
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,7 +38,6 @@ public static List GetCustomBottomBarItemsSetting()
buttonInfo.SymbolIcon = buttonDictionary[buttonInfo.ButtonText];
}
-
return customBottomBarItems;
}
diff --git a/Text-Grab/Views/EditTextWindow.xaml b/Text-Grab/Views/EditTextWindow.xaml
index 0e4f1a29..f741192a 100644
--- a/Text-Grab/Views/EditTextWindow.xaml
+++ b/Text-Grab/Views/EditTextWindow.xaml
@@ -131,6 +131,10 @@
CanExecute="IsolateSelectionCmdCanExecute"
Command="{x:Static local:EditTextWindow.WebSearchCmd}"
Executed="WebSearchExecuted" />
+
@@ -256,7 +260,10 @@
x:Name="FindAndReplaceMenuItem"
Click="FindAndReplaceMenuItem_Click"
Header="Find and Replace" />
-
+