From 6f68d4bcb8f9a38cec0ccdbe01fa72366b2f7de9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 7 Sep 2026 20:14:14 +0700 Subject: [PATCH 01/16] P0: make RCB inclusion truly multi-select --- MainWindow.RcbMultiSelectPointerAuthority.cs | 101 +++++++++++++++++-- 1 file changed, 95 insertions(+), 6 deletions(-) diff --git a/MainWindow.RcbMultiSelectPointerAuthority.cs b/MainWindow.RcbMultiSelectPointerAuthority.cs index 5e90f80f..9aed0041 100644 --- a/MainWindow.RcbMultiSelectPointerAuthority.cs +++ b/MainWindow.RcbMultiSelectPointerAuthority.cs @@ -10,11 +10,13 @@ namespace ArIED61850Tester; /// /// Physical pointer/keyboard authority for RCB export. Preview input is intercepted before /// the legacy XAML Click handler can run, so the production IED-card RCB action always opens -/// the generic multi-select exporter. Inside that exporter every row independently toggles -/// RcbExportRow.IsSelected; DataGrid row selection never limits export scope to one RCB. +/// the generic multi-select exporter. Inside that exporter RcbExportRow.IsSelected is the +/// inclusion authority; DataGrid row selection remains navigation/focus only. /// public partial class MainWindow { + private static readonly ConditionalWeakTable RcbSelectionAnchors = new(); + [ModuleInitializer] internal static void RegisterRcbMultiSelectPointerAuthority() { @@ -33,6 +35,11 @@ internal static void RegisterRcbMultiSelectPointerAuthority() UIElement.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(RcbMultiGrid_PreviewMouseLeftButtonDown), handledEventsToo: true); + EventManager.RegisterClassHandler( + typeof(DataGrid), + UIElement.PreviewKeyDownEvent, + new KeyEventHandler(RcbMultiGrid_PreviewKeyDown), + handledEventsToo: true); } private static void RcbExport_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) @@ -71,23 +78,99 @@ private static bool IsProductionRcbButton(Button button) private static void RcbMultiGrid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton != MouseButton.Left || sender is not DataGrid grid || - Window.GetWindow(grid) is not RcbMultiExportWindow || + Window.GetWindow(grid) is not RcbMultiExportWindow window || e.OriginalSource is not DependencyObject source) { return; } + if (FindRcbAncestor(source) != null || + FindRcbAncestor