| 1 | using static CascadeIDE.Services.IdeCommands; |
| 2 | |
| 3 | namespace CascadeIDE.Features.IdeMcp.Execution; |
| 4 | |
| 5 | /// <summary>MCP-хендлеры темы оформления и языка UI.</summary> |
| 6 | internal sealed partial class IdeMcpCommandExecutor |
| 7 | { |
| 8 | private void RegisterMenuToolbarThemeAndLanguage(Action<string, Handler> add) |
| 9 | { |
| 10 | add(ApplyLightTheme, async (_, _) => |
| 11 | { |
| 12 | if (_vm.ApplyLightThemeCommand.CanExecute(null)) |
| 13 | await _vm.ApplyLightThemeCommand.ExecuteAsync(null); |
| 14 | return "OK"; |
| 15 | }); |
| 16 | add(ApplyDarkTheme, async (_, _) => |
| 17 | { |
| 18 | if (_vm.ApplyDarkThemeCommand.CanExecute(null)) |
| 19 | await _vm.ApplyDarkThemeCommand.ExecuteAsync(null); |
| 20 | return "OK"; |
| 21 | }); |
| 22 | add(ApplyCursorLikeTheme, async (_, _) => |
| 23 | { |
| 24 | if (_vm.ApplyCursorLikeThemeCommand.CanExecute(null)) |
| 25 | await _vm.ApplyCursorLikeThemeCommand.ExecuteAsync(null); |
| 26 | return "OK"; |
| 27 | }); |
| 28 | add(ApplyPowerClassicTheme, async (_, _) => |
| 29 | { |
| 30 | if (_vm.ApplyPowerClassicThemeCommand.CanExecute(null)) |
| 31 | await _vm.ApplyPowerClassicThemeCommand.ExecuteAsync(null); |
| 32 | return "OK"; |
| 33 | }); |
| 34 | add(OpenThemeFileDialog, async (_, _) => |
| 35 | { |
| 36 | if (_vm.OpenThemeFileCommand.CanExecute(null)) |
| 37 | await _vm.OpenThemeFileCommand.ExecuteAsync(null); |
| 38 | return "OK"; |
| 39 | }); |
| 40 | add(SetUiLanguage, async (args, _) => |
| 41 | { |
| 42 | var cult = McpCommandJsonArgs.String(args, "culture") ?? McpCommandJsonArgs.String(args, "ci"); |
| 43 | if (string.IsNullOrWhiteSpace(cult)) |
| 44 | return "Missing culture (e.g. ru-RU, en-US)"; |
| 45 | var c = cult.Trim(); |
| 46 | if (_vm.SetUiLanguageCommand.CanExecute(c)) |
| 47 | _vm.SetUiLanguageCommand.Execute(c); |
| 48 | return "OK"; |
| 49 | }); |
| 50 | add(ResetUiLanguageToSystem, async (_, _) => |
| 51 | { |
| 52 | if (_vm.ResetUiLanguageToSystemCommand.CanExecute(null)) |
| 53 | _vm.ResetUiLanguageToSystemCommand.Execute(null); |
| 54 | return "OK"; |
| 55 | }); |
| 56 | } |
| 57 | } |
| 58 | |