Skip to content

Commit

Permalink
Optimize applying the theme
Browse files Browse the repository at this point in the history
- Don't re-apply the theme when opening the configuration or wizard. It's already applied at that time.
- Apply the theme before first Showing the MainWindow. This fixes an issue with the default material theme being shown until the connectors are loaded.
  • Loading branch information
steffen-wilke committed Feb 11, 2020
1 parent 060fe9c commit adeb7d2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/Soloplan.WhatsON.GUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public void ApplyTheme(bool? isDark = null)

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

var configDirArg = e.Args.FirstOrDefault(a => a.ToLower().StartsWith(ConfigDirArgName.ToLower()));
if (configDirArg != null)
{
Expand Down Expand Up @@ -112,10 +110,17 @@ protected override void OnStartup(StartupEventArgs e)
this.themeHelper.Initialize(this.handler.VisualSettings?.ColorSettings);
this.ApplyTheme();

if (!this.config.OpenMinimized)
{
this.handler.ShowOrHideWindow();
}

Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 15 });

this.scheduler.Start();
ComponentDispatcher.ThreadPreprocessMessage += this.ComponentDispatcherThreadPreprocessMessage;

base.OnStartup(e);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Soloplan.WhatsON.GUI/Configuration/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<TextBlock TextWrapping="Wrap" Text="Configuration:" Margin="20,0,20,10" FontWeight="Bold"/>

<DockPanel Margin="20,0,20,20">
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}" Content="{x:Static properties:Resources.Export}" DockPanel.Dock="Right" Click="ExportButtonClick"/>
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}" Content="{x:Static properties:Resources.Import}" Margin="10,0,10,0" DockPanel.Dock="Right" Click="ImportButtonClick"/>
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}" Content="{x:Static properties:Resources.Export}" DockPanel.Dock="Right" VerticalAlignment="Center" Click="ExportButtonClick"/>
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}" Content="{x:Static properties:Resources.Import}" Margin="10,0,10,0" DockPanel.Dock="Right" VerticalAlignment="Center" Click="ImportButtonClick"/>
<TextBox x:Name="ConfigFile" Text="{}{CONFIG_FILE}" IsReadOnly="True" DockPanel.Dock="Left"/>
</DockPanel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ protected override void OnContentRendered(EventArgs e)
}

this.windowShown = true;
((App)Application.Current).ApplyTheme(this.configurationSource.DarkThemeEnabled);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ protected override void OnContentRendered(EventArgs e)
}

this.windowShown = true;
var app = (App)Application.Current;
app.ApplyTheme(app.IsDarkThemeEnabled);
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions src/Soloplan.WhatsON.GUI/TrayHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public TrayHandler(ObservationScheduler scheduler, ApplicationConfiguration conf
{
this.VisualSettings = SerializationHelper.Load<MainWindowSettings>(Path.Combine(SerializationHelper.Instance.ConfigFolder, MainWindow.VisualSettingsFile));
}

if (!this.configuration.OpenMinimized)
{
this.ShowOrHideWindow();
}
}

public MainWindowSettings VisualSettings { get; private set; }
Expand Down Expand Up @@ -219,7 +214,7 @@ private void OnCloseApplicationClick(object sender, EventArgs e)
/// <summary>
/// Handles showing and hiding main window.
/// </summary>
private void ShowOrHideWindow()
public void ShowOrHideWindow()
{
if (this.MainWindowVisible)
{
Expand Down

0 comments on commit adeb7d2

Please sign in to comment.