Forge
csharpdeeb25a2
1#nullable enable
2using Avalonia;
3using Avalonia.Styling;
4using SkiaSharp;
5
6namespace CascadeIDE.Views.SkiaKit;
7
8/// <summary>Мост CascadeTheme (Avalonia) → <see cref="SkiaKitPaintTheme"/>.</summary>
9internal static class SkiaKitThemeBridge
10{
11 public static class Keys
12 {
13 public const string PanelBackground = "CascadeTheme.ChatPanelBackground";
14 public const string BubbleBackground = "CascadeTheme.ChatMessageBubbleBackground";
15 public const string LabelForeground = "CascadeTheme.ChatLabelForeground";
16 public const string ContentForeground = "CascadeTheme.ChatMessageContentForeground";
17 public const string ColumnBorder = "CascadeTheme.EditorColumnBorderBrush";
18 public const string Accent = "CascadeTheme.PanelTitleAccentBrush";
19 }
20
21 public static SkiaKitPaintTheme ResolveIdeSurface(StyledElement element)
22 {
23 var theme = SkiaKitPaintTheme.DarkFallback;
24 var hasBubble = SkiaKitColor.TrySkColor(element, Keys.BubbleBackground, out var bubble);
25 if (hasBubble)
26 theme = theme with { Surface = SkiaKitColor.Darken(bubble, 0.92f) };
27
28 if (SkiaKitColor.TrySkColor(element, Keys.PanelBackground, out var panelBg))
29 theme = theme with { Surface = panelBg };
30 else if (hasBubble)
31 theme = theme with { Surface = SkiaKitColor.Darken(bubble, 0.92f) };
32
33 if (SkiaKitColor.TrySkColor(element, Keys.LabelForeground, out var label))
34 theme = theme with { Role = label };
35 if (SkiaKitColor.TrySkColor(element, Keys.ContentForeground, out var body))
36 theme = theme with { Content = body };
37 if (SkiaKitColor.TrySkColor(element, Keys.ColumnBorder, out var edge))
38 theme = theme with { Border = edge };
39
40 if (SkiaKitColor.TrySkColor(element, Keys.Accent, out var accent))
41 {
42 theme = theme with { HoverBorder = accent };
43 theme = theme with
44 {
45 SelectedBorder = SkiaKitColor.Blend(accent, new SKColor(255, 255, 255), 0.35f)
46 };
47 }
48
49 var emptyHint = SkiaKitColor.Blend(theme.Content, theme.Role, 0.58f);
50 return theme with { EmptyHint = emptyHint };
51 }
52}
53
View only · write via MCP/CIDE