Skip to content

Commit

Permalink
Add default search to ButtonInfo and FSG
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJoeFin committed Dec 20, 2024
1 parent f859c11 commit 8d8672e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 62 deletions.
28 changes: 2 additions & 26 deletions Text-Grab/Models/ButtonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions Text-Grab/Views/EditTextWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public static Dictionary<string, RoutedCommand> GetRoutedCommands()
{nameof(OcrPasteCommand), OcrPasteCommand},
{nameof(MakeQrCodeCmd), MakeQrCodeCmd},
{nameof(WebSearchCmd), WebSearchCmd},
{nameof(DefaultWebSearchCmd), DefaultWebSearchCmd},
};
}

Expand Down
40 changes: 18 additions & 22 deletions Text-Grab/Views/FullscreenGrab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@
Height="34"
Margin="4,0,2,0"
Click="FreezeMenuItem_Click"
IsChecked="{Binding IsChecked, ElementName=FreezeMenuItem, Mode=TwoWay}"
IsChecked="{Binding IsChecked,
ElementName=FreezeMenuItem,
Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}"
ToolTip="(F) Freeze what is on screens">
<wpfui:SymbolIcon Symbol="Pause24" />
Expand Down Expand Up @@ -191,7 +193,9 @@
Margin="0"
d:IsChecked="True"
Click="SingleLineMenuItem_Click"
IsChecked="{Binding IsChecked, ElementName=SingleLineMenuItem, Mode=TwoWay}"
IsChecked="{Binding IsChecked,
ElementName=SingleLineMenuItem,
Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}"
ToolTip="(S) Make result a single line">
<wpfui:SymbolIcon Symbol="SubtractSquare24" />
Expand All @@ -203,7 +207,9 @@
Margin="0"
d:IsChecked="True"
Click="TableToggleButton_Click"
IsChecked="{Binding IsChecked, ElementName=TableMenuItem, Mode=TwoWay}"
IsChecked="{Binding IsChecked,
ElementName=TableMenuItem,
Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}"
ToolTip="(T) OCR text as a table">
<wpfui:SymbolIcon Symbol="Table24" />
Expand All @@ -215,7 +221,9 @@
Margin="0"
d:IsChecked="True"
Click="NewGrabFrameMenuItem_Click"
IsChecked="{Binding IsChecked, ElementName=NewGrabFrameMenuItem, Mode=TwoWay}"
IsChecked="{Binding IsChecked,
ElementName=NewGrabFrameMenuItem,
Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}"
ToolTip="(G) Place a Grab Frame">
<wpfui:SymbolIcon Symbol="PanelBottom20" />
Expand Down Expand Up @@ -258,31 +266,17 @@
IsCheckable="True"
StaysOpenOnClick="False" />
<MenuItem
Name="BingSearchPostCapture"
Name="WebSearchPostCapture"
Click="PostActionMenuItem_Click"
Header="Bing Search"
Header="Web Search"
InputGestureText="CTRL + 4"
IsCheckable="True"
StaysOpenOnClick="False" />
<MenuItem
Name="GoogleSearchPostCapture"
Click="PostActionMenuItem_Click"
Header="Google Search"
InputGestureText="CTRL + 5"
IsCheckable="True"
StaysOpenOnClick="False" />
<MenuItem
Name="DuckSearchPostCapture"
Click="PostActionMenuItem_Click"
Header="Duck Duck Go Search"
InputGestureText="CTRL + 6"
IsCheckable="True"
StaysOpenOnClick="False" />
<MenuItem
Name="InsertPostCapture"
Click="PostActionMenuItem_Click"
Header="Try to insert text"
InputGestureText="CTRL + 7"
InputGestureText="CTRL + 5"
IsCheckable="True"
StaysOpenOnClick="False" />
</ContextMenu>
Expand All @@ -295,7 +289,9 @@
Margin="2,0"
d:IsChecked="True"
Click="SendToEditTextToggleButton_Click"
IsChecked="{Binding IsChecked, ElementName=SendToEtwMenuItem, Mode=TwoWay}"
IsChecked="{Binding IsChecked,
ElementName=SendToEtwMenuItem,
Mode=TwoWay}"
Style="{StaticResource ToggleSymbolButton}"
ToolTip="(E) Send to an Edit Text Window">
<wpfui:SymbolIcon Symbol="Window24" />
Expand Down
20 changes: 6 additions & 14 deletions Text-Grab/Views/FullscreenGrab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,27 +698,19 @@ private async void RegionClickCanvas_MouseUp(object sender, MouseButtonEventArgs
if (RemoveDuplicatesMenuItem.IsChecked is true)
TextFromOCR = TextFromOCR.RemoveDuplicateLines();

if (BingSearchPostCapture.IsChecked is true)
if (WebSearchPostCapture.IsChecked is true)
{
string searchStringUrlSafe = WebUtility.UrlEncode(TextFromOCR.MakeStringSingleLine());
_ = await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format($"https://www.bing.com/search?q={searchStringUrlSafe}")));
}
string searchStringUrlSafe = WebUtility.UrlEncode(TextFromOCR);

if (GoogleSearchPostCapture.IsChecked is true)
{
string searchStringUrlSafe = WebUtility.UrlEncode(TextFromOCR.MakeStringSingleLine());
_ = await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format($"https://www.google.com/search?q={searchStringUrlSafe}")));
}
WebSearchUrlModel searcher = Singleton<WebSearchUrlModel>.Instance.DefaultSearcher;

if (DuckSearchPostCapture.IsChecked is true)
{
string searchStringUrlSafe = WebUtility.UrlEncode(TextFromOCR.MakeStringSingleLine());
_ = await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format($"https://duckduckgo.com/?va=d&t=he&q={searchStringUrlSafe}&ia=web")));
Uri searchUri = new($"{searcher.Url}{searchStringUrlSafe}");
_ = await Windows.System.Launcher.LaunchUriAsync(searchUri);
}

if (SendToEditTextToggleButton.IsChecked is true
&& destinationTextBox is null
&& BingSearchPostCapture.IsChecked is false)
&& WebSearchPostCapture.IsChecked is false)
{
EditTextWindow etw = WindowUtilities.OpenOrActivateWindow<EditTextWindow>();
destinationTextBox = etw.PassedTextControl;
Expand Down

0 comments on commit 8d8672e

Please sign in to comment.