diff --git a/AxialSqlTools/AxialSqlTools.csproj b/AxialSqlTools/AxialSqlTools.csproj
index b567e7b..fa66a93 100644
--- a/AxialSqlTools/AxialSqlTools.csproj
+++ b/AxialSqlTools/AxialSqlTools.csproj
@@ -143,6 +143,8 @@
+
+
@@ -404,6 +406,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
diff --git a/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml b/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml
index 0ba5480..b91b57f 100644
--- a/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml
+++ b/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml
@@ -4,19 +4,37 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0"
- mc:Ignorable="d" FontSize="14"
- Name="MyToolWindow">
-
+ mc:Ignorable="d"
+ Name="MyToolWindow"
+ Background="{DynamicResource AxialThemeBackgroundBrush}"
+ Foreground="{DynamicResource AxialThemeForegroundBrush}">
+
+
+
+
+
+
+
+
+
-
- Data Transfer
+
+
+ Data Transfer
+
+
+
+
+
+
+
-
-
-
+
@@ -27,11 +45,11 @@
-
+
-
+
@@ -73,8 +91,8 @@
-
-
+
+
@@ -87,7 +105,7 @@
-
+
@@ -143,8 +161,8 @@
-
-
+
+
@@ -158,7 +176,7 @@
-
+
@@ -214,8 +232,8 @@
-
-
+
+
@@ -260,7 +278,7 @@
-
+
@@ -285,8 +303,8 @@
-
-
+
+
@@ -331,7 +349,7 @@
-
+
@@ -356,8 +374,8 @@
-
-
+
+
@@ -375,3 +393,4 @@
+
diff --git a/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml.cs b/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml.cs
index 11b8f65..fec8243 100644
--- a/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml.cs
+++ b/AxialSqlTools/DataTransfer/DataTransferWindowControl.xaml.cs
@@ -17,6 +17,8 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
+ using System.Windows.Media;
+ using System.Windows.Navigation;
///
/// Interaction logic for DataTransferWindowControl.
@@ -26,6 +28,7 @@ public partial class DataTransferWindowControl : UserControl
private CancellationTokenSource _cancellationTokenSource;
private Stopwatch stopwatch;
+ private readonly ToolWindowThemeController _themeController;
private string sourceConnectionString = "";
private string targetConnectionString = "";
@@ -69,6 +72,7 @@ public static int GetRowsCopied(SqlBulkCopy bulkCopy)
public DataTransferWindowControl()
{
this.InitializeComponent();
+ _themeController = new ToolWindowThemeController(this, ApplyThemeBrushResources);
Button_CopyData.IsEnabled = false;
ButtonToPsql_CopyData.IsEnabled = false;
@@ -109,6 +113,26 @@ public DataTransferWindowControl()
}
+ private void ApplyThemeBrushResources()
+ {
+ ToolWindowThemeResources.ApplySharedTheme(this);
+ }
+
+ private void WikiLink_RequestNavigate(object sender, RequestNavigateEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(e.Uri?.AbsoluteUri))
+ {
+ return;
+ }
+
+ Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)
+ {
+ UseShellExecute = true,
+ });
+
+ e.Handled = true;
+ }
+
private void Button_EditSavedConnections_Click(object sender, RoutedEventArgs e)
{
var window = new SavedConnectionManagerWindow
diff --git a/AxialSqlTools/Modules/ToolWindowThemeSupport.cs b/AxialSqlTools/Modules/ToolWindowThemeSupport.cs
new file mode 100644
index 0000000..88f9ddc
--- /dev/null
+++ b/AxialSqlTools/Modules/ToolWindowThemeSupport.cs
@@ -0,0 +1,197 @@
+namespace AxialSqlTools
+{
+ using System;
+ using System.Windows;
+ using System.Windows.Media;
+ using Microsoft.VisualStudio.PlatformUI;
+ using Microsoft.VisualStudio.Shell;
+
+ internal static class ToolWindowThemeResources
+ {
+ public static void ApplySharedTheme(FrameworkElement control)
+ {
+ Brush bg = VsThemeBrushResolver.ResolveBrush(control, EnvironmentColors.ToolWindowBackgroundBrushKey)
+ ?? SystemColors.WindowBrush;
+ Brush fg = VsThemeBrushResolver.ResolveBrush(control, EnvironmentColors.ToolWindowTextBrushKey)
+ ?? SystemColors.WindowTextBrush;
+ Brush border = VsThemeBrushResolver.ResolveBrush(control, EnvironmentColors.ToolWindowBorderBrushKey)
+ ?? SystemColors.ActiveBorderBrush;
+ Brush link = VsThemeBrushResolver.ResolveBrush(control, EnvironmentColors.ControlLinkTextBrushKey)
+ ?? SystemColors.HotTrackBrush;
+ Brush accent = VsThemeBrushResolver.ResolveEnvironmentBrushByName(control, "MainWindowActiveDefaultBorderBrushKey")
+ ?? VsThemeBrushResolver.ResolveEnvironmentBrushByName(control, "SystemAccentBrushKey")
+ ?? border;
+ Brush success = VsThemeBrushResolver.ResolveEnvironmentBrushByName(control, "SystemGreenTextBrushKey")
+ ?? new SolidColorBrush(Color.FromRgb(0x10, 0x7C, 0x10));
+ Brush error = VsThemeBrushResolver.ResolveEnvironmentBrushByName(control, "SystemRedTextBrushKey")
+ ?? new SolidColorBrush(Color.FromRgb(0xA1, 0x26, 0x0D));
+
+ Color bgColor = VsThemeBrushResolver.GetBrushColor(bg, Colors.White);
+ Color accentColor = VsThemeBrushResolver.GetBrushColor(accent, Color.FromRgb(0x00, 0x7A, 0xCC));
+ Color errorColor = VsThemeBrushResolver.GetBrushColor(error, Color.FromRgb(0xA1, 0x26, 0x0D));
+ bool isLightTheme = VsThemeBrushResolver.GetRelativeLuminance(bgColor) > 0.6;
+
+ Color headerColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.04)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.04);
+ Color tabHeaderColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.05)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.06);
+ Color tabHoverColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.10)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.12);
+ Color tabSelectedColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.16)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.18);
+ Color buttonBackgroundColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.06)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.08);
+ Color buttonHoverColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.14)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.10);
+ Color buttonPressedColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.22)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.18);
+ Color subtleBorderColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.16)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.14);
+ Color primaryHoverColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(accentColor, Colors.White, 0.10)
+ : VsThemeBrushResolver.BlendColors(accentColor, Colors.White, 0.14);
+ Color primaryPressedColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(accentColor, Colors.Black, 0.12)
+ : VsThemeBrushResolver.BlendColors(accentColor, Colors.Black, 0.16);
+ Color primaryForegroundColor = VsThemeBrushResolver.GetRelativeLuminance(accentColor) > 0.55
+ ? Colors.Black
+ : Colors.White;
+ Color dangerHoverColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(errorColor, Colors.White, 0.08)
+ : VsThemeBrushResolver.BlendColors(errorColor, Colors.White, 0.10);
+ Color dangerPressedColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(errorColor, Colors.Black, 0.12)
+ : VsThemeBrushResolver.BlendColors(errorColor, Colors.Black, 0.16);
+ Color dangerForegroundColor = VsThemeBrushResolver.GetRelativeLuminance(errorColor) > 0.55
+ ? Colors.Black
+ : Colors.White;
+ Color gridHeaderColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.03)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.08);
+ Color gridAlternateRowColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.02)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.04);
+ Color gridSelectionColor = isLightTheme
+ ? VsThemeBrushResolver.BlendColors(bgColor, Colors.Black, 0.12)
+ : VsThemeBrushResolver.BlendColors(bgColor, Colors.White, 0.14);
+
+ control.Resources["AxialThemeBackgroundBrush"] = bg;
+ control.Resources["AxialThemeForegroundBrush"] = fg;
+ control.Resources["AxialThemeBorderBrush"] = border;
+ control.Resources["AxialThemeSubtleBorderBrush"] = new SolidColorBrush(subtleBorderColor);
+ control.Resources["AxialThemeHeaderBackgroundBrush"] = new SolidColorBrush(headerColor);
+ control.Resources["AxialThemeLinkBrush"] = link;
+ control.Resources["AxialThemeAccentBrush"] = new SolidColorBrush(accentColor);
+ control.Resources["AxialThemeStatusErrorBrush"] = error;
+ control.Resources["AxialThemeStatusSuccessBrush"] = success;
+ control.Resources["AxialThemeTabHeaderBackgroundBrush"] = new SolidColorBrush(tabHeaderColor);
+ control.Resources["AxialThemeTabHeaderHoverBrush"] = new SolidColorBrush(tabHoverColor);
+ control.Resources["AxialThemeTabHeaderSelectedBrush"] = new SolidColorBrush(tabSelectedColor);
+ control.Resources["AxialThemeButtonBackgroundBrush"] = new SolidColorBrush(buttonBackgroundColor);
+ control.Resources["AxialThemeButtonHoverBrush"] = new SolidColorBrush(buttonHoverColor);
+ control.Resources["AxialThemeButtonPressedBrush"] = new SolidColorBrush(buttonPressedColor);
+ control.Resources["AxialThemePrimaryButtonBackgroundBrush"] = new SolidColorBrush(accentColor);
+ control.Resources["AxialThemePrimaryButtonHoverBrush"] = new SolidColorBrush(primaryHoverColor);
+ control.Resources["AxialThemePrimaryButtonPressedBrush"] = new SolidColorBrush(primaryPressedColor);
+ control.Resources["AxialThemePrimaryButtonForegroundBrush"] = new SolidColorBrush(primaryForegroundColor);
+ control.Resources["AxialThemeDangerButtonBackgroundBrush"] = new SolidColorBrush(errorColor);
+ control.Resources["AxialThemeDangerButtonHoverBrush"] = new SolidColorBrush(dangerHoverColor);
+ control.Resources["AxialThemeDangerButtonPressedBrush"] = new SolidColorBrush(dangerPressedColor);
+ control.Resources["AxialThemeDangerButtonForegroundBrush"] = new SolidColorBrush(dangerForegroundColor);
+ control.Resources["AxialThemeGridHeaderBackgroundBrush"] = new SolidColorBrush(gridHeaderColor);
+ control.Resources["AxialThemeGridAlternateRowBrush"] = new SolidColorBrush(gridAlternateRowColor);
+ control.Resources["AxialThemeGridSelectionBrush"] = new SolidColorBrush(gridSelectionColor);
+ }
+ }
+
+ internal sealed class ToolWindowThemeController : IDisposable
+ {
+ private readonly FrameworkElement control;
+ private readonly Action applyTheme;
+ private bool isThemeSubscribed;
+
+ public ToolWindowThemeController(FrameworkElement control, Action applyTheme)
+ {
+ this.control = control ?? throw new ArgumentNullException(nameof(control));
+ this.applyTheme = applyTheme ?? throw new ArgumentNullException(nameof(applyTheme));
+
+ this.control.Loaded += OnLoaded;
+ this.control.Unloaded += OnUnloaded;
+ this.control.IsVisibleChanged += OnIsVisibleChanged;
+
+ this.applyTheme();
+ }
+
+ private void OnLoaded(object sender, RoutedEventArgs e)
+ {
+ ThreadHelper.ThrowIfNotOnUIThread();
+
+ applyTheme();
+ SubscribeToThemeChanges();
+ }
+
+ private void OnUnloaded(object sender, RoutedEventArgs e)
+ {
+ UnsubscribeFromThemeChanges();
+ }
+
+ private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ ThreadHelper.ThrowIfNotOnUIThread();
+
+ if (control.IsVisible)
+ {
+ applyTheme();
+ }
+ }
+
+ private void SubscribeToThemeChanges()
+ {
+ if (isThemeSubscribed)
+ {
+ return;
+ }
+
+ VSColorTheme.ThemeChanged += OnVsThemeChanged;
+ isThemeSubscribed = true;
+ }
+
+ private void UnsubscribeFromThemeChanges()
+ {
+ if (!isThemeSubscribed)
+ {
+ return;
+ }
+
+ VSColorTheme.ThemeChanged -= OnVsThemeChanged;
+ isThemeSubscribed = false;
+ }
+
+ private void OnVsThemeChanged(ThemeChangedEventArgs e)
+ {
+ if (!control.Dispatcher.CheckAccess())
+ {
+ control.Dispatcher.BeginInvoke(new Action(applyTheme));
+ return;
+ }
+
+ applyTheme();
+ }
+
+ public void Dispose()
+ {
+ control.Loaded -= OnLoaded;
+ control.Unloaded -= OnUnloaded;
+ control.IsVisibleChanged -= OnIsVisibleChanged;
+ UnsubscribeFromThemeChanges();
+ }
+ }
+}
diff --git a/AxialSqlTools/Modules/VsThemeBrushResolver.cs b/AxialSqlTools/Modules/VsThemeBrushResolver.cs
new file mode 100644
index 0000000..7465b49
--- /dev/null
+++ b/AxialSqlTools/Modules/VsThemeBrushResolver.cs
@@ -0,0 +1,66 @@
+namespace AxialSqlTools
+{
+ using System;
+ using System.Reflection;
+ using System.Windows;
+ using System.Windows.Media;
+ using Microsoft.VisualStudio.PlatformUI;
+
+ internal static class VsThemeBrushResolver
+ {
+ public static Brush ResolveBrush(FrameworkElement scope, object resourceKey)
+ {
+ if (resourceKey == null)
+ {
+ return null;
+ }
+
+ return scope?.TryFindResource(resourceKey) as Brush
+ ?? Application.Current?.TryFindResource(resourceKey) as Brush;
+ }
+
+ public static Brush ResolveEnvironmentBrushByName(FrameworkElement scope, string keyName)
+ {
+ if (string.IsNullOrWhiteSpace(keyName))
+ {
+ return null;
+ }
+
+ PropertyInfo property = typeof(EnvironmentColors).GetProperty(keyName, BindingFlags.Public | BindingFlags.Static);
+ object key = property?.GetValue(null);
+ return ResolveBrush(scope, key);
+ }
+
+ public static Color GetBrushColor(Brush brush, Color fallback)
+ {
+ if (brush is SolidColorBrush solidBrush)
+ {
+ return solidBrush.Color;
+ }
+
+ return fallback;
+ }
+
+ public static double GetRelativeLuminance(Color color)
+ {
+ double r = color.R / 255.0;
+ double g = color.G / 255.0;
+ double b = color.B / 255.0;
+
+ double rLinear = r <= 0.03928 ? r / 12.92 : Math.Pow((r + 0.055) / 1.055, 2.4);
+ double gLinear = g <= 0.03928 ? g / 12.92 : Math.Pow((g + 0.055) / 1.055, 2.4);
+ double bLinear = b <= 0.03928 ? b / 12.92 : Math.Pow((b + 0.055) / 1.055, 2.4);
+
+ return 0.2126 * rLinear + 0.7152 * gLinear + 0.0722 * bLinear;
+ }
+
+ public static Color BlendColors(Color baseColor, Color blendColor, double blendAmount)
+ {
+ blendAmount = Math.Max(0.0, Math.Min(1.0, blendAmount));
+ byte r = (byte)Math.Round((baseColor.R * (1.0 - blendAmount)) + (blendColor.R * blendAmount));
+ byte g = (byte)Math.Round((baseColor.G * (1.0 - blendAmount)) + (blendColor.G * blendAmount));
+ byte b = (byte)Math.Round((baseColor.B * (1.0 - blendAmount)) + (blendColor.B * blendAmount));
+ return Color.FromRgb(r, g, b);
+ }
+ }
+}
\ No newline at end of file
diff --git a/AxialSqlTools/QueryHistory/QueryHistoryWindowCommand.cs b/AxialSqlTools/QueryHistory/QueryHistoryWindowCommand.cs
index cd06d63..2f19552 100644
--- a/AxialSqlTools/QueryHistory/QueryHistoryWindowCommand.cs
+++ b/AxialSqlTools/QueryHistory/QueryHistoryWindowCommand.cs
@@ -90,14 +90,27 @@ private void Execute(object sender, EventArgs e)
{
await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
- ToolWindowPane window = await this.package.ShowToolWindowAsync(typeof(QueryHistoryWindow), 0, true, this.package.DisposalToken);
- if ((null == window) || (null == window.Frame))
+ try
{
- throw new NotSupportedException("Cannot create tool window");
- }
+ ToolWindowPane window = await this.package.ShowToolWindowAsync(typeof(QueryHistoryWindow), 0, true, this.package.DisposalToken);
+ if ((null == window) || (null == window.Frame))
+ {
+ throw new NotSupportedException("Cannot create tool window");
+ }
- IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
- windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
+ IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
+ windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
+ }
+ catch (Exception ex)
+ {
+ VsShellUtilities.ShowMessageBox(
+ this.package,
+ "Failed to open Query History. " + ex.Message,
+ "Axial SQL Tools",
+ OLEMSGICON.OLEMSGICON_CRITICAL,
+ OLEMSGBUTTON.OLEMSGBUTTON_OK,
+ OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
+ }
});
}
diff --git a/AxialSqlTools/QueryHistory/QueryHistoryWindowControl.xaml b/AxialSqlTools/QueryHistory/QueryHistoryWindowControl.xaml
index 5b8e13e..e827582 100644
--- a/AxialSqlTools/QueryHistory/QueryHistoryWindowControl.xaml
+++ b/AxialSqlTools/QueryHistory/QueryHistoryWindowControl.xaml
@@ -7,9 +7,39 @@
mc:Ignorable="d"
d:DesignHeight="800"
d:DesignWidth="1000"
- Name="MyToolWindow">
+ Name="MyToolWindow"
+ Background="{DynamicResource AxialThemeBackgroundBrush}"
+ Foreground="{DynamicResource AxialThemeForegroundBrush}">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -57,7 +87,7 @@
-
@@ -70,11 +100,12 @@
@@ -101,7 +132,11 @@
ItemsSource="{Binding QueryHistoryRecords}"
SelectedItem="{Binding SelectedRecord, Mode=TwoWay}"
AutoGenerateColumns="False"
- SelectionMode="Single">
+ SelectionMode="Single"
+ Style="{DynamicResource AxialThemedDataGridStyle}"
+ ColumnHeaderStyle="{DynamicResource AxialThemedDataGridColumnHeaderStyle}"
+ CellStyle="{DynamicResource AxialThemedDataGridCellStyle}"
+ RowStyle="{DynamicResource AxialThemedDataGridRowStyle}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml b/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml
index 6d60236..8b909ee 100644
--- a/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml
+++ b/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml
@@ -4,20 +4,31 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
- Name="MyToolWindow">
+ Name="MyToolWindow"
+ Background="{DynamicResource AxialThemeBackgroundBrush}"
+ Foreground="{DynamicResource AxialThemeForegroundBrush}">
+
+
+
+
+
+
+
+
-
+
+ Background="{DynamicResource AxialThemeHeaderBackgroundBrush}"
+ Padding="12" BorderBrush="{DynamicResource AxialThemeBorderBrush}" BorderThickness="0,0,0,1">
+ HorizontalAlignment="Left"/>
@@ -68,11 +79,9 @@
FontWeight="Bold"
HorizontalAlignment="Left">
-
+
+
+
@@ -165,11 +174,9 @@
FontWeight="Bold"
HorizontalAlignment="Left">
-
+
+
+
@@ -275,11 +282,9 @@
Margin="5"
FontWeight="Bold" HorizontalAlignment="Left">
-
+
+
+
@@ -381,11 +386,9 @@
HorizontalAlignment="Left"
FontWeight="Bold">
-
+
+
+
@@ -504,11 +507,9 @@
HorizontalAlignment="Left"
FontWeight="Bold">
-
+
+
+
@@ -567,7 +568,9 @@
@@ -652,11 +655,9 @@
VerticalAlignment="Top"
FontWeight="Bold">
-
+
+
+
@@ -707,11 +708,9 @@
VerticalAlignment="Top"
FontWeight="Bold">
-
+
+
+
diff --git a/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml.cs b/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml.cs
index 89a965e..8e12a77 100644
--- a/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml.cs
+++ b/AxialSqlTools/WindowSettings/SettingsWindowControl.xaml.cs
@@ -24,6 +24,7 @@ public partial class SettingsWindowControl : UserControl
{
private string _queryHistoryConnectionString;
+ private readonly ToolWindowThemeController _themeController;
private string tsqlFormatExample = @"while (1=0)
begin
@@ -49,6 +50,7 @@ public SettingsWindowControl()
{
this.InitializeComponent();
+ _themeController = new ToolWindowThemeController(this, ApplyThemeBrushResources);
LoadSavedSettings();
this.Loaded += UserControl_Loaded;
@@ -64,6 +66,31 @@ private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
LoadSavedSettings();
}
+ private void ApplyThemeBrushResources()
+ {
+ ToolWindowThemeResources.ApplySharedTheme(this);
+
+ ApplyGoogleSheetsAuthorizationBrush();
+ }
+
+ private Brush GetThemedStatusBrush(bool isSuccess)
+ {
+ string key = isSuccess ? "AxialThemeStatusSuccessBrush" : "AxialThemeStatusErrorBrush";
+ return Resources[key] as Brush
+ ?? (isSuccess ? new SolidColorBrush(Color.FromRgb(0x10, 0x7C, 0x10)) : new SolidColorBrush(Color.FromRgb(0xA1, 0x26, 0x0D)));
+ }
+
+ private void ApplyGoogleSheetsAuthorizationBrush()
+ {
+ if (GoogleSheetsRefreshTokenLabel == null)
+ {
+ return;
+ }
+
+ bool isAuthorized = string.Equals(GoogleSheetsRefreshTokenLabel.Text, "Authorized", StringComparison.OrdinalIgnoreCase);
+ GoogleSheetsRefreshTokenLabel.Foreground = GetThemedStatusBrush(isAuthorized);
+ }
+
private void LoadSavedSettings()
{
try
@@ -413,12 +440,12 @@ private void UpdateGoogleSheetsStatus(string refreshToken)
if (string.IsNullOrWhiteSpace(refreshToken))
{
GoogleSheetsRefreshTokenLabel.Text = "Not authorized";
- GoogleSheetsRefreshTokenLabel.Foreground = new SolidColorBrush(Colors.DarkRed);
+ GoogleSheetsRefreshTokenLabel.Foreground = GetThemedStatusBrush(false);
}
else
{
GoogleSheetsRefreshTokenLabel.Text = "Authorized";
- GoogleSheetsRefreshTokenLabel.Foreground = new SolidColorBrush(Colors.DarkGreen);
+ GoogleSheetsRefreshTokenLabel.Foreground = GetThemedStatusBrush(true);
}
}
diff --git a/AxialSqlTools/source.extension.vsixmanifest b/AxialSqlTools/source.extension.vsixmanifest
index 00dbdb2..7a0add2 100644
--- a/AxialSqlTools/source.extension.vsixmanifest
+++ b/AxialSqlTools/source.extension.vsixmanifest
@@ -10,7 +10,7 @@
Resources\vsix-logo.png
Resources\vsix-logo.png
-
+
amd64