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

60 lines
2.1 KiB
C#
Raw Normal View History

2025-09-29 19:09:48 +02:00
using System;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
2025-09-29 11:16:14 +02:00
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
2025-09-29 19:09:48 +02:00
using Wino.Core.Domain.Interfaces;
using Wino.Core.WinUI;
2025-09-29 11:16:14 +02:00
using Wino.Core.WinUI.Interfaces;
2025-09-29 19:09:48 +02:00
using Wino.Messaging.Client.Mails;
2025-09-29 11:16:14 +02:00
using Wino.Views;
using WinUIEx;
namespace Wino.Mail.WinUI;
public sealed partial class ShellWindow : WindowEx, IWinoShellWindow
{
2025-09-29 19:09:48 +02:00
public IStatePersistanceService StatePersistanceService { get; } = WinoApplication.Current.Services.GetService<IStatePersistanceService>() ?? throw new Exception("StatePersistanceService not registered in DI container.");
public IPreferencesService PreferencesService { get; } = WinoApplication.Current.Services.GetService<IPreferencesService>() ?? throw new Exception("PreferencesService not registered in DI container.");
2025-09-29 11:16:14 +02:00
public ShellWindow()
{
InitializeComponent();
2025-09-29 19:09:48 +02:00
MinWidth = 420;
MinHeight = 420;
2025-09-29 11:16:14 +02:00
ConfigureTitleBar();
}
private void ConfigureTitleBar()
{
AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
}
public void HandleAppActivation(LaunchActivatedEventArgs args)
{
// TODO: Handle protocol activations.
MainShellFrame.Navigate(typeof(AppShell));
}
public Microsoft.UI.Xaml.Controls.TitleBar GetTitleBar() => ShellTitleBar;
public Frame GetMainFrame() => MainShellFrame;
2025-09-29 19:09:48 +02:00
public FrameworkElement GetRootContent() => Content as Grid ?? throw new Exception("RootContent is not a Grid or empty.");
private void BackButtonClicked(Microsoft.UI.Xaml.Controls.TitleBar sender, object args)
{
WeakReferenceMessenger.Default.Send(new ClearMailSelectionsRequested());
WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested());
}
private void MainFrameNavigated(object sender, Microsoft.UI.Xaml.Navigation.NavigationEventArgs e) => ShellTitleBar.Content = (e.Content as BasePage).ShellContent;
private void PaneButtonClicked(Microsoft.UI.Xaml.Controls.TitleBar sender, object args)
{
PreferencesService.IsNavigationPaneOpened = !PreferencesService.IsNavigationPaneOpened;
}
2025-09-29 11:16:14 +02:00
}