From 4161196a00fc6c8cff7f794623057a775a7473bc Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Thu, 22 Jan 2026 16:28:12 -0800 Subject: [PATCH 1/7] Fix LT-22230: Parser Test Report Font --- Src/LexText/ParserUI/ParserListener.cs | 36 +++++++++++++++---- .../ParserUI/ParserReportDialog.xaml.cs | 22 ++++++++++-- .../ParserUI/ParserReportsDialog.xaml.cs | 24 ++++++++++--- Src/xWorks/FwXApp.cs | 1 + 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/Src/LexText/ParserUI/ParserListener.cs b/Src/LexText/ParserUI/ParserListener.cs index dfea987b77..420756a8f1 100644 --- a/Src/LexText/ParserUI/ParserListener.cs +++ b/Src/LexText/ParserUI/ParserListener.cs @@ -70,6 +70,7 @@ public class ParserListener : IxCoreColleague, IDisposable, IVwNotifyChange private string m_sourceText = null; private ObservableCollection m_parserReports = null; private ParserReportsDialog m_parserReportsDialog = null; + private IList m_parserReportDialogs = new List(); private string m_defaultComment = null; public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters) @@ -626,7 +627,7 @@ private void UpdateWordforms(IEnumerable wordforms, ParserPriority // Write an empty parser report. var parserReport = CreateParserReport(); ParserReportViewModel viewModel = AddParserReport(parserReport); - ShowParserReport(viewModel, m_mediator, m_cache); + OnShowParserReport(viewModel); } } m_parserConnection.UpdateWordforms(wordforms, priority, checkParser); @@ -681,7 +682,7 @@ private void WordformUpdatedEventHandler(object sender, WordformUpdatedEventArgs // Convert parse results into ParserReport. var parserReport = CreateParserReport(); ParserReportViewModel viewModel = AddParserReport(parserReport); - ShowParserReport(viewModel, m_mediator, m_cache); + OnShowParserReport(viewModel); } } @@ -839,13 +840,26 @@ public void ShowParserReports() { ReadParserReports(); // Create parser reports window. - m_parserReportsDialog = new ParserReportsDialog(m_parserReports, m_mediator, m_cache, m_defaultComment); + m_parserReportsDialog = new ParserReportsDialog(m_parserReports, m_mediator, m_cache, m_propertyTable, m_defaultComment); m_parserReportsDialog.Closed += ParserReportsDialog_Closed; } m_parserReportsDialog.Show(); // Show the dialog but do not block other app access m_parserReportsDialog.BringIntoView(); } + public bool OnRefreshPopupWindows(object sender) + { + if (m_parserReportsDialog != null) + { + m_parserReportsDialog.SetFont(); + } + foreach (ParserReportDialog dialog in m_parserReportDialogs) + { + dialog.SetFont(); + } + return true; + } + private void ParserReportsDialog_Closed(object sender, EventArgs e) { ParserReportsDialog dialog = (ParserReportsDialog)sender; @@ -889,11 +903,21 @@ private ParserReportViewModel AddParserReport(ParserReport parserReport) /// Display a parser report window. /// /// - /// the mediator is used to call TryAWord - public static void ShowParserReport(ParserReportViewModel parserReport, Mediator mediator, LcmCache cache) + public void OnShowParserReport(ParserReportViewModel parserReport) { - ParserReportDialog dialog = new ParserReportDialog(parserReport, mediator, cache); + ParserReportDialog dialog = new ParserReportDialog(parserReport, m_mediator, m_cache, m_propertyTable); dialog.Show(); + m_parserReportDialogs.Add(dialog); + dialog.Closed += ParserReportDialog_Closed; + } + + private void ParserReportDialog_Closed(object sender, EventArgs e) + { + ParserReportDialog dialog = (ParserReportDialog)sender; + if (dialog != null) + { + m_parserReportDialogs.Remove(dialog); + } } public bool OnParseAllWords(object argument) diff --git a/Src/LexText/ParserUI/ParserReportDialog.xaml.cs b/Src/LexText/ParserUI/ParserReportDialog.xaml.cs index 18afdcd8c3..7c9907f88d 100644 --- a/Src/LexText/ParserUI/ParserReportDialog.xaml.cs +++ b/Src/LexText/ParserUI/ParserReportDialog.xaml.cs @@ -1,9 +1,11 @@ using SIL.FieldWorks.Common.FwUtils; +using SIL.FieldWorks.Common.Widgets; using SIL.FieldWorks.WordWorks.Parser; using SIL.LCModel; using SIL.LCModel.Core.Text; -using System.Diagnostics; using System; +using System.Diagnostics; +using System.Drawing; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -17,18 +19,32 @@ public partial class ParserReportDialog : Window public Mediator Mediator { get; set; } public LcmCache Cache { get; set; } + private readonly PropertyTable m_propertyTable; + public ParserReportDialog() { InitializeComponent(); } - public ParserReportDialog(ParserReportViewModel parserReport, Mediator mediator, LcmCache cache) + public ParserReportDialog(ParserReportViewModel parserReport, Mediator mediator, LcmCache cache, PropertyTable propertyTable) { InitializeComponent(); Mediator = mediator; Cache = cache; + m_propertyTable = propertyTable; DataContext = parserReport; commentLabel.Content = ParserUIStrings.ksComment + ":"; + SetFont(); + } + + public void SetFont() + { + Font font = FontHeightAdjuster.GetFontForNormalStyle(Cache.DefaultVernWs, Cache.WritingSystemFactory, m_propertyTable); + if (font != null) + { + FontFamily = new System.Windows.Media.FontFamily(font.FontFamily.Name); + FontSize = font.Size; + } } public void SaveParserReport(object sender, RoutedEventArgs e) @@ -86,7 +102,7 @@ private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) if (sender is DataGrid dataGrid) { if (dataGrid.SelectedItem is ParserReportViewModel selectedItem) - ParserListener.ShowParserReport(selectedItem, Mediator, Cache); + Mediator.SendMessage("ShowParserReport", selectedItem); } else Debug.Fail("Type of Contents of DataGrid changed, adjust double click code."); diff --git a/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs b/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs index 77498dcb96..fd6c8b3214 100644 --- a/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs +++ b/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs @@ -1,9 +1,11 @@ using SIL.Extensions; +using SIL.FieldWorks.Common.Widgets; using SIL.FieldWorks.WordWorks.Parser; using SIL.LCModel; using System; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Drawing; using System.Linq; using System.Windows; using System.Windows.Controls; @@ -27,20 +29,34 @@ public partial class ParserReportsDialog : Window public string DefaultComment = null; + private PropertyTable m_propertyTable; + public ParserReportsDialog() { InitializeComponent(); } - public ParserReportsDialog(ObservableCollection parserReports, Mediator mediator, LcmCache cache, string defaultComment) + public ParserReportsDialog(ObservableCollection parserReports, Mediator mediator, LcmCache cache, PropertyTable propertyTable, string defaultComment) { InitializeComponent(); parserReports.Sort((x, y) => y.Timestamp.CompareTo(x.Timestamp)); ParserReports = parserReports; Mediator = mediator; Cache = cache; + m_propertyTable = propertyTable; DataContext = new ParserReportsViewModel { ParserReports = parserReports }; DefaultComment = defaultComment; + SetFont(); + } + + public void SetFont() + { + Font font = FontHeightAdjuster.GetFontForNormalStyle(Cache.DefaultVernWs, Cache.WritingSystemFactory, m_propertyTable); + if (font != null) + { + FontFamily = new System.Windows.Media.FontFamily(font.FontFamily.Name); + FontSize = font.Size; + } } private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) @@ -60,7 +76,7 @@ public void ShowParserReport(object sender, RoutedEventArgs e) { if (report.IsSelected) { - ParserListener.ShowParserReport(report, Mediator, Cache); + Mediator.SendMessage("ShowParserReport", report); break; } } @@ -129,14 +145,14 @@ public void DiffParserReports(object sender, RoutedEventArgs e) } var diff = parserReport.ParserReport.DiffParserReports(parserReport2.ParserReport); ParserReportViewModel viewModel = new ParserReportViewModel() { ParserReport = diff }; - ParserListener.ShowParserReport(viewModel, Mediator, Cache); + Mediator.SendMessage("ShowParserReport", viewModel); } private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender is DataGrid dataGrid) { if(dataGrid.SelectedItem is ParserReportViewModel selectedItem) - ParserListener.ShowParserReport(selectedItem, Mediator, Cache); + Mediator.SendMessage("ShowParserReport", selectedItem); } else Debug.Fail("Type of Contents of DataGrid changed, adjust double click code."); diff --git a/Src/xWorks/FwXApp.cs b/Src/xWorks/FwXApp.cs index 7d168da845..a3a4b36b01 100644 --- a/Src/xWorks/FwXApp.cs +++ b/Src/xWorks/FwXApp.cs @@ -101,6 +101,7 @@ public void OnMasterRefresh(object sender) if (activeWnd != null) { // Refresh it last, so its saved settings get restored. + activeWnd.Mediator.BroadcastMessage("RefreshPopupWindows", null); activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); From b5877046a46d1690ee8a8726fb2c45cf11e07605 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 23 Jan 2026 08:21:08 -0800 Subject: [PATCH 2/7] Change "ShowParserReport" to Pub/Sub model --- Src/Common/FwUtils/EventConstants.cs | 1 + Src/LexText/ParserUI/ParserListener.cs | 9 ++++++--- Src/LexText/ParserUI/ParserReportDialog.xaml.cs | 3 ++- Src/LexText/ParserUI/ParserReportsDialog.xaml.cs | 9 +++++---- Src/xWorks/FwXApp.cs | 2 ++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Src/Common/FwUtils/EventConstants.cs b/Src/Common/FwUtils/EventConstants.cs index 6b278d327e..23482ea0b2 100644 --- a/Src/Common/FwUtils/EventConstants.cs +++ b/Src/Common/FwUtils/EventConstants.cs @@ -36,6 +36,7 @@ public static class EventConstants public const string SetToolFromName = "SetToolFromName"; public const string SFMImport = "SFMImport"; public const string ShowNotification = "ShowNotification"; + public const string ShowParserReport = "ShowParserReport"; public const string StopParser = "StopParser"; /// /// Called before opening and after closing UploadToWebonaryDlg to prevent bits of the main window from reloading (comment on LT-21480). diff --git a/Src/LexText/ParserUI/ParserListener.cs b/Src/LexText/ParserUI/ParserListener.cs index 420756a8f1..adc0132c93 100644 --- a/Src/LexText/ParserUI/ParserListener.cs +++ b/Src/LexText/ParserUI/ParserListener.cs @@ -86,6 +86,7 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configu m_sda.AddNotification(this); Subscriber.Subscribe(EventConstants.StopParser, StopParser); + Subscriber.Subscribe(EventConstants.RemoveFilters, ShowParserReport); } /// @@ -365,6 +366,7 @@ protected virtual void Dispose(bool disposing) if (disposing) { Subscriber.Unsubscribe(EventConstants.StopParser, StopParser); + Subscriber.Unsubscribe(EventConstants.ShowParserReport, ShowParserReport); // other clients may now parse // Dispose managed resources here. @@ -627,7 +629,7 @@ private void UpdateWordforms(IEnumerable wordforms, ParserPriority // Write an empty parser report. var parserReport = CreateParserReport(); ParserReportViewModel viewModel = AddParserReport(parserReport); - OnShowParserReport(viewModel); + ShowParserReport(viewModel); } } m_parserConnection.UpdateWordforms(wordforms, priority, checkParser); @@ -682,7 +684,7 @@ private void WordformUpdatedEventHandler(object sender, WordformUpdatedEventArgs // Convert parse results into ParserReport. var parserReport = CreateParserReport(); ParserReportViewModel viewModel = AddParserReport(parserReport); - OnShowParserReport(viewModel); + ShowParserReport(viewModel); } } @@ -903,8 +905,9 @@ private ParserReportViewModel AddParserReport(ParserReport parserReport) /// Display a parser report window. /// /// - public void OnShowParserReport(ParserReportViewModel parserReport) + private void ShowParserReport(object obj) { + ParserReportViewModel parserReport = obj as ParserReportViewModel; ParserReportDialog dialog = new ParserReportDialog(parserReport, m_mediator, m_cache, m_propertyTable); dialog.Show(); m_parserReportDialogs.Add(dialog); diff --git a/Src/LexText/ParserUI/ParserReportDialog.xaml.cs b/Src/LexText/ParserUI/ParserReportDialog.xaml.cs index 7c9907f88d..f7630ef64c 100644 --- a/Src/LexText/ParserUI/ParserReportDialog.xaml.cs +++ b/Src/LexText/ParserUI/ParserReportDialog.xaml.cs @@ -1,4 +1,5 @@ using SIL.FieldWorks.Common.FwUtils; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.Widgets; using SIL.FieldWorks.WordWorks.Parser; using SIL.LCModel; @@ -102,7 +103,7 @@ private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) if (sender is DataGrid dataGrid) { if (dataGrid.SelectedItem is ParserReportViewModel selectedItem) - Mediator.SendMessage("ShowParserReport", selectedItem); + Publisher.Publish(new PublisherParameterObject(EventConstants.ShowParserReport, selectedItem)); } else Debug.Fail("Type of Contents of DataGrid changed, adjust double click code."); diff --git a/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs b/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs index fd6c8b3214..1963d3a16e 100644 --- a/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs +++ b/Src/LexText/ParserUI/ParserReportsDialog.xaml.cs @@ -1,6 +1,7 @@ using SIL.Extensions; +using SIL.FieldWorks.Common.FwUtils; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.Widgets; -using SIL.FieldWorks.WordWorks.Parser; using SIL.LCModel; using System; using System.Collections.ObjectModel; @@ -76,7 +77,7 @@ public void ShowParserReport(object sender, RoutedEventArgs e) { if (report.IsSelected) { - Mediator.SendMessage("ShowParserReport", report); + Publisher.Publish(new PublisherParameterObject(EventConstants.ShowParserReport, report)); break; } } @@ -145,14 +146,14 @@ public void DiffParserReports(object sender, RoutedEventArgs e) } var diff = parserReport.ParserReport.DiffParserReports(parserReport2.ParserReport); ParserReportViewModel viewModel = new ParserReportViewModel() { ParserReport = diff }; - Mediator.SendMessage("ShowParserReport", viewModel); + Publisher.Publish(new PublisherParameterObject(EventConstants.ShowParserReport, viewModel)); } private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender is DataGrid dataGrid) { if(dataGrid.SelectedItem is ParserReportViewModel selectedItem) - Mediator.SendMessage("ShowParserReport", selectedItem); + Publisher.Publish(new PublisherParameterObject(EventConstants.ShowParserReport, selectedItem)); } else Debug.Fail("Type of Contents of DataGrid changed, adjust double click code."); diff --git a/Src/xWorks/FwXApp.cs b/Src/xWorks/FwXApp.cs index a3a4b36b01..f189d858ad 100644 --- a/Src/xWorks/FwXApp.cs +++ b/Src/xWorks/FwXApp.cs @@ -101,7 +101,9 @@ public void OnMasterRefresh(object sender) if (activeWnd != null) { // Refresh it last, so its saved settings get restored. + #pragma warning disable 618 // suppress obsolete warning activeWnd.Mediator.BroadcastMessage("RefreshPopupWindows", null); + #pragma warning restore 618 activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); From 57e0362739c0e4b45479969870cc79e4602e6198 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 23 Jan 2026 09:06:09 -0800 Subject: [PATCH 3/7] Change layout to work for different font sizes --- Src/LexText/ParserUI/ParserReportDialog.xaml | 10 +++++----- Src/LexText/ParserUI/ParserReportsDialog.xaml | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Src/LexText/ParserUI/ParserReportDialog.xaml b/Src/LexText/ParserUI/ParserReportDialog.xaml index 793ccd6450..2407087c09 100644 --- a/Src/LexText/ParserUI/ParserReportDialog.xaml +++ b/Src/LexText/ParserUI/ParserReportDialog.xaml @@ -133,7 +133,7 @@ - +