Skip to content

Commit 53dd47c

Browse files
fix #81 (#82)
1 parent fd53dc4 commit 53dd47c

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/PlanViewer.App/MainWindow.axaml.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,21 +451,24 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer)
451451
Theme = (Avalonia.Styling.ControlTheme)this.FindResource("AppButton")!
452452
};
453453

454-
humanBtn.Click += (_, _) =>
454+
Action showHumanAdvice = () =>
455455
{
456456
if (viewer.CurrentPlan == null) return;
457457
var analysis = ResultMapper.Map(viewer.CurrentPlan, "file", viewer.Metadata);
458458
ShowAdviceWindow("Advice for Humans", TextFormatter.Format(analysis), analysis);
459459
};
460460

461-
robotBtn.Click += (_, _) =>
461+
Action showRobotAdvice = () =>
462462
{
463463
if (viewer.CurrentPlan == null) return;
464464
var analysis = ResultMapper.Map(viewer.CurrentPlan, "file", viewer.Metadata);
465465
var json = JsonSerializer.Serialize(analysis, new JsonSerializerOptions { WriteIndented = true });
466466
ShowAdviceWindow("Advice for Robots", json);
467467
};
468468

469+
humanBtn.Click += (_, _) => showHumanAdvice();
470+
robotBtn.Click += (_, _) => showRobotAdvice();
471+
469472
var compareBtn = new Button
470473
{
471474
Content = "\u2194 Compare Plans",
@@ -500,7 +503,7 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer)
500503
Theme = (Avalonia.Styling.ControlTheme)this.FindResource("AppButton")!
501504
};
502505

503-
copyReproBtn.Click += async (_, _) =>
506+
Func<System.Threading.Tasks.Task> copyRepro = async () =>
504507
{
505508
if (viewer.CurrentPlan == null) return;
506509
var queryText = GetQueryTextFromPlan(viewer);
@@ -518,10 +521,12 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer)
518521
}
519522
};
520523

524+
copyReproBtn.Click += async (_, _) => await copyRepro();
525+
521526
// Wire up context menu events from PlanViewerControl
522-
viewer.HumanAdviceRequested += (_, _) => humanBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
523-
viewer.RobotAdviceRequested += (_, _) => robotBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
524-
viewer.CopyReproRequested += async (_, _) => copyReproBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
527+
viewer.HumanAdviceRequested += (_, _) => showHumanAdvice();
528+
viewer.RobotAdviceRequested += (_, _) => showRobotAdvice();
529+
viewer.CopyReproRequested += async (_, _) => await copyRepro();
525530

526531
var getActualPlanBtn = new Button
527532
{

0 commit comments

Comments
 (0)