diff --git a/Text-Grab/App.config b/Text-Grab/App.config
index f852fa6e..646b884d 100644
--- a/Text-Grab/App.config
+++ b/Text-Grab/App.config
@@ -145,6 +145,9 @@
Resize
+
+ True
+
\ No newline at end of file
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/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/Properties/Settings.Designer.cs b/Text-Grab/Properties/Settings.Designer.cs
index 95b517f6..2e79afb9 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,17 @@ 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;
+ }
+ }
}
}
diff --git a/Text-Grab/Properties/Settings.settings b/Text-Grab/Properties/Settings.settings
index fc262f6b..99ca662d 100644
--- a/Text-Grab/Properties/Settings.settings
+++ b/Text-Grab/Properties/Settings.settings
@@ -140,5 +140,8 @@
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/Views/FullscreenGrab.xaml.cs b/Text-Grab/Views/FullscreenGrab.xaml.cs
index 72bc321c..877dc742 100644
--- a/Text-Grab/Views/FullscreenGrab.xaml.cs
+++ b/Text-Grab/Views/FullscreenGrab.xaml.cs
@@ -40,7 +40,7 @@ public partial class FullscreenGrab : Window
private double xShiftDelta;
private double yShiftDelta;
private HistoryInfo? historyInfo;
- private bool usingTesseract;
+ private readonly bool usingTesseract;
private static readonly Settings DefaultSettings = AppUtilities.TextGrabSettings;
#endregion Fields
diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml b/Text-Grab/Views/QuickSimpleLookup.xaml
index c81435af..2c11ca67 100644
--- a/Text-Grab/Views/QuickSimpleLookup.xaml
+++ b/Text-Grab/Views/QuickSimpleLookup.xaml
@@ -11,6 +11,7 @@
Width="800"
Height="400"
Closed="FluentWindow_Closed"
+ Closing="FluentWindow_Closing"
Loaded="Window_Loaded"
PreviewKeyDown="QuickSimpleLookup_PreviewKeyDown"
Topmost="True"
@@ -23,7 +24,7 @@
@@ -151,6 +152,11 @@
x:Name="ParseCSVFileMenuItem"
Click="ParseCSVFileMenuItem_Click"
Header="Add Rows from CSV File..." />
+