| 1 | using static CascadeIDE.Services.IdeCommands; |
| 2 | |
| 3 | namespace CascadeIDE.Features.IdeMcp.Execution; |
| 4 | |
| 5 | /// <summary>MCP-хендлеры диалогов открытия, выхода, настроек, превью и окон-хостов презентации.</summary> |
| 6 | internal sealed partial class IdeMcpCommandExecutor |
| 7 | { |
| 8 | private void RegisterMenuToolbarDialogsAndHosts(Action<string, Handler> add) |
| 9 | { |
| 10 | add(OpenSolutionDialog, async (_, _) => |
| 11 | { |
| 12 | if (_vm.OpenSolutionCommand.CanExecute(null)) |
| 13 | _vm.OpenSolutionCommand.Execute(null); |
| 14 | return "OK"; |
| 15 | }); |
| 16 | add(CreateNewSolutionDialog, async (_, _) => |
| 17 | { |
| 18 | if (_vm.CreateNewSolutionCommand.CanExecute(null)) |
| 19 | _vm.CreateNewSolutionCommand.Execute(null); |
| 20 | return "OK"; |
| 21 | }); |
| 22 | add(OpenFolderDialog, async (_, _) => |
| 23 | { |
| 24 | if (_vm.OpenFolderCommand.CanExecute(null)) |
| 25 | _vm.OpenFolderCommand.Execute(null); |
| 26 | return "OK"; |
| 27 | }); |
| 28 | add(OpenFileDialog, async (_, _) => |
| 29 | { |
| 30 | if (_vm.OpenFileFromDialogCommand.CanExecute(null)) |
| 31 | _vm.OpenFileFromDialogCommand.Execute(null); |
| 32 | return "OK"; |
| 33 | }); |
| 34 | add(ExitApplication, async (_, _) => |
| 35 | { |
| 36 | if (_vm.ExitCommand.CanExecute(null)) |
| 37 | _vm.ExitCommand.Execute(null); |
| 38 | return "OK"; |
| 39 | }); |
| 40 | add(About, async (_, _) => |
| 41 | { |
| 42 | if (_vm.AboutCommand.CanExecute(null)) |
| 43 | _vm.AboutCommand.Execute(null); |
| 44 | return "OK"; |
| 45 | }); |
| 46 | add(OpenSettings, async (_, _) => |
| 47 | { |
| 48 | if (_vm.OpenSettingsCommand.CanExecute(null)) |
| 49 | _vm.OpenSettingsCommand.Execute(null); |
| 50 | return "OK"; |
| 51 | }); |
| 52 | add(OpenPreviewWindow, async (_, _) => |
| 53 | { |
| 54 | if (_vm.OpenPreviewWindowCommand.CanExecute(null)) |
| 55 | _vm.OpenPreviewWindowCommand.Execute(null); |
| 56 | return "OK"; |
| 57 | }); |
| 58 | add(ExportExpandedMarkdown, async (_, _) => |
| 59 | { |
| 60 | if (_vm.ExportExpandedMarkdownCommand.CanExecute(null)) |
| 61 | await _vm.ExportExpandedMarkdownCommand.ExecuteAsync(null); |
| 62 | return "OK"; |
| 63 | }); |
| 64 | add(ToggleMfdHostWindow, async (_, _) => |
| 65 | { |
| 66 | if (!_vm.ToggleMfdHostWindowCommand.CanExecute(null)) |
| 67 | return "Skipped: presentation does not request Mfd host window; set presentation / zone_screen_layout in settings.toml (ADR 0017)."; |
| 68 | _vm.ToggleMfdHostWindowCommand.Execute(null); |
| 69 | return "OK"; |
| 70 | }); |
| 71 | add(TogglePmSplitHostWindow, async (_, _) => |
| 72 | { |
| 73 | if (!_vm.TogglePmSplitHostWindowCommand.CanExecute(null)) |
| 74 | return "Skipped: presentation does not request P+M split host; use (xP+yM)(F) or (F)(xP+yM) in settings.toml (ADR 0017)."; |
| 75 | _vm.TogglePmSplitHostWindowCommand.Execute(null); |
| 76 | return "OK"; |
| 77 | }); |
| 78 | } |
| 79 | } |
| 80 | |