From 25b13309256bfd7a0cf208283b9414d01f6c5e02 Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Tue, 3 Dec 2024 19:38:20 -0600 Subject: [PATCH 01/11] Search history on QSL related #382 --- Text-Grab/Models/LookupItem.cs | 29 +++++++++- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 64 +++++++++++++++++++++-- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index 3beebb5b..ab5ef78f 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -1,12 +1,23 @@ -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 LookupItemKind Kind { get; set; } = LookupItemKind.Simple; + public LookupItem() { @@ -18,6 +29,20 @@ public LookupItem(string sv, string lv) longValue = lv; } + public LookupItem(HistoryInfo historyInfo) + { + shortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F"); + longValue = historyInfo.TextContent; + HistoryItem = historyInfo; + + if (string.IsNullOrEmpty(historyInfo.ImagePath)) + Kind = LookupItemKind.EditWindow; + else + Kind = LookupItemKind.GrabFrame; + } + + public HistoryInfo? HistoryItem { get; set; } + public override string ToString() => $"{shortValue} {longValue}"; public string ToCSVString() => $"{shortValue},{longValue}"; @@ -32,4 +57,4 @@ public bool Equals(LookupItem? other) return false; } -} \ No newline at end of file +} diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 0b85f879..1980dd42 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -1,4 +1,5 @@ -using Microsoft.Win32; +using Humanizer; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Diagnostics; @@ -13,6 +14,7 @@ using System.Windows.Media; using Text_Grab.Models; using Text_Grab.Properties; +using Text_Grab.Services; using Text_Grab.Utilities; namespace Text_Grab.Views; @@ -362,11 +364,17 @@ private async void PutValueIntoClipboard(KeyboardModifiersDown? keysDown = null) { if (MainDataGrid.ItemsSource is not List lookUpList || lookUpList.FirstOrDefault() is not LookupItem firstLookupItem) + { + EditTextWindow etw = new(SearchBox.Text, false); + etw.Show(); + this.Close(); + WindowUtilities.ShouldShutDown(); return; + } isPuttingValueIn = true; - List selectedLookupItems = new(); + List selectedLookupItems = []; foreach (object item in MainDataGrid.SelectedItems) if (item is LookupItem selectedLookupItem) @@ -375,10 +383,10 @@ private async void PutValueIntoClipboard(KeyboardModifiersDown? keysDown = null) if (selectedLookupItems.Count == 0) selectedLookupItems.Add(firstLookupItem); + bool openedHistoryItemOrLink = false; StringBuilder stringBuilder = new(); - if (keysDown is null) - keysDown = KeyboardExtensions.GetKeyboardModifiersDown(); + keysDown ??= KeyboardExtensions.GetKeyboardModifiersDown(); switch (keysDown) { @@ -414,10 +422,42 @@ private async void PutValueIntoClipboard(KeyboardModifiersDown? keysDown = null) break; default: foreach (LookupItem lItem in selectedLookupItems) - stringBuilder.AppendLine(lItem.longValue); + { + switch (lItem.Kind) + { + case LookupItemKind.EditWindow when lItem.HistoryItem is not null: + { + EditTextWindow editTextWindow = new(lItem.HistoryItem); + editTextWindow.Show(); + openedHistoryItemOrLink = true; + break; + } + case LookupItemKind.GrabFrame when lItem.HistoryItem is not null: + { + GrabFrame gf = new(lItem.HistoryItem); + gf.Show(); + openedHistoryItemOrLink = true; + break; + } + case LookupItemKind.Link: + Process.Start(new ProcessStartInfo(lItem.longValue) { UseShellExecute = true }); + openedHistoryItemOrLink = true; + break; + default: + stringBuilder.AppendLine(lItem.longValue); + break; + } + } break; } + if (openedHistoryItemOrLink) + { + this.Close(); + WindowUtilities.ShouldShutDown(); + return; + } + if (string.IsNullOrEmpty(stringBuilder.ToString())) return; @@ -693,6 +733,8 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) { await ReadCsvFileIntoQuickSimpleLookup(DefaultSettings.LookupFileLocation); + AddHistoryItemsToLookup(); + if (DefaultSettings.TryInsert && !IsFromETW) PasteToggleButton.IsChecked = true; @@ -703,6 +745,18 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) Activate(); SearchBox.Focus(); } + + private void AddHistoryItemsToLookup() + { + List historyItems = Singleton.Instance.GetEditWindows(); + + foreach (HistoryInfo historyItem in historyItems) + { + LookupItem newItem = new(historyItem); + ItemsDictionary.Add(newItem); + } + } + private async Task WriteDataToCSV() { if (!string.IsNullOrWhiteSpace(SearchBox.Text)) From 55d37c7536c4b04e3edd5585c4a19e1e659f0ca8 Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Tue, 3 Dec 2024 19:47:00 -0600 Subject: [PATCH 02/11] Add Grab Frames to QSL Searches too --- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 1980dd42..c5c9f154 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -690,7 +690,7 @@ private async void SearchBox_TextChanged(object sender, TextChangedEventArgs e) List searchArray = SearchBox.Text.ToLower().Split().ToList(); searchArray.Sort(); - List filteredList = new(); + List filteredList = []; foreach (LookupItem lItem in ItemsDictionary) { @@ -748,9 +748,17 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) private void AddHistoryItemsToLookup() { - List historyItems = Singleton.Instance.GetEditWindows(); + List textHistoryItems = Singleton.Instance.GetEditWindows(); - foreach (HistoryInfo historyItem in historyItems) + foreach (HistoryInfo historyItem in textHistoryItems) + { + LookupItem newItem = new(historyItem); + ItemsDictionary.Add(newItem); + } + + List grabFrameHistoryItems = Singleton.Instance.GetRecentGrabs(); + + foreach (HistoryInfo historyItem in grabFrameHistoryItems) { LookupItem newItem = new(historyItem); ItemsDictionary.Add(newItem); From 0a6ccfa750338d88da27b2984c6e5bb8ec7262ec Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Mon, 9 Dec 2024 22:53:27 -0600 Subject: [PATCH 03/11] Better saving experinece --- Text-Grab/Views/QuickSimpleLookup.xaml | 8 ++- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 65 +++++++++++++---------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml b/Text-Grab/Views/QuickSimpleLookup.xaml index c81435af..50a6d6ce 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 @@ @@ -212,7 +213,10 @@ - + diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index c5c9f154..46e24e4e 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -1,4 +1,4 @@ -using Humanizer; +using Microsoft.VisualBasic.FileIO; using Microsoft.Win32; using System; using System.Collections.Generic; @@ -33,6 +33,7 @@ public partial class QuickSimpleLookup : Wpf.Ui.Controls.FluentWindow private int rowCount = 0; private string valueUnderEdit = string.Empty; private static readonly Settings DefaultSettings = AppUtilities.TextGrabSettings; + private List lookupItems = []; #endregion Fields @@ -50,7 +51,7 @@ public QuickSimpleLookup() public bool IsEditingDataGrid { get; set; } = false; public bool IsFromETW { get; set; } = false; - public List ItemsDictionary { get; set; } = new(); + public List ItemsDictionary { get; set; } = []; #endregion Properties @@ -58,20 +59,20 @@ public QuickSimpleLookup() private static LookupItem ParseStringToLookupItem(char splitChar, string row) { - List cells = row.Split(splitChar).ToList(); + List cells = [.. row.Split(splitChar)]; LookupItem newRow = new(); - if (cells.FirstOrDefault() is String firstCell) + if (cells.FirstOrDefault() is string firstCell) newRow.shortValue = firstCell; newRow.longValue = ""; if (cells.Count > 1 && cells[1] is not null) - newRow.longValue = String.Join(" ", cells.Skip(1).ToArray()); + newRow.longValue = string.Join(" ", cells.Skip(1).ToArray()); return newRow; } private static IEnumerable ParseStringToRows(string clipboardContent, bool isCSV = false) { - List rows = clipboardContent.Split(Environment.NewLine).ToList(); + List rows = [.. clipboardContent.Split(Environment.NewLine)]; char splitChar = isCSV ? ',' : '\t'; @@ -100,7 +101,7 @@ private void AddToLookUpResults(char splitChar, string text) MainDataGrid.ItemsSource = null; ItemsDictionary.Add(newItem); - MainDataGrid.ItemsSource = ItemsDictionary; + lookupItems.Add(newItem); UpdateRowCount(); MainDataGrid.ScrollIntoView(ItemsDictionary.LastOrDefault()); @@ -188,9 +189,10 @@ private void FluentWindow_Closed(object sender, EventArgs e) private List GetMainDataGridSelection() { - if (MainDataGrid.SelectedItems is not List selectedItems || selectedItems.Count == 0) + if (MainDataGrid.SelectedItems is not List selectedItems + || selectedItems.Count == 0) { - selectedItems = new List(); + selectedItems = []; if (MainDataGrid.SelectedItem is not LookupItem selectedLookupItem) return selectedItems; @@ -283,12 +285,13 @@ private void ParseBTN_Click(object sender, RoutedEventArgs e) private async void ParseCSVFileMenuItem_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog - Microsoft.Win32.OpenFileDialog dlg = new(); - - // Set filter for file extension and default file extension - dlg.DefaultExt = ".csv"; - dlg.Filter = "Comma Separated Values File (.csv)|*.csv"; - dlg.CheckFileExists = true; + OpenFileDialog dlg = new() + { + // Set filter for file extension and default file extension + DefaultExt = ".csv", + Filter = "Comma Separated Values File (.csv)|*.csv", + CheckFileExists = true + }; bool? result = dlg.ShowDialog(); @@ -310,17 +313,18 @@ private void PasteToggleButton_Checked(object sender, RoutedEventArgs e) private async void PickSaveLocation_Click(object sender, RoutedEventArgs e) { - SaveFileDialog dlg = new(); - - dlg.AddExtension = true; - dlg.DefaultExt = ".csv"; - dlg.InitialDirectory = "C:\\"; - dlg.FileName = "QuickSimpleLookupDataFile.csv"; - dlg.OverwritePrompt = false; + SaveFileDialog dlg = new() + { + AddExtension = true, + DefaultExt = ".csv", + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + FileName = "QuickSimpleLookupDataFile.csv", + OverwritePrompt = false + }; if (!string.IsNullOrEmpty(DefaultSettings.LookupFileLocation)) { - dlg.InitialDirectory = DefaultSettings.LookupFileLocation; + dlg.InitialDirectory = Path.GetDirectoryName(DefaultSettings.LookupFileLocation); dlg.FileName = Path.GetFileName(DefaultSettings.LookupFileLocation); } @@ -596,6 +600,7 @@ private async Task ReadCsvFileIntoQuickSimpleLookup(string csvToOpenPath) PopulateSampleData(); ItemsDictionary.AddRange(ParseStringToRows(contentToParse, true)); + lookupItems = new(ItemsDictionary); MainDataGrid.ItemsSource = null; MainDataGrid.ItemsSource = ItemsDictionary; @@ -618,6 +623,7 @@ private void RowDeleted() if (item is LookupItem selectedLookupItem) { filteredLookupList.Remove(selectedLookupItem); + lookupItems.Remove(selectedLookupItem); ItemsDictionary.Remove(selectedLookupItem); SaveBTN.Visibility = Visibility.Visible; } @@ -687,7 +693,7 @@ private async void SearchBox_TextChanged(object sender, TextChangedEventArgs e) else MainDataGrid.CanUserAddRows = false; - List searchArray = SearchBox.Text.ToLower().Split().ToList(); + List searchArray = [.. SearchBox.Text.ToLower().Split()]; searchArray.Sort(); List filteredList = []; @@ -772,10 +778,7 @@ private async Task WriteDataToCSV() StringBuilder csvContents = new(); - if (MainDataGrid.ItemsSource is not List itemsToSave) - return; - - foreach (LookupItem lookupItem in itemsToSave) + foreach (LookupItem lookupItem in lookupItems) csvContents.AppendLine(lookupItem.ToCSVString()); try @@ -792,5 +795,11 @@ private async Task WriteDataToCSV() System.Windows.Forms.MessageBox.Show($"Failed to save csv file. {ex.Message}"); } } + + private void FluentWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + // Can't do this here because it will close the app before the text can be inserted + // WindowUtilities.ShouldShutDown(); + } #endregion Methods } From 84e3f87b557d1d678d1e64c3970fb37311e6bbc8 Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Tue, 10 Dec 2024 20:16:11 -0600 Subject: [PATCH 04/11] Add icons to QSL to signify what the item is --- Text-Grab/Models/LookupItem.cs | 15 +++++++++++++++ Text-Grab/Views/QuickSimpleLookup.xaml | 21 +++++++++++++++++++++ Text-Grab/Views/QuickSimpleLookup.xaml.cs | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index ab5ef78f..5292b858 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -16,6 +16,21 @@ public class LookupItem : IEquatable 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.Diamond24, + 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.Diamond24, + }; + } + } + public LookupItemKind Kind { get; set; } = LookupItemKind.Simple; public LookupItem() diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml b/Text-Grab/Views/QuickSimpleLookup.xaml index 50a6d6ce..0640a302 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml +++ b/Text-Grab/Views/QuickSimpleLookup.xaml @@ -199,6 +199,27 @@ SelectionChanged="MainDataGrid_SelectionChanged" SelectionUnit="FullRow"> + + + + + + + + + + + + + + + Date: Thu, 12 Dec 2024 22:32:27 -0600 Subject: [PATCH 05/11] change icon of items to copy --- Text-Grab/Models/LookupItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index 5292b858..5ef01d85 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -22,11 +22,11 @@ public Wpf.Ui.Controls.SymbolRegular UiSymbol { return Kind switch { - LookupItemKind.Simple => Wpf.Ui.Controls.SymbolRegular.Diamond24, + 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.Diamond24, + _ => Wpf.Ui.Controls.SymbolRegular.Copy20, }; } } From e0dae86d42cfa8fd3c90427ca48a89b5c78dd75d Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Fri, 13 Dec 2024 22:35:47 -0600 Subject: [PATCH 06/11] Add setting for search history --- Text-Grab/App.config | 3 +++ Text-Grab/Controls/CollapsibleButton.xaml | 11 ++++++++--- Text-Grab/Models/LookupItem.cs | 10 ++++++++-- Text-Grab/Properties/Settings.Designer.cs | 14 ++++++++++++- Text-Grab/Properties/Settings.settings | 3 +++ Text-Grab/Styles/ButtonStyles.xaml | 24 +++++++++++++++-------- Text-Grab/Styles/DataGridStyles.xaml | 12 +++++++++--- Text-Grab/Styles/TextBoxStyles.xaml | 5 +++-- Text-Grab/Views/FullscreenGrab.xaml.cs | 2 +- Text-Grab/Views/QuickSimpleLookup.xaml | 5 +++++ Text-Grab/Views/QuickSimpleLookup.xaml.cs | 23 +++++++++++++++++++++- 11 files changed, 91 insertions(+), 21 deletions(-) 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 5ef01d85..77e8bdef 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -47,7 +47,7 @@ public LookupItem(string sv, string lv) public LookupItem(HistoryInfo historyInfo) { shortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F"); - longValue = historyInfo.TextContent; + longValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100] : historyInfo.TextContent; HistoryItem = historyInfo; if (string.IsNullOrEmpty(historyInfo.ImagePath)) @@ -58,7 +58,13 @@ public LookupItem(HistoryInfo historyInfo) public HistoryInfo? HistoryItem { get; set; } - public override string ToString() => $"{shortValue} {longValue}"; + public override string ToString() + { + if (HistoryItem is not null) + return $"{HistoryItem.CaptureDateTime:F} {HistoryItem.TextContent}"; + + return $"{shortValue} {longValue}"; + } public string ToCSVString() => $"{shortValue},{longValue}"; 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/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 0640a302..bc4d7b2f 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml +++ b/Text-Grab/Views/QuickSimpleLookup.xaml @@ -152,6 +152,11 @@ x:Name="ParseCSVFileMenuItem" Click="ParseCSVFileMenuItem_Click" Header="Add Rows from CSV File..." /> + Date: Fri, 13 Dec 2024 22:47:05 -0600 Subject: [PATCH 07/11] Deleting history item deletes it --- Text-Grab/Models/LookupItem.cs | 3 ++- Text-Grab/Services/HistoryService.cs | 30 ++++++++++++++++++----- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 8 ++++++ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index 77e8bdef..b57b83fc 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -47,7 +47,8 @@ public LookupItem(string sv, string lv) public LookupItem(HistoryInfo historyInfo) { shortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F"); - longValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100] : historyInfo.TextContent; + longValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100] + "…" : historyInfo.TextContent; + HistoryItem = historyInfo; if (string.IsNullOrEmpty(historyInfo.ImagePath)) 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/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 63fb89c1..6acf84a3 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -626,6 +626,14 @@ private void RowDeleted() lookupItems.Remove(selectedLookupItem); ItemsDictionary.Remove(selectedLookupItem); SaveBTN.Visibility = Visibility.Visible; + + if (selectedLookupItem.HistoryItem is null) + continue; + + if (selectedLookupItem.Kind is LookupItemKind.EditWindow) + Singleton.Instance.RemoveTextHistoryItem(selectedLookupItem.HistoryItem); + else if (selectedLookupItem.Kind is LookupItemKind.GrabFrame) + Singleton.Instance.RemoveImageHistoryItem(selectedLookupItem.HistoryItem); } } From 7d5024a9590325af304a78d96df69a2dbd72333b Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Fri, 13 Dec 2024 23:00:47 -0600 Subject: [PATCH 08/11] Fix deleting and editing lookp values --- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 6acf84a3..5beb4a8d 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -32,6 +32,7 @@ public partial class QuickSimpleLookup : Wpf.Ui.Controls.FluentWindow private LookupItem? lastSelection; private int rowCount = 0; private string valueUnderEdit = string.Empty; + private LookupItem? itemUnderEdit; private static readonly Settings DefaultSettings = AppUtilities.TextGrabSettings; private List lookupItems = []; @@ -229,6 +230,7 @@ private void GoToEndOfMainDataGrid() private void MainDataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { IsEditingDataGrid = true; + itemUnderEdit = e.Row.Item as LookupItem; } private void MainDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) @@ -236,7 +238,27 @@ private void MainDataGrid_CellEditEnding(object sender, DataGridCellEditEndingEv IsEditingDataGrid = false; if (e.EditAction == DataGridEditAction.Cancel) + { + itemUnderEdit = null; return; + } + + LookupItem? editedRow = e.Row.Item as LookupItem; + int prevIndex = -1; + + if (itemUnderEdit is not null) + { + prevIndex = lookupItems.IndexOf(itemUnderEdit); + lookupItems.Remove(itemUnderEdit); + } + + if (editedRow is not null) + { + if (prevIndex > -1) + lookupItems.Insert(prevIndex, editedRow); + else + lookupItems.Add(editedRow); + } DependencyObject child = VisualTreeHelper.GetChild(e.EditingElement, 0); if (child is TextBox editedBox From 31bc59a9eb0e57d7bbe1442dd27e236cf6a36ae0 Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Sat, 14 Dec 2024 15:19:52 -0600 Subject: [PATCH 09/11] Add all text content at once and set the item source once --- Text-Grab/Models/LookupItem.cs | 2 +- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 39 +++++++++++------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index b57b83fc..ecc6a9df 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -47,7 +47,7 @@ public LookupItem(string sv, string lv) public LookupItem(HistoryInfo historyInfo) { shortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F"); - longValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100] + "…" : historyInfo.TextContent; + longValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100].Trim() + "…" : historyInfo.TextContent.Trim(); HistoryItem = historyInfo; diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 5beb4a8d..41c37d4d 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -322,7 +322,7 @@ private async void ParseCSVFileMenuItem_Click(object sender, RoutedEventArgs e) string csvToOpenPath = dlg.FileName; - await ReadCsvFileIntoQuickSimpleLookup(csvToOpenPath); + await LoadDataGridContent(csvToOpenPath); SaveBTN.Visibility = Visibility.Visible; } @@ -362,7 +362,7 @@ private async void PickSaveLocation_Click(object sender, RoutedEventArgs e) { // clear and load the new file ItemsDictionary.Clear(); - await ReadCsvFileIntoQuickSimpleLookup(dlg.FileName); + await LoadDataGridContent(dlg.FileName); } else await WriteDataToCSV(); @@ -371,15 +371,19 @@ private async void PickSaveLocation_Click(object sender, RoutedEventArgs e) private void PopulateSampleData() { LookupItem sampleItem1 = new("This is the key", "This is the value you want to copy quickly"); + sampleItem1.Kind = LookupItemKind.Simple; ItemsDictionary.Add(sampleItem1); LookupItem sampleItem2 = new("Import data", "From a copied Excel table, or import from a CSV File"); + sampleItem2.Kind = LookupItemKind.Simple; ItemsDictionary.Add(sampleItem2); LookupItem sampleItem3 = new("You can change save location", "Putting the data store location in OneDrive it will sync across devices"); + sampleItem3.Kind = LookupItemKind.Simple; ItemsDictionary.Add(sampleItem3); LookupItem sampleItem4 = new("Delete these initial rows", "and add your own manually if you like."); + sampleItem4.Kind = LookupItemKind.Simple; ItemsDictionary.Add(sampleItem4); MainDataGrid.ItemsSource = null; @@ -609,7 +613,7 @@ private async void QuickSimpleLookup_PreviewKeyDown(object sender, KeyEventArgs } } - private async Task ReadCsvFileIntoQuickSimpleLookup(string csvToOpenPath) + private async Task LoadDataGridContent(string csvToOpenPath) { string contentToParse = string.Empty; @@ -621,10 +625,17 @@ private async Task ReadCsvFileIntoQuickSimpleLookup(string csvToOpenPath) if (string.IsNullOrWhiteSpace(contentToParse)) PopulateSampleData(); + MainDataGrid.ItemsSource = null; + ItemsDictionary.AddRange(ParseStringToRows(contentToParse, true)); - lookupItems = new(ItemsDictionary); + lookupItems = [.. ItemsDictionary]; + + if (DefaultSettings.LookupSearchHistory) + { + AddHistoryItemsToItemsDictionary(); + SearchHistory.IsChecked = true; + } - MainDataGrid.ItemsSource = null; MainDataGrid.ItemsSource = ItemsDictionary; UpdateRowCount(); @@ -767,13 +778,7 @@ private void UpdateRowCount() private async void Window_Loaded(object sender, RoutedEventArgs e) { - await ReadCsvFileIntoQuickSimpleLookup(DefaultSettings.LookupFileLocation); - - if (DefaultSettings.LookupSearchHistory) - { - AddHistoryItemsToLookup(); - SearchHistory.IsChecked = true; - } + await LoadDataGridContent(DefaultSettings.LookupFileLocation); if (DefaultSettings.TryInsert && !IsFromETW) PasteToggleButton.IsChecked = true; @@ -786,7 +791,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) SearchBox.Focus(); } - private void AddHistoryItemsToLookup() + private void AddHistoryItemsToItemsDictionary() { List textHistoryItems = Singleton.Instance.GetEditWindows(); @@ -844,13 +849,7 @@ private async void SearchHistory_Click(object sender, RoutedEventArgs e) ItemsDictionary.Clear(); MainDataGrid.ItemsSource = null; - await ReadCsvFileIntoQuickSimpleLookup(DefaultSettings.LookupFileLocation); - - if (DefaultSettings.LookupSearchHistory) - { - AddHistoryItemsToLookup(); - SearchHistory.IsChecked = true; - } + await LoadDataGridContent(DefaultSettings.LookupFileLocation); } #endregion Methods } From 1c311d0434eba12f84ba3b7c356857d6699c181e Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Sun, 15 Dec 2024 21:04:43 -0600 Subject: [PATCH 10/11] Add a right click to QSL --- Text-Grab/Views/QuickSimpleLookup.xaml | 20 ++++++ Text-Grab/Views/QuickSimpleLookup.xaml.cs | 86 ++++++++++++++++++++--- 2 files changed, 97 insertions(+), 9 deletions(-) diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml b/Text-Grab/Views/QuickSimpleLookup.xaml index bc4d7b2f..62ec408d 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml +++ b/Text-Grab/Views/QuickSimpleLookup.xaml @@ -268,6 +268,26 @@ + + + + + + + + + + + + + + diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 41c37d4d..68c1632b 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -370,20 +370,28 @@ private async void PickSaveLocation_Click(object sender, RoutedEventArgs e) private void PopulateSampleData() { - LookupItem sampleItem1 = new("This is the key", "This is the value you want to copy quickly"); - sampleItem1.Kind = LookupItemKind.Simple; + LookupItem sampleItem1 = new("This is the key", "This is the value you want to copy quickly") + { + Kind = LookupItemKind.Simple + }; ItemsDictionary.Add(sampleItem1); - LookupItem sampleItem2 = new("Import data", "From a copied Excel table, or import from a CSV File"); - sampleItem2.Kind = LookupItemKind.Simple; + LookupItem sampleItem2 = new("Import data", "From a copied Excel table, or import from a CSV File") + { + Kind = LookupItemKind.Simple + }; ItemsDictionary.Add(sampleItem2); - LookupItem sampleItem3 = new("You can change save location", "Putting the data store location in OneDrive it will sync across devices"); - sampleItem3.Kind = LookupItemKind.Simple; + LookupItem sampleItem3 = new("You can change save location", "Putting the data store location in OneDrive it will sync across devices") + { + Kind = LookupItemKind.Simple + }; ItemsDictionary.Add(sampleItem3); - LookupItem sampleItem4 = new("Delete these initial rows", "and add your own manually if you like."); - sampleItem4.Kind = LookupItemKind.Simple; + LookupItem sampleItem4 = new("Delete these initial rows", "and add your own manually if you like.") + { + Kind = LookupItemKind.Simple + }; ItemsDictionary.Add(sampleItem4); MainDataGrid.ItemsSource = null; @@ -658,10 +666,12 @@ private void RowDeleted() filteredLookupList.Remove(selectedLookupItem); lookupItems.Remove(selectedLookupItem); ItemsDictionary.Remove(selectedLookupItem); - SaveBTN.Visibility = Visibility.Visible; if (selectedLookupItem.HistoryItem is null) + { + SaveBTN.Visibility = Visibility.Visible; continue; + } if (selectedLookupItem.Kind is LookupItemKind.EditWindow) Singleton.Instance.RemoveTextHistoryItem(selectedLookupItem.HistoryItem); @@ -851,5 +861,63 @@ private async void SearchHistory_Click(object sender, RoutedEventArgs e) await LoadDataGridContent(DefaultSettings.LookupFileLocation); } + + private void DeleteItem_Click(object sender, RoutedEventArgs e) + { + if (MainDataGrid.SelectedItem is not LookupItem lookupItem) + return; + + RowDeleted(); + } + + private void OpenInETWMenuItem_Click(object sender, RoutedEventArgs e) + { + if (MainDataGrid.SelectedItem is not LookupItem lookupItem) + return; + + switch (lookupItem.Kind) + { + case LookupItemKind.Simple: + StringBuilder sb = new(); + sb.Append(lookupItem.shortValue); + sb.Append(Environment.NewLine); + sb.AppendLine(lookupItem.longValue); + EditTextWindow etw = new(sb.ToString(), false); + etw.Show(); + break; + case LookupItemKind.EditWindow: + if (lookupItem.HistoryItem is not null) + { + EditTextWindow editTextWindow = new(lookupItem.HistoryItem); + editTextWindow.Show(); + return; + } + + EditTextWindow etw2 = new(lookupItem.longValue, false); + etw2.Show(); + break; + case LookupItemKind.GrabFrame: + if (lookupItem.HistoryItem is not null) + { + EditTextWindow editTextWindow = new(lookupItem.HistoryItem); + editTextWindow.Show(); + return; + } + + EditTextWindow etw3 = new(lookupItem.longValue, false); + etw3.Show(); + break; + case LookupItemKind.Link: + StringBuilder sb2 = new(); + sb2.Append(lookupItem.shortValue); + sb2.Append(Environment.NewLine); + sb2.AppendLine(lookupItem.longValue); + EditTextWindow etw4 = new(sb2.ToString(), false); + etw4.Show(); + break; + default: + break; + } + } #endregion Methods } From e05bdaaf63fd8bd0502cb754724b71621dc4eb82 Mon Sep 17 00:00:00 2001 From: Joseph Finney Date: Thu, 19 Dec 2024 16:52:30 -0600 Subject: [PATCH 11/11] Rename Lookup items to start uppercase --- Text-Grab/Models/LookupItem.cs | 16 +++++------ Text-Grab/Views/QuickSimpleLookup.xaml | 10 +++---- Text-Grab/Views/QuickSimpleLookup.xaml.cs | 34 ++++++++++------------- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/Text-Grab/Models/LookupItem.cs b/Text-Grab/Models/LookupItem.cs index ecc6a9df..64102818 100644 --- a/Text-Grab/Models/LookupItem.cs +++ b/Text-Grab/Models/LookupItem.cs @@ -13,8 +13,8 @@ public enum LookupItemKind 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 { @@ -40,14 +40,14 @@ public LookupItem() public LookupItem(string sv, string lv) { - shortValue = sv; - longValue = lv; + ShortValue = sv; + LongValue = lv; } 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(); + ShortValue = historyInfo.CaptureDateTime.Humanize() + Environment.NewLine + historyInfo.CaptureDateTime.ToString("F"); + LongValue = historyInfo.TextContent.Length > 100 ? historyInfo.TextContent[..100].Trim() + "…" : historyInfo.TextContent.Trim(); HistoryItem = historyInfo; @@ -64,10 +64,10 @@ public override string ToString() if (HistoryItem is not null) return $"{HistoryItem.CaptureDateTime:F} {HistoryItem.TextContent}"; - return $"{shortValue} {longValue}"; + return $"{ShortValue} {LongValue}"; } - public string ToCSVString() => $"{shortValue},{longValue}"; + public string ToCSVString() => $"{ShortValue},{LongValue}"; public bool Equals(LookupItem? other) { diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml b/Text-Grab/Views/QuickSimpleLookup.xaml index 62ec408d..2c11ca67 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml +++ b/Text-Grab/Views/QuickSimpleLookup.xaml @@ -221,7 +221,7 @@ + Text="{Binding ShortValue}" /> @@ -234,7 +234,7 @@ - + @@ -242,7 +242,7 @@ + Text="{Binding ShortValue}" /> @@ -255,7 +255,7 @@ - + @@ -263,7 +263,7 @@ + Text="{Binding LongValue}" /> diff --git a/Text-Grab/Views/QuickSimpleLookup.xaml.cs b/Text-Grab/Views/QuickSimpleLookup.xaml.cs index 68c1632b..c072593b 100644 --- a/Text-Grab/Views/QuickSimpleLookup.xaml.cs +++ b/Text-Grab/Views/QuickSimpleLookup.xaml.cs @@ -1,5 +1,4 @@ -using Microsoft.VisualBasic.FileIO; -using Microsoft.Win32; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Diagnostics; @@ -19,9 +18,6 @@ namespace Text_Grab.Views; -/// -/// Interaction logic for QuickSimpleLookup.xaml -/// public partial class QuickSimpleLookup : Wpf.Ui.Controls.FluentWindow { #region Fields @@ -63,11 +59,11 @@ private static LookupItem ParseStringToLookupItem(char splitChar, string row) List cells = [.. row.Split(splitChar)]; LookupItem newRow = new(); if (cells.FirstOrDefault() is string firstCell) - newRow.shortValue = firstCell; + newRow.ShortValue = firstCell; - newRow.longValue = ""; + newRow.LongValue = ""; if (cells.Count > 1 && cells[1] is not null) - newRow.longValue = string.Join(" ", cells.Skip(1).ToArray()); + newRow.LongValue = string.Join(" ", cells.Skip(1).ToArray()); return newRow; } @@ -443,16 +439,16 @@ private async void PutValueIntoClipboard(KeyboardModifiersDown? keysDown = null) if (selectedLookupItems.FirstOrDefault() is not LookupItem lookupItem) return; - if (Uri.TryCreate(lookupItem.longValue, UriKind.Absolute, out Uri? uri)) + if (Uri.TryCreate(lookupItem.LongValue, UriKind.Absolute, out Uri? uri)) { - Process.Start(new ProcessStartInfo(lookupItem.longValue) { UseShellExecute = true }); + Process.Start(new ProcessStartInfo(lookupItem.LongValue) { UseShellExecute = true }); this.Close(); return; } break; case KeyboardModifiersDown.Ctrl: foreach (LookupItem lItem in selectedLookupItems) - stringBuilder.AppendLine(lItem.shortValue); + stringBuilder.AppendLine(lItem.ShortValue); break; case KeyboardModifiersDown.Shift: foreach (LookupItem lItem in selectedLookupItems) @@ -478,11 +474,11 @@ private async void PutValueIntoClipboard(KeyboardModifiersDown? keysDown = null) break; } case LookupItemKind.Link: - Process.Start(new ProcessStartInfo(lItem.longValue) { UseShellExecute = true }); + Process.Start(new ProcessStartInfo(lItem.LongValue) { UseShellExecute = true }); openedHistoryItemOrLink = true; break; default: - stringBuilder.AppendLine(lItem.longValue); + stringBuilder.AppendLine(lItem.LongValue); break; } } @@ -879,9 +875,9 @@ private void OpenInETWMenuItem_Click(object sender, RoutedEventArgs e) { case LookupItemKind.Simple: StringBuilder sb = new(); - sb.Append(lookupItem.shortValue); + sb.Append(lookupItem.ShortValue); sb.Append(Environment.NewLine); - sb.AppendLine(lookupItem.longValue); + sb.AppendLine(lookupItem.LongValue); EditTextWindow etw = new(sb.ToString(), false); etw.Show(); break; @@ -893,7 +889,7 @@ private void OpenInETWMenuItem_Click(object sender, RoutedEventArgs e) return; } - EditTextWindow etw2 = new(lookupItem.longValue, false); + EditTextWindow etw2 = new(lookupItem.LongValue, false); etw2.Show(); break; case LookupItemKind.GrabFrame: @@ -904,14 +900,14 @@ private void OpenInETWMenuItem_Click(object sender, RoutedEventArgs e) return; } - EditTextWindow etw3 = new(lookupItem.longValue, false); + EditTextWindow etw3 = new(lookupItem.LongValue, false); etw3.Show(); break; case LookupItemKind.Link: StringBuilder sb2 = new(); - sb2.Append(lookupItem.shortValue); + sb2.Append(lookupItem.ShortValue); sb2.Append(Environment.NewLine); - sb2.AppendLine(lookupItem.longValue); + sb2.AppendLine(lookupItem.LongValue); EditTextWindow etw4 = new(sb2.ToString(), false); etw4.Show(); break;