Fix: AutoHideStartup's bug of displaying window before hiding it.

This commit is contained in:
Waheal 2025-10-06 21:11:37 +08:00
parent 9c58fec8d4
commit 22e0364b33
3 changed files with 24 additions and 1 deletions

View file

@ -274,7 +274,7 @@ public class MainWindowViewModel : MyReactiveObject
BlReloadEnabled = true; BlReloadEnabled = true;
await Reload(); await Reload();
await AutoHideStartup(); // await AutoHideStartup();
} }
#endregion Init #endregion Init
@ -576,6 +576,7 @@ public class MainWindowViewModel : MyReactiveObject
await CoreManager.Instance.LoadCore(node); await CoreManager.Instance.LoadCore(node);
} }
/*
private async Task AutoHideStartup() private async Task AutoHideStartup()
{ {
if (_config.UiItem.AutoHideStartup) if (_config.UiItem.AutoHideStartup)
@ -584,6 +585,7 @@ public class MainWindowViewModel : MyReactiveObject
} }
await Task.CompletedTask; await Task.CompletedTask;
} }
*/
#endregion core job #endregion core job

View file

@ -31,6 +31,12 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight }; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
if (_config.UiItem.AutoHideStartup)
{
this.ShowActivated = false;
this.WindowState = WindowState.Minimized;
}
this.KeyDown += MainWindow_KeyDown; this.KeyDown += MainWindow_KeyDown;
menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click;
menuPromotion.Click += menuPromotion_Click; menuPromotion.Click += menuPromotion_Click;
@ -438,6 +444,11 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
protected override void OnLoaded(object? sender, RoutedEventArgs e) protected override void OnLoaded(object? sender, RoutedEventArgs e)
{ {
base.OnLoaded(sender, e); base.OnLoaded(sender, e);
if (_config.UiItem.AutoHideStartup)
{
this.ShowHideWindow(false);
_config.UiItem.ShowInTaskbar = true;
}
RestoreUI(); RestoreUI();
} }

View file

@ -25,6 +25,12 @@ public partial class MainWindow
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false); ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
if (_config.UiItem.AutoHideStartup)
{
this.ShowActivated = false;
this.WindowState = WindowState.Minimized;
}
App.Current.SessionEnding += Current_SessionEnding; App.Current.SessionEnding += Current_SessionEnding;
this.Closing += MainWindow_Closing; this.Closing += MainWindow_Closing;
this.PreviewKeyDown += MainWindow_PreviewKeyDown; this.PreviewKeyDown += MainWindow_PreviewKeyDown;
@ -390,6 +396,10 @@ public partial class MainWindow
protected override void OnLoaded(object? sender, RoutedEventArgs e) protected override void OnLoaded(object? sender, RoutedEventArgs e)
{ {
base.OnLoaded(sender, e); base.OnLoaded(sender, e);
if (_config.UiItem.AutoHideStartup)
{
ShowHideWindow(false);
}
RestoreUI(); RestoreUI();
} }