| 1 | namespace CascadeIDE.Services.Presentation; |
| 2 | |
| 3 | /// <summary> |
| 4 | /// Снимок флагов пресета <c>presentation</c> — единый источник для VM и тестов (ADR 0017). |
| 5 | /// </summary> |
| 6 | public readonly record struct PresentationTopologyFlags( |
| 7 | bool DedicatedMfdSecondScreen, |
| 8 | bool TripleOneAnchorPerZone, |
| 9 | bool ForwardMfdTwoScreen, |
| 10 | bool PmForwardTwoScreen) |
| 11 | { |
| 12 | /// <summary>Нужен <see cref="Views.MfdHostWindow"/> (второй TopLevel с MFD).</summary> |
| 13 | public bool MfdHostTopology => |
| 14 | DedicatedMfdSecondScreen || TripleOneAnchorPerZone || ForwardMfdTwoScreen; |
| 15 | |
| 16 | /// <summary>Нужен <see cref="Views.PfdHostWindow"/> (тройной пресет по одному якорю на экран).</summary> |
| 17 | public bool PfdHostTopology => TripleOneAnchorPerZone; |
| 18 | |
| 19 | /// <summary>Нужен <see cref="Views.PmSplitHostWindow"/>.</summary> |
| 20 | public bool PmHostTopology => PmForwardTwoScreen; |
| 21 | } |
| 22 | |
| 23 | /// <summary>Разбор строки <c>presentation</c> в флаги хостов и кадр <c>MainGrid</c>.</summary> |
| 24 | public static class PresentationTopologyResolver |
| 25 | { |
| 26 | public static PresentationTopologyFlags ResolveFlags(PresentationParseResult parse) |
| 27 | { |
| 28 | if (!parse.IsSuccess || parse.Screens.Count == 0) |
| 29 | return default; |
| 30 | |
| 31 | return ResolveFlags(parse.Screens); |
| 32 | } |
| 33 | |
| 34 | public static PresentationTopologyFlags ResolveFlags( |
| 35 | IReadOnlyList<IReadOnlyList<PresentationAnchorSlot>> screens) => |
| 36 | new( |
| 37 | PresentationLayoutAnalyzer.IsDedicatedMfdSecondScreenPreset(screens), |
| 38 | PresentationLayoutAnalyzer.IsTripleOneAnchorPerZonePreset(screens), |
| 39 | PresentationLayoutAnalyzer.IsForwardMfdTwoScreenPreset(screens), |
| 40 | PresentationLayoutAnalyzer.IsPmPlusForwardTwoScreenPreset(screens)); |
| 41 | |
| 42 | /// <summary> |
| 43 | /// Кадр колонок главного окна при типичном старте: хосты PFD/MFD открыты и подавляют свои колонки в main. |
| 44 | /// </summary> |
| 45 | public static PresentationMainGridLayoutFrame BuildMainWindowGridAtStartup( |
| 46 | PresentationParseResult parse, |
| 47 | PresentationTopologyFlags flags) |
| 48 | { |
| 49 | var mainIdx = PresentationLayoutAnalyzer.GetMainWindowPresentationScreenIndexOrDefault(parse); |
| 50 | return PresentationMainGridLayoutFrameBuilder.Build( |
| 51 | parse, |
| 52 | flags.DedicatedMfdSecondScreen, |
| 53 | mfdColumnSuppressedForHost: flags.MfdHostTopology, |
| 54 | flags.TripleOneAnchorPerZone, |
| 55 | suppressPfdColumnForPfdHostWindow: flags.PfdHostTopology, |
| 56 | mainIdx); |
| 57 | } |
| 58 | } |
| 59 | |