| 1 | using System.Threading; |
| 2 | |
| 3 | namespace CascadeIDE.ViewModels; |
| 4 | |
| 5 | /// <summary>Колбэки и провайдеры, которые View подставляет в главный VM (диалоги, UI automation).</summary> |
| 6 | public partial class MainWindowViewModel |
| 7 | { |
| 8 | private Func<int?, Services.EditorStateDto?>? _editorStateProvider; |
| 9 | private Func<int, int, string?>? _editorContentRangeProvider; |
| 10 | private Action<string, int, int, int, int, string>? _applyEditAction; |
| 11 | private Action? _focusEditorAction; |
| 12 | private Action<string?, int, int, int?>? _revealEditorRangeAction; |
| 13 | |
| 14 | public void SetEditorStateProvider(Func<int?, Services.EditorStateDto?> provider) => _editorStateProvider = provider; |
| 15 | public void SetEditorContentRangeProvider(Func<int, int, string?> provider) => _editorContentRangeProvider = provider; |
| 16 | public void SetApplyEdit(Action<string, int, int, int, int, string> action) => _applyEditAction = action; |
| 17 | public void SetFocusEditor(Action action) => _focusEditorAction = action; |
| 18 | public void SetRevealEditorRange(Action<string?, int, int, int?> action) => _revealEditorRangeAction = action; |
| 19 | |
| 20 | /// <summary>Вызвать, чтобы показать диалог «Открыть решение» (View подставит реализацию).</summary> |
| 21 | public Action? RequestOpenSolution { get; set; } |
| 22 | /// <summary>Вызвать, чтобы создать новое пустое решение (<c>dotnet new sln</c> после диалога «Сохранить как»).</summary> |
| 23 | public Action? RequestCreateNewSolution { get; set; } |
| 24 | /// <summary>Вызвать, чтобы показать диалог «Открыть папку» (workspace без .sln).</summary> |
| 25 | public Action? RequestOpenFolder { get; set; } |
| 26 | /// <summary>Вызвать, чтобы показать диалог «Открыть файл» (View подставит реализацию).</summary> |
| 27 | public Action? RequestOpenFile { get; set; } |
| 28 | /// <summary>Вызвать для закрытия окна (View подставит Close).</summary> |
| 29 | public Action? RequestClose { get; set; } |
| 30 | /// <summary>Показать «О программе» (View подставит диалог).</summary> |
| 31 | public Action? RequestShowAbout { get; set; } |
| 32 | /// <summary>Полное окно настроек (все секции): при <c>[ai.chat].settings_presentation = window</c>, из кнопки «Все настройки…» на странице AI во вторичном контуре.</summary> |
| 33 | public Action? RequestOpenSettings { get; set; } |
| 34 | /// <summary>Открыть или активировать окно-хост зоны Mfd — второй <c>TopLevel</c> (см. ADR 0017).</summary> |
| 35 | public Action? RequestToggleMfdHostWindow { get; set; } |
| 36 | /// <summary>Открыть или активировать окно-хост зоны Pfd при тройном пресете (ADR 0017).</summary> |
| 37 | public Action? RequestTogglePfdHostWindow { get; set; } |
| 38 | /// <summary>Открыть или активировать окно сплита P+M при пресете <c>(xP+yM)(F)</c> (ADR 0017).</summary> |
| 39 | public Action? RequestTogglePmSplitHostWindow { get; set; } |
| 40 | /// <summary>Показать диалог выбора файла темы (.json). Возвращает путь к файлу или null.</summary> |
| 41 | public Func<Task<string?>>? RequestOpenThemeFile { get; set; } |
| 42 | /// <summary>Показать превью Markdown в отдельном окне (контент от агента).</summary> |
| 43 | public Action<string, string>? RequestShowMarkdownPreviewWindow { get; set; } |
| 44 | /// <summary>Показать превью текущего редактора в отдельном окне (живое обновление).</summary> |
| 45 | public Action? RequestShowMarkdownPreviewForEditor { get; set; } |
| 46 | /// <summary>Показать подтверждение пользователю. Возвращает "ok" или "cancel".</summary> |
| 47 | public Func<string, CancellationToken, Task<string>>? RequestConfirmation { get; set; } |
| 48 | /// <summary>Поставщик снимка дерева UI (View подставит вызов UiLayoutSnapshot.BuildJson).</summary> |
| 49 | public Func<string>? GetUiLayoutProvider { get; set; } |
| 50 | public Func<string>? GetColorsUnderCursorProvider { get; set; } |
| 51 | public Func<string?, string>? GetControlAppearanceProvider { get; set; } |
| 52 | public Func<string, string, string>? SetControlLayoutProvider { get; set; } |
| 53 | public Func<string, string, string?, string?, string>? AddControlProvider { get; set; } |
| 54 | public Func<string, string, string>? SetControlTextProvider { get; set; } |
| 55 | public Func<string?, string>? ClickControlProvider { get; set; } |
| 56 | public Func<string?, string, string>? SendKeysProvider { get; set; } |
| 57 | public Func<string?, string>? SetFocusProvider { get; set; } |
| 58 | public Func<string?, string>? HighlightControlProvider { get; set; } |
| 59 | public Func<string, double?, double?, string>? SetPanelSizeProvider { get; set; } |
| 60 | |
| 61 | /// <summary>Выбор .dll/.exe для запуска под отладчиком. Возвращает полный путь или null.</summary> |
| 62 | public Func<Task<string?>>? RequestPickDebugTarget { get; set; } |
| 63 | |
| 64 | /// <summary>Ввод PID для attach. Возвращает PID или null.</summary> |
| 65 | public Func<Task<int?>>? RequestAttachProcessId { get; set; } |
| 66 | |
| 67 | /// <summary>Простой информационный диалог (заголовок, текст).</summary> |
| 68 | public Func<string, string, Task>? RequestShowInfoAsync { get; set; } |
| 69 | |
| 70 | /// <summary>Показать выбор одного документа фичи (список путей) и вернуть выбранный путь.</summary> |
| 71 | public Func<string, IReadOnlyList<string>, Task<string?>>? RequestPickFeatureDocAsync { get; set; } |
| 72 | |
| 73 | /// <summary>Сохранить файл Markdown (View показывает SaveFile dialog). Возвращает выбранный путь или null.</summary> |
| 74 | public Func<string?, Task<string?>>? RequestSaveMarkdownFile { get; set; } |
| 75 | |
| 76 | /// <summary>MCP <c>capture_window</c>: PNG (по умолчанию главное окно; при <c>scope=all</c> — все top-level). Подставляет <see cref="Views.MainWindow"/>.</summary> |
| 77 | public Func<string?, string?, string?, Task<string>>? CaptureWindowForMcpAsync { get; set; } |
| 78 | } |
| 79 | |