Forge
csharpdeeb25a2
1using Avalonia;
2using Avalonia.Controls;
3using Avalonia.Media;
4using CascadeIDE.Cockpit.PrimitivesKit;
5
6namespace CascadeIDE.Views;
7
8/// <summary>
9/// Лампа CascadeChord «CMD + зелёная полоса» (ADR 0060): отрисовка через
10/// <see cref="CommandArmedStripLampFace"/> — не дублировать палитру/геометрию в AXAML (ADR 0064/0066).
11/// </summary>
12public sealed class CommandArmedStripLampCell : Control
13{
14 public static readonly StyledProperty<bool> IsArmedProperty =
15 AvaloniaProperty.Register<CommandArmedStripLampCell, bool>(nameof(IsArmed));
16
17 static CommandArmedStripLampCell()
18 {
19 AffectsRender<CommandArmedStripLampCell>(IsArmedProperty);
20 FocusableProperty.OverrideDefaultValue<CommandArmedStripLampCell>(false);
21 }
22
23 public bool IsArmed
24 {
25 get => GetValue(IsArmedProperty);
26 set => SetValue(IsArmedProperty, value);
27 }
28
29 protected override Size MeasureOverride(Size availableSize)
30 {
31 return new Size(
32 AnnunciatorLampMetrics.DefaultCellWidth + 4,
33 AnnunciatorLampMetrics.DefaultCellHeight + 4);
34 }
35
36 public override void Render(DrawingContext context)
37 {
38 base.Render(context);
39 var w = Bounds.Width;
40 var h = Bounds.Height;
41 if (w <= 0 || h <= 0)
42 return;
43
44 var cell = AnnunciatorLampMetrics.DefaultCellWidth;
45 var x = (w - cell) / 2;
46 var y = (h - cell) / 2;
47 var outer = new Rect(x, y, cell, cell);
48 new CommandArmedStripLampFace(IsArmed).Draw(context, outer);
49 }
50}
51
View only · write via MCP/CIDE