From 298395eaaef656349c53025d3cf5f48f288cf11c Mon Sep 17 00:00:00 2001 From: ClaudioESSilva Date: Wed, 11 Mar 2026 17:41:19 +0000 Subject: [PATCH] fix #81 --- src/PlanViewer.App/MainWindow.axaml.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/PlanViewer.App/MainWindow.axaml.cs b/src/PlanViewer.App/MainWindow.axaml.cs index dc61e5f..1adb87d 100644 --- a/src/PlanViewer.App/MainWindow.axaml.cs +++ b/src/PlanViewer.App/MainWindow.axaml.cs @@ -451,14 +451,14 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer) Theme = (Avalonia.Styling.ControlTheme)this.FindResource("AppButton")! }; - humanBtn.Click += (_, _) => + Action showHumanAdvice = () => { if (viewer.CurrentPlan == null) return; var analysis = ResultMapper.Map(viewer.CurrentPlan, "file", viewer.Metadata); ShowAdviceWindow("Advice for Humans", TextFormatter.Format(analysis), analysis); }; - robotBtn.Click += (_, _) => + Action showRobotAdvice = () => { if (viewer.CurrentPlan == null) return; var analysis = ResultMapper.Map(viewer.CurrentPlan, "file", viewer.Metadata); @@ -466,6 +466,9 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer) ShowAdviceWindow("Advice for Robots", json); }; + humanBtn.Click += (_, _) => showHumanAdvice(); + robotBtn.Click += (_, _) => showRobotAdvice(); + var compareBtn = new Button { Content = "\u2194 Compare Plans", @@ -500,7 +503,7 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer) Theme = (Avalonia.Styling.ControlTheme)this.FindResource("AppButton")! }; - copyReproBtn.Click += async (_, _) => + Func copyRepro = async () => { if (viewer.CurrentPlan == null) return; var queryText = GetQueryTextFromPlan(viewer); @@ -518,10 +521,12 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer) } }; + copyReproBtn.Click += async (_, _) => await copyRepro(); + // Wire up context menu events from PlanViewerControl - viewer.HumanAdviceRequested += (_, _) => humanBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); - viewer.RobotAdviceRequested += (_, _) => robotBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); - viewer.CopyReproRequested += async (_, _) => copyReproBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); + viewer.HumanAdviceRequested += (_, _) => showHumanAdvice(); + viewer.RobotAdviceRequested += (_, _) => showRobotAdvice(); + viewer.CopyReproRequested += async (_, _) => await copyRepro(); var getActualPlanBtn = new Button {