Native tray icon implementation.
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Mail.WinUI.Interfaces;
|
||||
using WinUIEx;
|
||||
|
||||
namespace Wino.Mail.WinUI;
|
||||
|
||||
public sealed partial class WelcomeWindow : WindowEx
|
||||
{
|
||||
private bool _allowClose;
|
||||
|
||||
public Frame GetRootFrame() => RootFrame;
|
||||
|
||||
public WelcomeWindow()
|
||||
@@ -20,6 +24,7 @@ public sealed partial class WelcomeWindow : WindowEx
|
||||
this.SetIcon("Assets/Wino_Icon.ico");
|
||||
|
||||
ConfigureWindowChrome();
|
||||
AppWindow.Closing += OnAppWindowClosing;
|
||||
}
|
||||
|
||||
private void ConfigureWindowChrome()
|
||||
@@ -34,4 +39,20 @@ public sealed partial class WelcomeWindow : WindowEx
|
||||
var themeService = WinoApplication.Current.Services.GetService<INewThemeService>();
|
||||
themeService?.UpdateSystemCaptionButtonColors();
|
||||
}
|
||||
|
||||
private void OnAppWindowClosing(object sender, AppWindowClosingEventArgs e)
|
||||
{
|
||||
if (_allowClose || (Application.Current as App)?.IsExiting == true)
|
||||
return;
|
||||
|
||||
e.Cancel = true;
|
||||
|
||||
var windowManager = WinoApplication.Current.Services.GetService<IWinoWindowManager>();
|
||||
windowManager?.HideWindow(this);
|
||||
}
|
||||
|
||||
public void AllowClose()
|
||||
{
|
||||
_allowClose = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user