Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 25854cf

Browse files
committed
Load settings before window initialization
Now the UI won't show the light theme at startup when the dark was selected.
1 parent b8108aa commit 25854cf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

RaceControl/RaceControl/App.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ namespace RaceControl
3838
{
3939
public partial class App
4040
{
41+
private static readonly ResourceDictionary LightTheme = new() { Source = new Uri(@"/Themes/LightTheme.xaml", UriKind.Relative) };
42+
private static readonly ResourceDictionary DarkTheme = new() { Source = new Uri(@"/Themes/DarkTheme.xaml", UriKind.Relative) };
43+
4144
private readonly SplashScreen _splashScreen = new("splashscreen.png");
4245

4346
private static int _flyleafUniqueId;
@@ -100,6 +103,12 @@ protected override void RegisterTypes(IContainerRegistry registry)
100103

101104
protected override Window CreateShell()
102105
{
106+
var settings = Container.Resolve<ISettings>();
107+
settings.Load();
108+
109+
App.Current.Resources.MergedDictionaries.Clear();
110+
App.Current.Resources.MergedDictionaries.Add(settings.UseDarkTheme ? DarkTheme : LightTheme);
111+
103112
_splashScreen.Close(TimeSpan.Zero);
104113

105114
return Container.Resolve<MainWindow>();

RaceControl/RaceControl/ViewModels/MainWindowViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ public Track SelectedAudioTrack
291291
private void LoadedExecute(RoutedEventArgs args)
292292
{
293293
IsBusy = true;
294-
Settings.Load();
295294
VideoDialogLayout.Load();
296295
UpdateThemeCommand.TryExecute();
297296
SetVlcExeLocation();

0 commit comments

Comments
 (0)