Files
Wino-Mail/Wino.Mail.WinUI/WelcomeWindow.xaml.cs
T

78 lines
1.9 KiB
C#
Raw Normal View History

2026-03-05 10:12:03 +01:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Windowing;
2026-03-20 12:43:09 +01:00
using Microsoft.UI.Xaml;
2026-03-05 10:12:03 +01:00
using Microsoft.UI.Xaml.Controls;
using Wino.Core.Domain.Interfaces;
2026-04-05 13:18:50 +02:00
using Wino.Mail.WinUI.Helpers;
2026-03-20 12:43:09 +01:00
using Wino.Mail.WinUI.Interfaces;
2026-03-05 10:12:03 +01:00
using WinUIEx;
namespace Wino.Mail.WinUI;
public sealed partial class WelcomeWindow : WindowEx
{
2026-03-20 12:43:09 +01:00
private bool _allowClose;
2026-04-05 13:18:50 +02:00
private bool _isPreparedForClose;
2026-03-20 12:43:09 +01:00
2026-03-05 10:12:03 +01:00
public Frame GetRootFrame() => RootFrame;
public WelcomeWindow()
{
InitializeComponent();
MinWidth = 980;
MinHeight = 900;
Title = "Wino Mail";
this.SetIcon("Assets/Wino_Icon.ico");
ConfigureWindowChrome();
2026-03-20 12:43:09 +01:00
AppWindow.Closing += OnAppWindowClosing;
2026-04-05 13:18:50 +02:00
Closed += OnWindowClosed;
2026-03-05 10:12:03 +01:00
}
private void ConfigureWindowChrome()
{
AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
Width = 980;
Height = 720;
this.CenterOnScreen();
var themeService = WinoApplication.Current.Services.GetService<INewThemeService>();
themeService?.UpdateSystemCaptionButtonColors();
}
2026-03-20 12:43:09 +01:00
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;
}
2026-04-05 13:18:50 +02:00
public void PrepareForClose()
{
if (_isPreparedForClose)
return;
_isPreparedForClose = true;
WindowCleanupHelper.CleanupFrame(RootFrame);
}
private void OnWindowClosed(object sender, WindowEventArgs e)
{
Closed -= OnWindowClosed;
AppWindow.Closing -= OnAppWindowClosing;
PrepareForClose();
}
2026-03-05 10:12:03 +01:00
}