Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/PlanViewer.App/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,24 @@ 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);
var json = JsonSerializer.Serialize(analysis, new JsonSerializerOptions { WriteIndented = true });
ShowAdviceWindow("Advice for Robots", json);
};

humanBtn.Click += (_, _) => showHumanAdvice();
robotBtn.Click += (_, _) => showRobotAdvice();

var compareBtn = new Button
{
Content = "\u2194 Compare Plans",
Expand Down Expand Up @@ -500,7 +503,7 @@ private DockPanel CreatePlanTabContent(PlanViewerControl viewer)
Theme = (Avalonia.Styling.ControlTheme)this.FindResource("AppButton")!
};

copyReproBtn.Click += async (_, _) =>
Func<System.Threading.Tasks.Task> copyRepro = async () =>
{
if (viewer.CurrentPlan == null) return;
var queryText = GetQueryTextFromPlan(viewer);
Expand All @@ -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
{
Expand Down
Loading