From a65e5305f25df0bb351f9b9954495fcffb14017c Mon Sep 17 00:00:00 2001 From: rampaa Date: Tue, 23 Jan 2024 20:51:31 +0300 Subject: [PATCH] Show the matched text in results when there's a deconjugation process info for it --- JL.Windows/GUI/PopupWindow.xaml.cs | 57 ++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index 7bf235a1..470e09b2 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -711,18 +711,53 @@ public StackPanel PrepareResultStackPanel(LookupResult result, int index, int re if (result.DeconjugationProcess is not null) { - TextBlock deconjugationProcessTextBlock = new() + if (MiningMode) { - Name = nameof(result.DeconjugationProcess), - Text = result.DeconjugationProcess, - Foreground = ConfigManager.DeconjugationInfoColor, - FontSize = ConfigManager.DeconjugationInfoFontSize, - Margin = new Thickness(5, 0, 0, 0), - TextWrapping = TextWrapping.Wrap, - HorizontalAlignment = HorizontalAlignment.Left, - VerticalAlignment = VerticalAlignment.Top - }; - _ = top.Children.Add(deconjugationProcessTextBlock); + TouchScreenTextBox deconjugationProcessTextBox = new() + { + Name = nameof(result.DeconjugationProcess), + Text = string.Create(CultureInfo.InvariantCulture, $"{result.MatchedText} {result.DeconjugationProcess}"), + TextWrapping = TextWrapping.Wrap, + Background = Brushes.Transparent, + Foreground = ConfigManager.DeconjugationInfoColor, + FontSize = ConfigManager.DeconjugationInfoFontSize, + BorderThickness = new Thickness(0, 0, 0, 0), + Margin = new Thickness(5, 0, 0, 0), + Padding = new Thickness(0), + IsReadOnly = true, + IsUndoEnabled = false, + UndoLimit = 0, + Cursor = Cursors.Arrow, + SelectionBrush = ConfigManager.HighlightColor, + IsInactiveSelectionHighlightEnabled = true, + ContextMenu = PopupContextMenu, + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top + }; + + deconjugationProcessTextBox.PreviewMouseUp += TextBox_PreviewMouseUp; + deconjugationProcessTextBox.MouseMove += TextBox_MouseMove; + deconjugationProcessTextBox.LostFocus += Unselect; + deconjugationProcessTextBox.PreviewMouseRightButtonUp += TextBox_PreviewMouseRightButtonUp; + deconjugationProcessTextBox.MouseLeave += OnMouseLeave; + deconjugationProcessTextBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown; + _ = top.Children.Add(deconjugationProcessTextBox); + } + else + { + TextBlock deconjugationProcessTextBlock = new() + { + Name = nameof(result.DeconjugationProcess), + Text = string.Create(CultureInfo.InvariantCulture, $"{result.MatchedText} {result.DeconjugationProcess}"), + Foreground = ConfigManager.DeconjugationInfoColor, + FontSize = ConfigManager.DeconjugationInfoFontSize, + Margin = new Thickness(5, 0, 0, 0), + TextWrapping = TextWrapping.Wrap, + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top + }; + _ = top.Children.Add(deconjugationProcessTextBlock); + } } if (result.Frequencies is not null)