Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions src/modules/Workspaces/WorkspacesEditor/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,55 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WorkspacesEditor"
xmlns:ui="http://schemas.modernwpf.com/2019"
Exit="OnExit"
Startup="OnStartup">
Startup="OnStartup"
ThemeMode="System">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources />
<ui:XamlControlsResources />
<ResourceDictionary Source="pack://application:,,,/Styles/ButtonStyles.xaml" />
</ResourceDictionary.MergedDictionaries>

<FontFamily x:Key="SymbolThemeFontFamily">Segoe Fluent Icons, Segoe MDL2 Assets</FontFamily>
<Style x:Key="HeadingTextBlock" TargetType="TextBlock" />
<Style
x:Key="SubtleButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="Border"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="True">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
28 changes: 22 additions & 6 deletions src/modules/Workspaces/WorkspacesEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Globalization;
using System.Threading;
using System.Windows;
using Common.UI;
using ManagedCommon;
using Microsoft.PowerToys.Telemetry;
using Microsoft.Win32;
using WorkspacesEditor.Telemetry;
using WorkspacesEditor.Utils;
using WorkspacesEditor.ViewModels;
Expand All @@ -28,8 +28,6 @@ public partial class App : Application, IDisposable

private MainViewModel _mainViewModel;

public static ThemeManager ThemeManager { get; set; }

private bool _isDisposed;

private ETWTrace etwTrace = new ETWTrace();
Expand Down Expand Up @@ -92,8 +90,6 @@ private void OnStartup(object sender, StartupEventArgs e)
});
}

ThemeManager = new ThemeManager(this);

if (_mainViewModel == null)
{
_mainViewModel = new MainViewModel(WorkspacesEditorIO);
Expand All @@ -116,6 +112,27 @@ private void OnStartup(object sender, StartupEventArgs e)
_mainWindow.Topmost = false;
}

public static Theme GetCurrentTheme()
{
if (SystemParameters.HighContrast)
{
return Theme.HighContrastOne;
}

try
{
var useLightTheme = Registry.GetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
"AppsUseLightTheme",
1);
return (useLightTheme is int value && value == 0) ? Theme.Dark : Theme.Light;
}
catch
{
return Theme.Light;
}
}

private void OnExit(object sender, ExitEventArgs e)
{
if (_instanceMutex != null)
Expand All @@ -138,7 +155,6 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
ThemeManager?.Dispose();
_instanceMutex?.Dispose();
etwTrace?.Dispose();
}
Expand Down
Loading
Loading