Skip to content

Commit 059180d

Browse files
Merge pull request #890 from ClaudioESSilva/fix/improve-themes
Fix - Improve themes on grids and plan viewer
2 parents cd2bc05 + 6ded45b commit 059180d

13 files changed

Lines changed: 404 additions & 82 deletions

Dashboard/Controls/FinOpsContent.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<DataTrigger Binding="{Binding Severity}" Value="Low">
112112
<Setter Property="Foreground" Value="#27AE60"/>
113113
</DataTrigger>
114+
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow, AncestorLevel=1}, FallbackValue=False}" Value="True">
115+
<Setter Property="Foreground" Value="{DynamicResource GridSelectionForegroundBrush}"/>
116+
</DataTrigger>
114117
</Style.Triggers>
115118
</Style>
116119
</DataGridTextColumn.ElementStyle>
@@ -416,6 +419,9 @@
416419
<Setter Property="Foreground" Value="#E74C3C"/>
417420
<Setter Property="FontWeight" Value="SemiBold"/>
418421
</DataTrigger>
422+
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow, AncestorLevel=1}, FallbackValue=False}" Value="True">
423+
<Setter Property="Foreground" Value="{DynamicResource GridSelectionForegroundBrush}"/>
424+
</DataTrigger>
419425
</Style.Triggers>
420426
</Style>
421427
</DataGridTextColumn.ElementStyle>

Dashboard/Controls/PlanViewerControl.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@
7777

7878
<!-- Missing Indexes (center) -->
7979
<Border Grid.Column="1" Padding="10,4,10,8"
80-
Background="#3D2A0E"
81-
BorderBrush="#7A5A1E" BorderThickness="0,0,1,0">
80+
Background="{DynamicResource PlanMissingIndexBgBrush}"
81+
BorderBrush="{DynamicResource PlanMissingIndexBorderBrush}" BorderThickness="0,0,1,0">
8282
<ScrollViewer VerticalScrollBarVisibility="Auto"
8383
HorizontalScrollBarVisibility="Disabled">
8484
<StackPanel>
8585
<TextBlock x:Name="MissingIndexHeader"
8686
Text="Missing Index Suggestions"
8787
FontSize="13"
88-
FontWeight="SemiBold" Foreground="#FFB347"
88+
FontWeight="SemiBold" Foreground="{DynamicResource PlanMissingIndexHeaderBrush}"
8989
Margin="0,0,0,6"/>
9090
<StackPanel x:Name="MissingIndexContent"/>
9191
<TextBlock x:Name="MissingIndexEmpty"
@@ -98,14 +98,14 @@
9898

9999
<!-- Wait Stats (right, fills remaining space) -->
100100
<Border Grid.Column="2" Padding="10,4,10,8"
101-
Background="#1A2A3D">
101+
Background="{DynamicResource PlanWaitStatsBgBrush}">
102102
<ScrollViewer VerticalScrollBarVisibility="Auto"
103103
HorizontalScrollBarVisibility="Disabled">
104104
<StackPanel>
105105
<TextBlock x:Name="WaitStatsHeader"
106106
Text="Wait Stats"
107107
FontSize="13"
108-
FontWeight="SemiBold" Foreground="#4FA3FF"
108+
FontWeight="SemiBold" Foreground="{DynamicResource PlanWaitStatsHeaderBrush}"
109109
Margin="0,0,0,6"/>
110110
<StackPanel x:Name="WaitStatsContent"/>
111111
<TextBlock x:Name="WaitStatsEmpty"

Dashboard/Controls/PlanViewerControl.xaml.cs

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,27 @@ public partial class PlanViewerControl : UserControl
3131
private Border? _selectedNodeBorder;
3232
private Brush? _selectedNodeOriginalBorder;
3333
private Thickness _selectedNodeOriginalThickness;
34+
private PlanNode? _selectedNode;
3435

35-
// Brushes
36+
// Brushes — accent/neutral tones that suit every theme
3637
private static readonly SolidColorBrush SelectionBrush = new(Color.FromRgb(0x4F, 0xA3, 0xFF));
37-
private static readonly SolidColorBrush TooltipBgBrush = new(Color.FromRgb(0x1A, 0x1D, 0x23));
38-
private static readonly SolidColorBrush TooltipBorderBrush = new(Color.FromRgb(0x3A, 0x3D, 0x45));
39-
private static readonly SolidColorBrush TooltipFgBrush = new(Color.FromRgb(0xE4, 0xE6, 0xEB));
40-
private static readonly SolidColorBrush MutedBrush = new(Color.FromRgb(0xE4, 0xE6, 0xEB));
4138
private static readonly SolidColorBrush EdgeBrush = new(Color.FromRgb(0x6B, 0x72, 0x80));
42-
private static readonly SolidColorBrush SectionHeaderBrush = new(Color.FromRgb(0x4F, 0xA3, 0xFF));
43-
private static readonly SolidColorBrush PropSeparatorBrush = new(Color.FromRgb(0x2A, 0x2D, 0x35));
4439
private static readonly SolidColorBrush OrangeBrush = new(Color.FromRgb(0xFF, 0xB3, 0x47));
4540

