Skip to content

Commit

Permalink
Move activator to App's OnLaunched() override
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jun 22, 2024
1 parent a37d229 commit 2fb7f90
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions CollapseLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,32 @@ public partial class App

public App()
{
try
if (DebugSettings != null)
{
DebugSettings!.XamlResourceReferenceFailed += (sender, args) => { LogWriteLine($"[XAML_RES_REFERENCE] Sender: {sender}\r\n{args!.Message}", LogType.Error, true); };
#if ENABLEFRAMECOUNTER
DebugSettings.EnableFrameRateCounter = true;
#endif
#if DEBUG
DebugSettings.LayoutCycleDebugBreakLevel = LayoutCycleDebugBreakLevel.High;
DebugSettings.LayoutCycleTracingLevel = LayoutCycleTracingLevel.High;
DebugSettings.IsXamlResourceReferenceTracingEnabled = true;
DebugSettings.IsBindingTracingEnabled = true;
#endif
DebugSettings.XamlResourceReferenceFailed += (sender, args) => { LogWriteLine($"[XAML_RES_REFERENCE] Sender: {sender}\r\n{args!.Message}", LogType.Error, true); };
DebugSettings.BindingFailed += (sender, args) => { LogWriteLine($"[XAML_BINDING] Sender: {sender}\r\n{args!.Message}", LogType.Error, true); };
UnhandledException += (sender, e) => { LogWriteLine($"[XAML_OTHER] Sender: {sender}\r\n{e!.Exception} {e.Exception!.InnerException}", LogType.Error, true); };

}

RequestedTheme = IsAppThemeLight ? ApplicationTheme.Light : ApplicationTheme.Dark;
SetPreferredAppMode(ShouldAppsUseDarkMode() ? PreferredAppMode.AllowDark : PreferredAppMode.Default);

this.InitializeComponent();
}

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
try
{
ThemeChangerInvoker.ThemeEvent += (_, _) => {
WindowUtility.ApplyWindowTitlebarLegacyColor();
bool isThemeLight = IsAppThemeLight;
Expand All @@ -39,11 +59,8 @@ public App()
WindowUtility.CurrentAppWindow!.TitleBar!.ButtonInactiveBackgroundColor = color;
if (WindowUtility.CurrentWindow!.Content is not null and FrameworkElement frameworkElement)
frameworkElement.RequestedTheme = isThemeLight ? ElementTheme.Light : ElementTheme.Dark; };

this.InitializeComponent();
RequestedTheme = IsAppThemeLight ? ApplicationTheme.Light : ApplicationTheme.Dark;
SetPreferredAppMode(ShouldAppsUseDarkMode() ? PreferredAppMode.AllowDark : PreferredAppMode.Default);
frameworkElement.RequestedTheme = isThemeLight ? ElementTheme.Light : ElementTheme.Dark;
};

Check warning on line 63 in CollapseLauncher/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Incorrect indent (around child statement)

Line indent is not restored to the previous level around child statement

Window toInitializeWindow = null;
switch (m_appMode)
Expand Down

0 comments on commit 2fb7f90

Please sign in to comment.