Files
Wino-Mail/Wino.Mail/App.xaml.cs

85 lines
2.6 KiB
C#
Raw Permalink Normal View History

2024-07-20 23:32:39 +02:00
using System;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
2024-07-20 23:32:39 +02:00
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Windows.Storage;
using Wino.Domain;
using Wino.Domain.Interfaces;
using Wino.Shared.WinRT.Services;
2024-07-20 23:32:39 +02:00
using Wino.Views;
using WinUIEx;
namespace Wino
{
2024-07-20 23:32:39 +02:00
public partial class App : Application
{
2024-07-20 23:32:39 +02:00
private WindowEx m_Window;
private Frame m_ShellFrame;
private readonly IApplicationConfiguration _applicationFolderConfiguration;
public App()
{
2024-07-20 23:32:39 +02:00
if (WebAuthenticator.CheckOAuthRedirectionActivation()) return;
2024-07-20 23:32:39 +02:00
InitializeComponent();
Services = ConfigureServices();
2024-07-20 23:32:39 +02:00
_applicationFolderConfiguration = Services.GetService<IApplicationConfiguration>();
_logInitializer = Services.GetService<ILogInitializer>();
ConfigureLogger();
ConfigureAppCenter();
ConfigurePrelaunch();
ConfigureXbox();
// Make sure the paths are setup on app start.
_applicationFolderConfiguration.ApplicationDataFolderPath = ApplicationData.Current.LocalFolder.Path;
_applicationFolderConfiguration.PublisherSharedFolderPath = ApplicationData.Current.GetPublisherCacheFolder(Constants.SharedFolderName).Path;
_themeService = Services.GetService<IThemeService>();
_databaseService = Services.GetService<IDatabaseService>();
_translationService = Services.GetService<ITranslationService>();
_appShellService = Services.GetService<IAppShellService>();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
2024-07-20 23:32:39 +02:00
ConfigureWindow();
2024-07-20 23:32:39 +02:00
_appShellService.AppWindow = m_Window;
foreach (var service in initializeServices)
{
await service.InitializeAsync();
}
2024-07-20 23:32:39 +02:00
m_ShellFrame.Navigate(typeof(AppShell));
m_Window.Activate();
2024-07-22 11:05:04 +02:00
// Launch server
var serverConnectionManager = Services.GetService<IWinoServerConnectionManager>();
await serverConnectionManager.ConnectAsync();
}
2024-07-20 23:32:39 +02:00
private void ConfigureWindow()
{
2024-07-20 23:32:39 +02:00
m_Window = new WindowEx
{
2024-07-20 23:32:39 +02:00
SystemBackdrop = new MicaBackdrop(),
ExtendsContentIntoTitleBar = true,
MinWidth = 420
};
2024-07-20 23:32:39 +02:00
m_ShellFrame = new Frame();
2024-07-20 23:32:39 +02:00
m_Window.Content = m_ShellFrame;
}
}
}