41+
// Theme-aware brushes resolved at call time from Application.Resources
42+
private SolidColorBrush TooltipBgBrush =>
43+
(TryFindResource("PlanTooltipBgBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0x1A, 0x1D, 0x23));
44+
private SolidColorBrush TooltipBorderBrush =>
45+
(TryFindResource("PlanTooltipBorderBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0x3A, 0x3D, 0x45));
46+
private SolidColorBrush TooltipFgBrush =>
47+
(TryFindResource("PlanPanelTextBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0xE4, 0xE6, 0xEB));
48+
private SolidColorBrush MutedBrush =>
49+
(TryFindResource("PlanPanelMutedBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0xE4, 0xE6, 0xEB));
50+
private SolidColorBrush SectionHeaderBrush =>
51+
(TryFindResource("PlanSectionHeaderBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0x4F, 0xA3, 0xFF));
52+
private SolidColorBrush PropSeparatorBrush =>
53+
(TryFindResource("PlanPropSeparatorBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromRgb(0x2A, 0x2D, 0x35));
54+
4655
// Current property section for collapsible groups
4756
private StackPanel? _currentPropertySection;
4857

@@ -55,6 +64,28 @@ public partial class PlanViewerControl : UserControl
5564
public PlanViewerControl()
5665
{
5766
InitializeComponent();
67+
Helpers.ThemeManager.ThemeChanged += OnThemeChanged;
68+
Unloaded += (_, _) => Helpers.ThemeManager.ThemeChanged -= OnThemeChanged;
69+
}
70+
71+
private void OnThemeChanged(string _)
72+
{
73+
if (_currentStatement == null) return;
74+
75+
var nodeToRestore = _selectedNode;
76+
RenderStatement(_currentStatement);
77+
78+
if (nodeToRestore == null) return;
79+
80+
// Find the re-created border for the previously selected node and reopen properties
81+
foreach (var child in PlanCanvas.Children)
82+
{
83+
if (child is Border b && b.Tag == nodeToRestore)
84+
{
85+
SelectNode(b, nodeToRestore);
86+
break;
87+
}
88+
}
5889
}
5990

6091
public void LoadPlan(string planXml, string label, string? queryText = null)
@@ -488,14 +519,14 @@ void AddRow(string label, string value)
488519
var lbl = new TextBlock
489520
{
490521
Text = label,
491-
Foreground = new SolidColorBrush(Color.FromRgb(0xE0, 0xE0, 0xE0)),
522+
Foreground = MutedBrush,
492523
FontSize = 12,
493524
Margin = new Thickness(0, 1, 12, 1)
494525
};
495526
var val = new TextBlock
496527
{
497528
Text = value,
498-
Foreground = new SolidColorBrush(Colors.White),
529+
Foreground = TooltipFgBrush,
499530
FontSize = 12,
500531
FontWeight = FontWeights.SemiBold,
501532
HorizontalAlignment = HorizontalAlignment.Right,
@@ -528,8 +559,8 @@ void AddRow(string label, string value)
528559

529560
return new Border
530561
{
531-
Background = new SolidColorBrush(Color.FromRgb(0x1E, 0x1E, 0x2E)),
532-
BorderBrush = new SolidColorBrush(Color.FromRgb(0x3A, 0x3A, 0x5A)),
562+
Background = TooltipBgBrush,
563+
BorderBrush = TooltipBorderBrush,
533564
BorderThickness = new Thickness(1),
534565
Padding = new Thickness(10, 6, 10, 6),
535566
CornerRadius = new CornerRadius(4),
@@ -571,6 +602,7 @@ private void SelectNode(Border border, PlanNode node)
571602
_selectedNodeOriginalBorder = border.BorderBrush;
572603
_selectedNodeOriginalThickness = border.BorderThickness;
573604
_selectedNodeBorder = border;
605+
_selectedNode = node;
574606
border.BorderBrush = SelectionBrush;
575607
border.BorderThickness = new Thickness(2);
576608

@@ -1504,7 +1536,7 @@ private void AddPropertySection(string title)
15041536
Margin = new Thickness(0, 2, 0, 0),
15051537
Padding = new Thickness(0),
15061538
Foreground = SectionHeaderBrush,
1507-
Background = new SolidColorBrush(Color.FromArgb(0x18, 0x4F, 0xA3, 0xFF)),
1539+
Background = (TryFindResource("BackgroundLighterBrush") as SolidColorBrush) ?? new SolidColorBrush(Color.FromArgb(0x18, 0x4F, 0xA3, 0xFF)),
15081540
BorderBrush = PropSeparatorBrush,
15091541
BorderThickness = new Thickness(0, 0, 0, 1)
15101542
};
@@ -1568,6 +1600,7 @@ private void ClosePropertiesPanel()
15681600
_selectedNodeBorder.BorderThickness = _selectedNodeOriginalThickness;
15691601
_selectedNodeBorder = null;
15701602
}
1603+
_selectedNode = null;
15711604
}
15721605

15731606
#endregion
@@ -1780,7 +1813,7 @@ private ToolTip BuildNodeTooltip(PlanNode node, List<PlanWarning>? allWarnings =
17801813
return tip;
17811814
}
17821815

1783-
private static void AddTooltipSection(StackPanel parent, string title)
1816+
private void AddTooltipSection(StackPanel parent, string title)
17841817
{
17851818
parent.Children.Add(new TextBlock
17861819
{
@@ -1792,7 +1825,7 @@ private static void AddTooltipSection(StackPanel parent, string title)
17921825
});
17931826
}
17941827

1795-
private static void AddTooltipRow(StackPanel parent, string label, string value, bool isCode = false)
1828+
private void AddTooltipRow(StackPanel parent, string label, string value, bool isCode = false)
17961829
{
17971830
var row = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 1, 0, 1) };
17981831
row.Children.Add(new TextBlock
@@ -1835,19 +1868,19 @@ private void ShowMissingIndexes(List<MissingIndex> indexes)
18351868
{
18361869
Text = mi.Table,
18371870
FontWeight = FontWeights.SemiBold,
1838-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E6EB")),
1871+
Foreground = TooltipFgBrush,
18391872
FontSize = 12
18401873
});
18411874
headerRow.Children.Add(new TextBlock
18421875
{
18431876
Text = $" \u2014 Impact: ",
1844-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E6EB")),
1877+
Foreground = MutedBrush,
18451878
FontSize = 12
18461879
});
18471880
headerRow.Children.Add(new TextBlock
18481881
{
18491882
Text = $"{mi.Impact:F1}%",
1850-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFB347")),
1883+
Foreground = OrangeBrush,
18511884
FontSize = 12
18521885
});
18531886
itemPanel.Children.Add(headerRow);
@@ -1859,7 +1892,7 @@ private void ShowMissingIndexes(List<MissingIndex> indexes)
18591892
Text = mi.CreateStatement,
18601893
FontFamily = new FontFamily("Consolas"),
18611894
FontSize = 11,
1862-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E6EB")),
1895+
Foreground = TooltipFgBrush,
18631896
Background = Brushes.Transparent,
18641897
BorderThickness = new Thickness(0),
18651898
IsReadOnly = true,
@@ -1932,7 +1965,7 @@ private void ShowWaitStats(List<WaitStatInfo> waits, bool isActualPlan)
19321965
{
19331966
Text = w.WaitType,
19341967
FontSize = 12,
1935-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E6EB")),
1968+
Foreground = TooltipFgBrush,
19361969
VerticalAlignment = VerticalAlignment.Center,
19371970
Margin = new Thickness(0, 2, 10, 2)
19381971
};
@@ -1958,7 +1991,7 @@ private void ShowWaitStats(List<WaitStatInfo> waits, bool isActualPlan)
19581991
{
19591992
Text = $"{w.WaitTimeMs:N0}ms ({w.WaitCount:N0} waits)",
19601993
FontSize = 12,
1961-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E6EB")),
1994+
Foreground = TooltipFgBrush,
19621995
VerticalAlignment = VerticalAlignment.Center,
19631996
Margin = new Thickness(0, 2, 0, 2)
19641997
};
@@ -2014,8 +2047,8 @@ private void ShowRuntimeSummary(PlanStatement statement)
20142047
{
20152048
RuntimeSummaryContent.Children.Clear();
20162049

2017-
var labelColor = "#E4E6EB";
2018-
var valueColor = "#E4E6EB";
2050+
var labelBrush = MutedBrush;
2051+
var valueBrush = TooltipFgBrush;
20192052

20202053
var grid = new Grid();
20212054
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
@@ -2030,7 +2063,7 @@ void AddRow(string label, string value)
20302063
{
20312064
Text = label,
20322065
FontSize = 11,
2033-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(labelColor)),
2066+
Foreground = labelBrush,
20342067
HorizontalAlignment = HorizontalAlignment.Left,
20352068
Margin = new Thickness(0, 1, 8, 1)
20362069
};
@@ -2042,7 +2075,7 @@ void AddRow(string label, string value)
20422075
{
20432076
Text = value,
20442077
FontSize = 11,
2045-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(valueColor)),
2078+
Foreground = valueBrush,
20462079
Margin = new Thickness(0, 1, 0, 1)
20472080
};
20482081
Grid.SetRow(valueText, rowIndex);

0 commit comments

Comments
 (0)