diff --git a/JL.Core/Anki/JLField.cs b/JL.Core/Anki/JLField.cs index 02043db1..652e3748 100644 --- a/JL.Core/Anki/JLField.cs +++ b/JL.Core/Anki/JLField.cs @@ -19,6 +19,12 @@ public enum JLField [Description("EDICT ID")] EdictId, [Description("Local Time")] LocalTime, Frequencies, + [Description("Raw Frequencies")] RawFrequencies, + + // JMdict + [Description("Primary Spelling with Orthography Info")] PrimarySpellingWithOrthographyInfo, + [Description("Readings with Orthography Info")] ReadingsWithOrthographyInfo, + [Description("Alternative Spellings with Orthography Info")] AlternativeSpellingsWithOrthographyInfo, // Word dictionaries [Description("Deconjugated Matched Text")] DeconjugatedMatchedText, diff --git a/JL.Core/Anki/JLFieldUtils.cs b/JL.Core/Anki/JLFieldUtils.cs index 4c8e7101..672454f9 100644 --- a/JL.Core/Anki/JLFieldUtils.cs +++ b/JL.Core/Anki/JLFieldUtils.cs @@ -5,8 +5,11 @@ public static class JLFieldUtils public static readonly JLField[] JLFieldsForWordDicts = { JLField.Nothing, JLField.PrimarySpelling, + JLField.PrimarySpellingWithOrthographyInfo, JLField.AlternativeSpellings, + JLField.AlternativeSpellingsWithOrthographyInfo, JLField.Readings, + JLField.ReadingsWithOrthographyInfo, JLField.Definitions, JLField.DictionaryName, JLField.Audio, @@ -17,6 +20,7 @@ public static class JLFieldUtils JLField.DeconjugatedMatchedText, JLField.DeconjugationProcess, JLField.Frequencies, + JLField.RawFrequencies, JLField.EdictId, JLField.LocalTime }; @@ -38,6 +42,7 @@ public static class JLFieldUtils JLField.SourceText, JLField.Sentence, JLField.Frequencies, + JLField.RawFrequencies, JLField.EdictId, JLField.LocalTime }; diff --git a/JL.Core/Anki/Mining.cs b/JL.Core/Anki/Mining.cs index 77d35e54..b70f09e3 100644 --- a/JL.Core/Anki/Mining.cs +++ b/JL.Core/Anki/Mining.cs @@ -1,6 +1,7 @@ using System.Globalization; using JL.Core.Audio; using JL.Core.Dicts; +using JL.Core.Lookup; using JL.Core.Network; using JL.Core.Utilities; @@ -8,49 +9,34 @@ namespace JL.Core.Anki; public static class Mining { - public static async Task Mine(Dictionary miningParams) + public static async Task Mine(Dictionary miningParams, LookupResult lookupResult) { - string primarySpelling = miningParams[JLField.PrimarySpelling]; - - Dictionary? ankiConfigDict = await AnkiConfig.ReadAnkiConfig().ConfigureAwait(false); - - if (ankiConfigDict is null) + if (!CoreConfig.AnkiIntegration) { Utils.Frontend.Alert(AlertLevel.Error, "Please setup mining first in the preferences"); return false; } - AnkiConfig? ankiConfig; - - DictType? dictType = null; - - if (miningParams.TryGetValue(JLField.DictionaryName, out string? dictionaryName)) - { - if (DictUtils.Dicts.TryGetValue(dictionaryName, out Dict? dict)) - { - dictType = dict.Type; - } - } + Dictionary? ankiConfigDict = await AnkiConfig.ReadAnkiConfig().ConfigureAwait(false); - if (dictType is null) + if (ankiConfigDict is null) { - Utils.Frontend.Alert(AlertLevel.Error, string.Create(CultureInfo.InvariantCulture, $"Mining failed for {primarySpelling}. Cannot find the type of {JLField.DictionaryName.GetDescription()}")); - Utils.Logger.Error("Mining failed for {FoundSpelling}. Cannot find the type of {DictionaryName}", primarySpelling, JLField.DictionaryName.GetDescription()); + Utils.Frontend.Alert(AlertLevel.Error, "Please setup mining first in the preferences"); return false; } - - if (DictUtils.s_wordDictTypes.Contains(dictType.Value)) + AnkiConfig? ankiConfig; + if (DictUtils.s_wordDictTypes.Contains(lookupResult.Dict.Type)) { _ = ankiConfigDict.TryGetValue(MineType.Word, out ankiConfig); } - else if (DictUtils.s_kanjiDictTypes.Contains(dictType.Value)) + else if (DictUtils.s_kanjiDictTypes.Contains(lookupResult.Dict.Type)) { _ = ankiConfigDict.TryGetValue(MineType.Kanji, out ankiConfig); } - else if (DictUtils.s_nameDictTypes.Contains(dictType.Value)) + else if (DictUtils.s_nameDictTypes.Contains(lookupResult.Dict.Type)) { _ = ankiConfigDict.TryGetValue(MineType.Name, out ankiConfig); } @@ -66,20 +52,13 @@ public static async Task Mine(Dictionary miningParams) return false; } - // idk if this gets the right audio for every word - string? reading = miningParams.GetValueOrDefault(JLField.Readings)?.Split(',')[0]; - if (string.IsNullOrEmpty(reading)) - { - reading = primarySpelling; - } - Dictionary userFields = ankiConfig.Fields; - Dictionary fields = ConvertFields(userFields, miningParams); - List audioFields = FindFields(JLField.Audio, userFields); bool needsAudio = audioFields.Count > 0; + string reading = lookupResult.Readings?[0] ?? lookupResult.PrimarySpelling; + AudioResponse? audioResponse = needsAudio - ? await AudioUtils.GetPrioritizedAudio(primarySpelling, reading).ConfigureAwait(false) + ? await AudioUtils.GetPrioritizedAudio(lookupResult.PrimarySpelling, reading).ConfigureAwait(false) : null; byte[]? audioData = audioResponse?.AudioData; @@ -98,7 +77,7 @@ public static async Task Mine(Dictionary miningParams) : new Dictionary(4) { { "data", audioData }, - { "filename", string.Create(CultureInfo.InvariantCulture, $"JL_audio_{reading}_{primarySpelling}.{audioResponse!.AudioFormat}") }, + { "filename", string.Create(CultureInfo.InvariantCulture, $"JL_audio_{reading}_{lookupResult.PrimarySpelling}.{audioResponse!.AudioFormat}") }, { "skipHash", Networking.Jpod101NoAudioMd5Hash }, { "fields", audioFields } }; @@ -114,7 +93,7 @@ public static async Task Mine(Dictionary miningParams) : new Dictionary(3) { { "data", imageBytes }, - { "filename", string.Create(CultureInfo.InvariantCulture, $"JL_image_{reading}_{primarySpelling}.png") }, + { "filename", string.Create(CultureInfo.InvariantCulture, $"JL_image_{reading}_{lookupResult.PrimarySpelling}.png") }, { "fields", imageFields } }; @@ -123,26 +102,28 @@ public static async Task Mine(Dictionary miningParams) { "allowDuplicate", CoreConfig.AllowDuplicateCards } }; + Dictionary fields = ConvertFields(userFields, miningParams); + Note note = new(ankiConfig.DeckName, ankiConfig.ModelName, fields, options, ankiConfig.Tags, audio, null, image); Response? response = await AnkiConnect.AddNoteToDeck(note).ConfigureAwait(false); if (response is null) { - Utils.Frontend.Alert(AlertLevel.Error, string.Create(CultureInfo.InvariantCulture, $"Mining failed for {primarySpelling}")); - Utils.Logger.Error("Mining failed for {FoundSpelling}", primarySpelling); + Utils.Frontend.Alert(AlertLevel.Error, string.Create(CultureInfo.InvariantCulture, $"Mining failed for {lookupResult.PrimarySpelling}")); + Utils.Logger.Error("Mining failed for {FoundSpelling}", lookupResult.PrimarySpelling); return false; } if (needsAudio && (audioData is null || Utils.GetMd5String(audioData) is Networking.Jpod101NoAudioMd5Hash)) { - Utils.Frontend.Alert(AlertLevel.Warning, string.Create(CultureInfo.InvariantCulture, $"Mined {primarySpelling} (no audio)")); - Utils.Logger.Information("Mined {FoundSpelling} (no audio)", primarySpelling); + Utils.Frontend.Alert(AlertLevel.Warning, string.Create(CultureInfo.InvariantCulture, $"Mined {lookupResult.PrimarySpelling} (no audio)")); + Utils.Logger.Information("Mined {FoundSpelling} (no audio)", lookupResult.PrimarySpelling); } else { - Utils.Frontend.Alert(AlertLevel.Success, string.Create(CultureInfo.InvariantCulture, $"Mined {primarySpelling}")); - Utils.Logger.Information("Mined {FoundSpelling}", primarySpelling); + Utils.Frontend.Alert(AlertLevel.Success, string.Create(CultureInfo.InvariantCulture, $"Mined {lookupResult.PrimarySpelling}")); + Utils.Logger.Information("Mined {FoundSpelling}", lookupResult.PrimarySpelling); } if (CoreConfig.ForceSyncAnki) diff --git a/JL.Core/CoreConfig.cs b/JL.Core/CoreConfig.cs index ffcfe346..7b946aee 100644 --- a/JL.Core/CoreConfig.cs +++ b/JL.Core/CoreConfig.cs @@ -4,6 +4,7 @@ public static class CoreConfig { public static Uri AnkiConnectUri { get; set; } = new("http://127.0.0.1:8765"); public static bool KanjiMode { get; set; } = false; + public static bool AnkiIntegration { get; set; } = false; public static bool ForceSyncAnki { get; set; } = false; public static bool AllowDuplicateCards { get; set; } = false; public static int LookupRate { get; set; } = 0; diff --git a/JL.Core/Dicts/EDICT/JMdict/JmdictLoader.cs b/JL.Core/Dicts/EDICT/JMdict/JmdictLoader.cs index 405e3590..40e01c56 100644 --- a/JL.Core/Dicts/EDICT/JMdict/JmdictLoader.cs +++ b/JL.Core/Dicts/EDICT/JMdict/JmdictLoader.cs @@ -289,7 +289,7 @@ private static Sense ReadSense(XmlTextReader xmlReader) { lang = CultureInfo.GetCultureInfo(lang).EnglishName; } - catch (Exception ex) + catch (CultureNotFoundException ex) { Utils.Logger.Error(ex, "Underlying OS cannot process the culture info"); s_canHandleCulture = false; diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index c855150b..946c904a 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -23,7 +23,7 @@ internal static class ConfigManager #region General private static readonly ComboBoxItem[] s_japaneseFonts = - WindowsUtils.FindJapaneseFonts().OrderByDescending(static f => f.Foreground.ToString(CultureInfo.InvariantCulture)).ThenBy(static font => font.Content) + WindowsUtils.FindJapaneseFonts().OrderBy(static f => f.Foreground == Brushes.DimGray).ThenBy(static font => font.Content) .ToArray(); private static readonly ComboBoxItem[] s_popupJapaneseFonts = @@ -125,12 +125,6 @@ internal static class ConfigManager #endregion - #region Anki - - public static bool AnkiIntegration { get; set; } = false; - - #endregion - #region Hotkeys public static KeyGesture DisableHotkeysKeyGesture { get; private set; } = new(Key.Pause, ModifierKeys.Alt); @@ -281,7 +275,7 @@ public static void ApplyPreferences() WinApi.PreventActivation(mainWindow.WindowHandle); } - AnkiIntegration = GetValueFromConfig(config, AnkiIntegration, nameof(AnkiIntegration), bool.TryParse); + CoreConfig.AnkiIntegration = GetValueFromConfig(config, CoreConfig.AnkiIntegration, nameof(CoreConfig.AnkiIntegration), bool.TryParse); CoreConfig.KanjiMode = GetValueFromConfig(config, CoreConfig.KanjiMode, nameof(CoreConfig.KanjiMode), bool.TryParse); CoreConfig.ForceSyncAnki = GetValueFromConfig(config, CoreConfig.ForceSyncAnki, nameof(CoreConfig.ForceSyncAnki), bool.TryParse); CoreConfig.AllowDuplicateCards = GetValueFromConfig(config, CoreConfig.AllowDuplicateCards, nameof(CoreConfig.AllowDuplicateCards), bool.TryParse); @@ -833,7 +827,7 @@ public static void LoadPreferences(PreferencesWindow preferenceWindow) preferenceWindow.DisableHotkeysCheckBox.IsChecked = DisableHotkeys; preferenceWindow.FocusableCheckBox.IsChecked = Focusable; preferenceWindow.TextOnlyVisibleOnHoverCheckBox.IsChecked = TextOnlyVisibleOnHover; - preferenceWindow.AnkiIntegrationCheckBox.IsChecked = AnkiIntegration; + preferenceWindow.AnkiIntegrationCheckBox.IsChecked = CoreConfig.AnkiIntegration; preferenceWindow.LookupRateNumericUpDown.Value = CoreConfig.LookupRate; preferenceWindow.MainWindowDynamicWidthCheckBox.IsChecked = MainWindowDynamicWidth; @@ -1140,7 +1134,7 @@ public static async Task SavePreferences(PreferencesWindow preferenceWindow) settings[nameof(TextOnlyVisibleOnHover)].Value = preferenceWindow.TextOnlyVisibleOnHoverCheckBox.IsChecked.ToString(); - settings[nameof(AnkiIntegration)].Value = + settings[nameof(CoreConfig.AnkiIntegration)].Value = preferenceWindow.AnkiIntegrationCheckBox.IsChecked.ToString(); settings[nameof(HighlightColor)].Value = preferenceWindow.HighlightColorButton.Tag.ToString(); diff --git a/JL.Windows/GUI/AddNameWindow.xaml.cs b/JL.Windows/GUI/AddNameWindow.xaml.cs index a14e247c..f1bf65d4 100644 --- a/JL.Windows/GUI/AddNameWindow.xaml.cs +++ b/JL.Windows/GUI/AddNameWindow.xaml.cs @@ -66,7 +66,7 @@ private async void SaveButton_Click(object? sender, RoutedEventArgs? e) string? extraInfo = ExtraInfoTextBox.Text.Replace("\t", " ", StringComparison.Ordinal).Trim(); if (extraInfo.Length is 0) { - reading = null; + extraInfo = null; } DictType dictType = ComboBoxDictType.SelectedValue.ToString() is "Global" @@ -80,6 +80,7 @@ private async void SaveButton_Click(object? sender, RoutedEventArgs? e) Utils.Frontend.InvalidateDisplayCache(); } + PopupWindowUtils.HidePopups(MainWindow.Instance.FirstPopupWindow); Close(); string path = Path.GetFullPath(dict.Path, Utils.ApplicationPath); @@ -90,7 +91,6 @@ private async void SaveButton_Click(object? sender, RoutedEventArgs? e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { - WindowsUtils.HidePopups(MainWindow.Instance.FirstPopupWindow); WindowsUtils.UpdateMainWindowVisibility(); _ = MainWindow.Instance.Focus(); s_instance = null; @@ -103,10 +103,14 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { _ = SpellingTextBox.Focus(); } - else // if (string.IsNullOrEmpty(ReadingTextBox.Text)) + else if (string.IsNullOrEmpty(ReadingTextBox.Text)) { _ = ReadingTextBox.Focus(); } + else // if (string.IsNullOrEmpty(ExtraInfoTextBox.Text)) + { + _ = ExtraInfoTextBox.Focus(); + } } private void Window_PreviewKeyUp(object sender, KeyEventArgs e) diff --git a/JL.Windows/GUI/AddWordWindow.xaml.cs b/JL.Windows/GUI/AddWordWindow.xaml.cs index 38f05465..7d7794de 100644 --- a/JL.Windows/GUI/AddWordWindow.xaml.cs +++ b/JL.Windows/GUI/AddWordWindow.xaml.cs @@ -95,6 +95,7 @@ private async void SaveButton_Click(object? sender, RoutedEventArgs? e) Utils.Frontend.InvalidateDisplayCache(); } + PopupWindowUtils.HidePopups(MainWindow.Instance.FirstPopupWindow); Close(); string line = string.IsNullOrWhiteSpace(rawWordClasses) @@ -108,7 +109,6 @@ private async void SaveButton_Click(object? sender, RoutedEventArgs? e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { - WindowsUtils.HidePopups(MainWindow.Instance.FirstPopupWindow); WindowsUtils.UpdateMainWindowVisibility(); _ = MainWindow.Instance.Focus(); s_instance = null; diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index 9e184da5..0512b9a8 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -194,7 +194,7 @@ private void HandlePostCopy(string text) TitleBarContextMenu.IsOpen = false; MainTextBoxContextMenu.IsOpen = false; - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); }, DispatcherPriority.Send); if (ConfigManager.AlwaysOnTop @@ -414,7 +414,7 @@ private void OpacityButton_MouseDown(object sender, MouseButtonEventArgs e) } else if (e.ChangedButton is MouseButton.Right) { - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); } } @@ -437,7 +437,7 @@ private void FontSizeButton_MouseDown(object sender, MouseButtonEventArgs e) } else if (e.ChangedButton is MouseButton.Right) { - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); } } @@ -712,7 +712,7 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) { handled = true; - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); if (ConfigManager.Focusable) { @@ -875,7 +875,7 @@ private void AddName(object sender, RoutedEventArgs e) ShowAddNameWindow(); } - private void ShowAddNameWindow() + public void ShowAddNameWindow() { string? text = MainTextBox.SelectionLength > 0 ? MainTextBox.SelectedText @@ -888,7 +888,7 @@ private void ShowAddNameWindow() if (text is not null && FirstPopupWindow.LastSelectedText is not null && text == FirstPopupWindow.LastSelectedText) { string[]? readings = FirstPopupWindow.LastLookupResults[0].Readings; - reading = readings is { Length: 1 } + reading = readings?.Length is 1 ? readings[0] : ""; } @@ -906,7 +906,7 @@ private void AddWord(object sender, RoutedEventArgs e) ShowAddWordWindow(); } - private void ShowAddWordWindow() + public void ShowAddWordWindow() { string? text = MainTextBox.SelectionLength > 0 ? MainTextBox.SelectedText @@ -923,6 +923,11 @@ private void ShowPreferences(object sender, RoutedEventArgs e) } private void SearchWithBrowser(object sender, RoutedEventArgs e) + { + SearchWithBrowser(); + } + + public void SearchWithBrowser() { WindowsUtils.SearchWithBrowser(MainTextBox.SelectedText); WindowsUtils.UpdateMainWindowVisibility(); @@ -1032,11 +1037,11 @@ private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e) if (e.ChangedButton == ConfigManager.MiningModeMouseButton && FirstPopupWindow is { IsVisible: true, MiningMode: false }) { e.Handled = true; - PopupWindow.ShowMiningModeResults(FirstPopupWindow); + PopupWindowUtils.ShowMiningModeResults(FirstPopupWindow); } else if (e.ChangedButton is not MouseButton.Right) { - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); } } @@ -1222,7 +1227,7 @@ private void ResizeWindow(object sender, MouseButtonEventArgs e) } else if (e.ChangedButton is MouseButton.Right) { - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); } } @@ -1262,7 +1267,7 @@ private void MainTextBox_ContextMenuOpening(object sender, ContextMenuEventArgs int charIndex = MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), ConfigManager.HorizontallyCenterMainWindowText); ContextMenuIsOpening = charIndex >= MainTextBox.SelectionStart && charIndex <= MainTextBox.SelectionStart + MainTextBox.SelectionLength; - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); if (!ContextMenuIsOpening && MainTextBox.SelectionLength > 0) { @@ -1496,6 +1501,6 @@ private void MainTextBox_PreviewTouchUp(object sender, TouchEventArgs e) private void TitleBar_ContextMenuOpening(object sender, ContextMenuEventArgs e) { - WindowsUtils.HidePopups(FirstPopupWindow); + PopupWindowUtils.HidePopups(FirstPopupWindow); } } diff --git a/JL.Windows/GUI/PopupWindow.xaml b/JL.Windows/GUI/PopupWindow.xaml index 4a2024aa..3ec3e1e5 100644 --- a/JL.Windows/GUI/PopupWindow.xaml +++ b/JL.Windows/GUI/PopupWindow.xaml @@ -40,7 +40,7 @@ VirtualizingPanel.IsVirtualizingWhenGrouping="True" VirtualizingPanel.ScrollUnit="Pixel" BorderThickness="0" ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="True" ScrollViewer.VerticalScrollBarVisibility="Auto" VirtualizingPanel.IsContainerVirtualizable="True" - HorizontalContentAlignment="Stretch" + HorizontalContentAlignment="Stretch" MouseLeave="PopupListView_MouseLeave" Background="{Binding Path=Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" x:Name="PopupListView" Opacity="70"> diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index a5b20895..e3e39a53 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -6,11 +6,9 @@ using System.Windows.Media; using Caching; using JL.Core; -using JL.Core.Anki; using JL.Core.Audio; using JL.Core.Dicts; using JL.Core.Lookup; -using JL.Core.Statistics; using JL.Core.Utilities; using JL.Windows.GUI.UserControls; using JL.Windows.SpeechSynthesis; @@ -28,13 +26,17 @@ internal sealed partial class PopupWindow : Window public PopupWindow? ChildPopupWindow { get; private set; } private bool ContextMenuIsOpening { get; set; } = false; - private TextBox? _lastTextBox; + private TextBox? _previousTextBox; - private int _listBoxIndex; + private TextBox? _lastInteractedTextBox; + + private int _listBoxIndex = 0; + + private int _firstVisibleListBoxIndex = 0; private int _currentCharPosition; - private string? _currentText; + private string _currentText = ""; public string? LastSelectedText { get; private set; } @@ -116,16 +118,30 @@ private void AddName(object sender, RoutedEventArgs e) private void AddWord(object sender, RoutedEventArgs e) { - string text = ChildPopupWindow?._lastTextBox?.SelectionLength > 0 - ? ChildPopupWindow._lastTextBox.SelectedText - : LastLookupResults[MiningMode ? _listBoxIndex : 0].PrimarySpelling; + ShowAddWordWindow(); + } + + private void ShowAddWordWindow() + { + string text = _lastInteractedTextBox?.SelectionLength > 0 + ? _lastInteractedTextBox.SelectedText + : LastLookupResults[_listBoxIndex].PrimarySpelling; WindowsUtils.ShowAddWordWindow(text); } private void SearchWithBrowser(object sender, RoutedEventArgs e) { - WindowsUtils.SearchWithBrowser(LastSelectedText); + SearchWithBrowser(); + } + + private void SearchWithBrowser() + { + string text = _lastInteractedTextBox?.SelectionLength > 0 + ? _lastInteractedTextBox.SelectedText + : LastLookupResults[_listBoxIndex].PrimarySpelling; + + WindowsUtils.SearchWithBrowser(text); } public async Task LookupOnCharPosition(TextBox tb, int charPosition, bool enableMiningMode) @@ -170,7 +186,7 @@ public async Task LookupOnCharPosition(TextBox tb, int charPosition, bool enable if (lookupResults?.Count > 0) { - _lastTextBox = tb; + _previousTextBox = tb; LastSelectedText = lookupResults[0].MatchedText; if (ConfigManager.HighlightLongestMatch) @@ -203,6 +219,9 @@ public async Task LookupOnCharPosition(TextBox tb, int charPosition, bool enable Show(); + _firstVisibleListBoxIndex = GetFirstVisibleListBoxItemIndex(); + _listBoxIndex = _firstVisibleListBoxIndex; + if (ConfigManager.FixedPopupPositioning && Owner == MainWindow.Instance) { UpdatePosition(WindowsUtils.DpiAwareFixedPopupXPosition, WindowsUtils.DpiAwareFixedPopupYPosition); @@ -263,13 +282,14 @@ public async Task LookupOnSelect(TextBox tb) return; } - _lastTextBox = tb; + _previousTextBox = tb; LastText = tb.SelectedText; LastSelectedText = tb.SelectedText; + _currentCharPosition = tb.SelectionStart; List? lookupResults = LookupUtils.LookupText(tb.SelectedText); - if (lookupResults is { Count: > 0 }) + if (lookupResults?.Count > 0) { LastLookupResults = lookupResults; EnableMiningMode(); @@ -282,6 +302,9 @@ public async Task LookupOnSelect(TextBox tb) Show(); + _firstVisibleListBoxIndex = GetFirstVisibleListBoxItemIndex(); + _listBoxIndex = _firstVisibleListBoxIndex; + if (ConfigManager.FixedPopupPositioning && Owner == MainWindow.Instance) { UpdatePosition(WindowsUtils.DpiAwareFixedPopupXPosition, WindowsUtils.DpiAwareFixedPopupYPosition); @@ -383,7 +406,7 @@ private void UpdatePosition(double x, double y) Top = y; } - private void DisplayResults(bool generateAllResults, string? text = null) + public void DisplayResults(bool generateAllResults, string? text = null) { DictsWithResults.Clear(); @@ -607,11 +630,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul _ = top.Children.Add(readingTextBox); } - readingTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - readingTextBox.MouseMove += UiElement_MouseMove; + readingTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + readingTextBox.MouseMove += TextBox_MouseMove; readingTextBox.LostFocus += Unselect; - readingTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + readingTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; readingTextBox.MouseLeave += OnMouseLeave; + readingTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; } else @@ -689,11 +713,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul VerticalAlignment = VerticalAlignment.Center }; - alternativeSpellingsTexBox.PreviewMouseUp += UiElement_PreviewMouseUp; - alternativeSpellingsTexBox.MouseMove += UiElement_MouseMove; + alternativeSpellingsTexBox.PreviewMouseUp += TextBox_PreviewMouseUp; + alternativeSpellingsTexBox.MouseMove += TextBox_MouseMove; alternativeSpellingsTexBox.LostFocus += Unselect; - alternativeSpellingsTexBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + alternativeSpellingsTexBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; alternativeSpellingsTexBox.MouseLeave += OnMouseLeave; + alternativeSpellingsTexBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = top.Children.Add(alternativeSpellingsTexBox); } else @@ -792,11 +817,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul VerticalAlignment = VerticalAlignment.Center }; - definitionsTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - definitionsTextBox.MouseMove += UiElement_MouseMove; + definitionsTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + definitionsTextBox.MouseMove += TextBox_MouseMove; definitionsTextBox.LostFocus += Unselect; - definitionsTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + definitionsTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; definitionsTextBox.MouseLeave += OnMouseLeave; + definitionsTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = bottom.Children.Add(definitionsTextBox); } @@ -844,11 +870,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul ContextMenu = PopupContextMenu }; - onReadingsTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - onReadingsTextBox.MouseMove += UiElement_MouseMove; + onReadingsTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + onReadingsTextBox.MouseMove += TextBox_MouseMove; onReadingsTextBox.LostFocus += Unselect; - onReadingsTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + onReadingsTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; onReadingsTextBox.MouseLeave += OnMouseLeave; + onReadingsTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = bottom.Children.Add(onReadingsTextBox); } @@ -895,11 +922,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul ContextMenu = PopupContextMenu }; - kunReadingsTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - kunReadingsTextBox.MouseMove += UiElement_MouseMove; + kunReadingsTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + kunReadingsTextBox.MouseMove += TextBox_MouseMove; kunReadingsTextBox.LostFocus += Unselect; - kunReadingsTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + kunReadingsTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; kunReadingsTextBox.MouseLeave += OnMouseLeave; + kunReadingsTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = bottom.Children.Add(kunReadingsTextBox); } @@ -946,11 +974,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul ContextMenu = PopupContextMenu }; - nanoriReadingsTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - nanoriReadingsTextBox.MouseMove += UiElement_MouseMove; + nanoriReadingsTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + nanoriReadingsTextBox.MouseMove += TextBox_MouseMove; nanoriReadingsTextBox.LostFocus += Unselect; - nanoriReadingsTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + nanoriReadingsTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; nanoriReadingsTextBox.MouseLeave += OnMouseLeave; + nanoriReadingsTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = bottom.Children.Add(nanoriReadingsTextBox); } @@ -1030,11 +1059,12 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul ContextMenu = PopupContextMenu }; - compositionTextBox.PreviewMouseUp += UiElement_PreviewMouseUp; - compositionTextBox.MouseMove += UiElement_MouseMove; + compositionTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + compositionTextBox.MouseMove += TextBox_MouseMove; compositionTextBox.LostFocus += Unselect; - compositionTextBox.PreviewMouseRightButtonUp += TextBoxPreviewMouseRightButtonUp; + compositionTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; compositionTextBox.MouseLeave += OnMouseLeave; + compositionTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; _ = bottom.Children.Add(compositionTextBox); } @@ -1096,9 +1126,24 @@ public StackPanel MakeResultStackPanel(LookupResult result, int index, int resul return stackPanel; } + private static int GetIndexOfListBoxItemFromStackPanel(StackPanel stackPanel) + { + return (int)((WrapPanel)stackPanel.Children[0]).Tag; + } + + private int GetFirstVisibleListBoxItemIndex() + { + StackPanel? firstVisibleStackPanel = PopupListView.Items.Cast() + .FirstOrDefault(static stackPanel => stackPanel.Visibility is Visibility.Visible); + + return firstVisibleStackPanel is not null + ? GetIndexOfListBoxItemFromStackPanel(firstVisibleStackPanel) + : 0; + } + private void ListBoxItem_MouseEnter(object sender, MouseEventArgs e) { - _listBoxIndex = (int)((WrapPanel)((StackPanel)sender).Children[0]).Tag; + _listBoxIndex = GetIndexOfListBoxItemFromStackPanel((StackPanel)sender); LastSelectedText = LastLookupResults[_listBoxIndex].PrimarySpelling; } @@ -1107,14 +1152,20 @@ private static void Unselect(object sender, RoutedEventArgs e) WindowsUtils.Unselect((TextBox)sender); } - private void TextBoxPreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) + private void TextBox_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { AddNameMenuItem.IsEnabled = DictUtils.CustomNameDictReady && DictUtils.ProfileCustomNameDictReady; AddWordMenuItem.IsEnabled = DictUtils.CustomWordDictReady && DictUtils.ProfileCustomWordDictReady; - LastSelectedText = ((TextBox)sender).SelectedText; + _lastInteractedTextBox = (TextBox)sender; + LastSelectedText = _lastInteractedTextBox.SelectedText; } - private async void UiElement_MouseMove(object sender, MouseEventArgs? e) + private void TextBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + _lastInteractedTextBox = (TextBox)sender; + } + + private async void TextBox_MouseMove(object sender, MouseEventArgs? e) { if (ConfigManager.InactiveLookupMode || ConfigManager.LookupOnSelectOnly @@ -1137,6 +1188,7 @@ private async void UiElement_MouseMove(object sender, MouseEventArgs? e) if (MiningMode) { TextBox tb = (TextBox)sender; + _lastInteractedTextBox = tb; if (JapaneseUtils.JapaneseRegex.IsMatch(tb.Text)) { await ChildPopupWindow.LookupOnMouseMoveOrClick(tb).ConfigureAwait(false); @@ -1144,150 +1196,8 @@ private async void UiElement_MouseMove(object sender, MouseEventArgs? e) else if (ConfigManager.HighlightLongestMatch) { - WindowsUtils.Unselect(ChildPopupWindow._lastTextBox); - } - } - } - - private async Task Mine(Panel top) - { - Dictionary miningParams = new(); - - if (_currentText is not null) - { - miningParams[JLField.SourceText] = _currentText; - miningParams[JLField.Sentence] = JapaneseUtils.FindSentence(_currentText, _currentCharPosition); - } - - HidePopup(); - - foreach (UIElement child in top.Children) - { - switch (child) - { - case TextBox chi: - switch (chi.Name) - { - case nameof(LookupResult.Readings): - miningParams[JLField.Readings] = chi.Text; - break; - case nameof(LookupResult.AlternativeSpellings): - miningParams[JLField.AlternativeSpellings] = chi.Text; - break; - } - - break; - case TextBlock ch: - switch (ch.Name) - { - case nameof(LookupResult.PrimarySpelling): - miningParams[JLField.PrimarySpelling] = ch.Text; - break; - case nameof(LookupResult.MatchedText): - miningParams[JLField.MatchedText] = ch.Text; - break; - case nameof(LookupResult.DeconjugatedMatchedText): - miningParams[JLField.DeconjugatedMatchedText] = ch.Text; - break; - case nameof(LookupResult.EdictId): - miningParams[JLField.EdictId] = ch.Text; - break; - case nameof(LookupResult.Frequencies): - miningParams[JLField.Frequencies] = ch.Text; - break; - case nameof(LookupResult.Dict.Name): - miningParams[JLField.DictionaryName] = ch.Text; - break; - case nameof(LookupResult.Process): - miningParams[JLField.DeconjugationProcess] = ch.Text; - break; - } - - break; - case Grid grid: - { - foreach (UIElement uiElement in grid.Children) - { - if (uiElement is TextBlock textBlockCg) - { - switch (textBlockCg.Name) - { - case nameof(LookupResult.PrimarySpelling): - miningParams[JLField.PrimarySpelling] = textBlockCg.Text; - break; - } - } - else if (uiElement is TextBox textBoxCg) - { - switch (textBoxCg.Name) - { - case nameof(LookupResult.Readings): - miningParams[JLField.Readings] = textBoxCg.Text; - break; - } - } - } - - break; - } - } - } - - StackPanel innerStackPanel = (StackPanel)top.Parent; - StackPanel bottom = (StackPanel)innerStackPanel.Children[1]; - foreach (object child in bottom.Children) - { - if (child is TextBox textBox) - { - switch (textBox.Name) - { - case nameof(LookupResult.FormattedDefinitions): - miningParams[JLField.Definitions] = textBox.Text.Replace("\n", "
", StringComparison.Ordinal); - break; - case nameof(LookupResult.OnReadings): - miningParams[JLField.OnReadings] = textBox.Text[4..]; - break; - case nameof(LookupResult.KunReadings): - miningParams[JLField.KunReadings] = textBox.Text[5..]; - break; - case nameof(LookupResult.NanoriReadings): - miningParams[JLField.NanoriReadings] = textBox.Text[8..]; - break; - case nameof(LookupResult.KanjiComposition): - miningParams[JLField.KanjiComposition] = textBox.Text[13..]; - break; - } - continue; - } - - if (child is not TextBlock tb) - { - continue; + WindowsUtils.Unselect(ChildPopupWindow._previousTextBox); } - - switch (tb.Name) - { - case nameof(LookupResult.StrokeCount): - miningParams[JLField.StrokeCount] = tb.Text; - break; - case nameof(LookupResult.KanjiGrade): - miningParams[JLField.KanjiGrade] = tb.Text; - break; - case nameof(LookupResult.KanjiStats): - miningParams[JLField.KanjiStats] = tb.Text; - break; - default: - throw new ArgumentOutOfRangeException(null, "Invalid LookupResult type"); - } - } - - miningParams[JLField.LocalTime] = DateTime.Now.ToString("s", CultureInfo.InvariantCulture); - - bool mined = await Mining.Mine(miningParams).ConfigureAwait(false); - - if (mined) - { - Stats.IncrementStat(StatType.CardsMined); } } @@ -1303,38 +1213,32 @@ private async void PrimarySpelling_PreviewMouseUp(object sender, MouseButtonEven return; } - TextBlock textBlock = (TextBlock)sender; - - WrapPanel top = textBlock.Parent is Grid primarySpellingGrid - ? (WrapPanel)primarySpellingGrid.Parent - : (WrapPanel)textBlock.Parent; + HidePopup(); - await Mine(top).ConfigureAwait(false); + await PopupWindowUtils.Mine(LastLookupResults[_listBoxIndex], _currentText, _currentCharPosition).ConfigureAwait(false); } private void ShowAddNameWindow() { string text; string reading = ""; - if (ChildPopupWindow?._lastTextBox?.SelectionLength > 0) + if (_lastInteractedTextBox?.SelectionLength > 0) { - text = ChildPopupWindow._lastTextBox.SelectedText; - - if (text == ChildPopupWindow.LastSelectedText) + text = _lastInteractedTextBox.SelectedText; + if (text == ChildPopupWindow?.LastSelectedText) { string[]? readings = ChildPopupWindow.LastLookupResults[0].Readings; - reading = readings is { Length: 1 } + reading = readings?.Length is 1 ? readings[0] : ""; } } else { - int index = MiningMode ? _listBoxIndex : 0; - text = LastLookupResults[index].PrimarySpelling; + text = LastLookupResults[_listBoxIndex].PrimarySpelling; - string[]? readings = LastLookupResults[index].Readings; - reading = readings is { Length: 1 } + string[]? readings = LastLookupResults[_listBoxIndex].Readings; + reading = readings?.Length is 1 ? readings[0] : ""; } @@ -1444,7 +1348,7 @@ public async Task HandleHotKey(KeyGesture keyGesture) if (Owner != MainWindow.Instance) { - UiElement_MouseMove(_lastTextBox!, null); + TextBox_MouseMove(_previousTextBox!, null); } else @@ -1459,10 +1363,24 @@ public async Task HandleHotKey(KeyGesture keyGesture) { if (!MiningMode) { + if (Owner is PopupWindow previousPopupWindow) + { + previousPopupWindow.ShowAddNameWindow(); + } + + else + { + MainWindow.Instance.ShowAddNameWindow(); + } + HidePopup(); } - ShowAddNameWindow(); + else + { + ShowAddNameWindow(); + } + PopupAutoHideTimer.Start(); } } @@ -1473,17 +1391,49 @@ public async Task HandleHotKey(KeyGesture keyGesture) { if (!MiningMode) { + if (Owner is PopupWindow previousPopupWindow) + { + previousPopupWindow.ShowAddWordWindow(); + } + + else + { + MainWindow.Instance.ShowAddWordWindow(); + } + HidePopup(); } - WindowsUtils.ShowAddWordWindow(LastSelectedText); + else + { + ShowAddWordWindow(); + } + PopupAutoHideTimer.Start(); } } else if (KeyGestureUtils.CompareKeyGestures(keyGesture, ConfigManager.SearchWithBrowserKeyGesture)) { - WindowsUtils.SearchWithBrowser(LastSelectedText); + if (!MiningMode) + { + if (Owner is PopupWindow previousPopupWindow) + { + previousPopupWindow.SearchWithBrowser(); + } + + else + { + MainWindow.Instance.SearchWithBrowser(); + } + + HidePopup(); + } + + else + { + SearchWithBrowser(); + } } else if (KeyGestureUtils.CompareKeyGestures(keyGesture, ConfigManager.InactiveLookupModeKeyGesture)) @@ -1585,7 +1535,7 @@ public async Task HandleHotKey(KeyGesture keyGesture) else if (KeyGestureUtils.CompareKeyGestures(keyGesture, ConfigManager.ToggleMinimizedStateKeyGesture)) { MainWindow mainWindow = MainWindow.Instance; - WindowsUtils.HidePopups(mainWindow.FirstPopupWindow); + PopupWindowUtils.HidePopups(mainWindow.FirstPopupWindow); if (ConfigManager.Focusable) { @@ -1611,10 +1561,13 @@ public async Task HandleHotKey(KeyGesture keyGesture) else if (KeyGestureUtils.CompareKeyGestures(keyGesture, ConfigManager.SelectedTextToSpeechKeyGesture)) { if (MiningMode - && SpeechSynthesisUtils.InstalledVoiceWithHighestPriority is not null - && LastSelectedText is not null) + && SpeechSynthesisUtils.InstalledVoiceWithHighestPriority is not null) { - await SpeechSynthesisUtils.TextToSpeech(SpeechSynthesisUtils.InstalledVoiceWithHighestPriority, LastSelectedText, CoreConfig.AudioVolume).ConfigureAwait(false); + string text = _lastInteractedTextBox?.SelectionLength > 0 + ? _lastInteractedTextBox.SelectedText + : LastLookupResults[_listBoxIndex].PrimarySpelling; + + await SpeechSynthesisUtils.TextToSpeech(SpeechSynthesisUtils.InstalledVoiceWithHighestPriority, text, CoreConfig.AudioVolume).ConfigureAwait(false); } } @@ -1638,17 +1591,15 @@ public async Task HandleHotKey(KeyGesture keyGesture) { if (MiningMode && PopupListView.SelectedItem is not null) { - WrapPanel? top = ((StackPanel)PopupListView.SelectedItem).Children.OfType().FirstOrDefault(); + HidePopup(); - if (top is not null) - { - await Mine(top).ConfigureAwait(false); - } + int index = GetIndexOfListBoxItemFromStackPanel((StackPanel)PopupListView.SelectedItem); + await PopupWindowUtils.Mine(LastLookupResults[index], _currentText, _currentCharPosition).ConfigureAwait(false); } } } - private void EnableMiningMode() + public void EnableMiningMode() { MiningMode = true; @@ -1662,88 +1613,26 @@ private void EnableMiningMode() private async Task PlayAudio() { - string? primarySpelling = null; - string? reading = null; - - List visibleStackPanels = PopupListView.Items.Cast() - .Where(static stackPanel => stackPanel.Visibility is Visibility.Visible).ToList(); - - if (visibleStackPanels.Count is 0) + if (LastLookupResults.Count is 0) { return; } - StackPanel innerStackPanel = visibleStackPanels[MiningMode ? _listBoxIndex : 0]; - WrapPanel top = (WrapPanel)innerStackPanel.Children[0]; + LookupResult lastLookupResult = LastLookupResults[_listBoxIndex]; + string primarySpelling = lastLookupResult.PrimarySpelling; + string? reading = lastLookupResult.Readings?[0]; - foreach (UIElement child in top.Children) + if (WindowsUtils.AudioPlayer?.PlaybackState is PlaybackState.Playing + && s_primarySpellingOfLastPlayedAudio == primarySpelling + && s_readingOfLastPlayedAudio == reading) { - if (child is TextBox chi) - { - switch (chi.Name) - { - case nameof(LookupResult.Readings): - reading = chi.Text.Split(',')[0]; - break; - } - } - - else if (child is TextBlock ch) - { - switch (ch.Name) - { - case nameof(LookupResult.PrimarySpelling): - primarySpelling = ch.Text; - break; - case nameof(LookupResult.Readings): - reading = ch.Text.Split(',')[0]; - break; - } - } - - else if (child is Grid grid) - { - foreach (UIElement uiElement in grid.Children) - { - if (uiElement is TextBlock textBlockCg) - { - switch (textBlockCg.Name) - { - case nameof(LookupResult.PrimarySpelling): - primarySpelling = textBlockCg.Text; - break; - case nameof(LookupResult.Readings): - reading = textBlockCg.Text.Split(',')[0]; - break; - } - } - else if (uiElement is TextBox textBoxCg) - { - switch (textBoxCg.Name) - { - case nameof(LookupResult.Readings): - reading = textBoxCg.Text.Split(',')[0]; - break; - } - } - } - } + return; } - if (primarySpelling is not null) - { - if (WindowsUtils.AudioPlayer?.PlaybackState is PlaybackState.Playing - && s_primarySpellingOfLastPlayedAudio == primarySpelling - && s_readingOfLastPlayedAudio == reading) - { - return; - } + s_primarySpellingOfLastPlayedAudio = primarySpelling; + s_readingOfLastPlayedAudio = reading; - s_primarySpellingOfLastPlayedAudio = primarySpelling; - s_readingOfLastPlayedAudio = reading; - - await AudioUtils.GetAndPlayAudio(primarySpelling, reading).ConfigureAwait(false); - } + await AudioUtils.GetAndPlayAudio(primarySpelling, reading).ConfigureAwait(false); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) @@ -1780,9 +1669,10 @@ private void OnMouseEnter(object sender, MouseEventArgs e) HidePopup(); } - private async void UiElement_PreviewMouseUp(object sender, MouseButtonEventArgs e) + private async void TextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e) { - LastSelectedText = ((TextBox)sender).SelectedText; + _lastInteractedTextBox = (TextBox)sender; + LastSelectedText = _lastInteractedTextBox.SelectedText; if (ConfigManager.InactiveLookupMode || (ConfigManager.RequireLookupKeyPress && !KeyGestureUtils.CompareKeyGesture(ConfigManager.LookupKeyKeyGesture)) @@ -1842,25 +1732,6 @@ private void OnMouseLeave(object sender, MouseEventArgs e) } } - public static void ShowMiningModeResults(PopupWindow popupWindow) - { - popupWindow.EnableMiningMode(); - WinApi.BringToFront(popupWindow.WindowHandle); - popupWindow.DisplayResults(true); - - if (ConfigManager.Focusable) - { - _ = popupWindow.Activate(); - } - - _ = popupWindow.Focus(); - - if (ConfigManager.AutoHidePopupIfMouseIsNotOverIt) - { - PopupWindowUtils.SetPopupAutoHideTimer(); - } - } - private void GenerateDictTypeButtons() { List