Files
@ 35683a714f6b
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/App.axaml.cs - annotation
35683a714f6b
2.5 KiB
text/x-csharp
Added tag R_T10_1.0 for changeset f419334a476f
40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 40eaee10ae56 | using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using DesertPaintCodex.Services;
using DesertPaintCodex.Views;
namespace DesertPaintCodex
{
internal class App : Application
{
private WelcomeView? _welcomeView;
private MainWindow? _mainWindow;
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
ShowWelcomeView();
base.OnFrameworkInitializationCompleted();
}
public void ReturnToWelcome()
{
ShowWelcomeView();
CloseMainWindow();
}
private void ShowWelcomeView()
{
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
_welcomeView = new WelcomeView();
_welcomeView.Closed += OnWelcomeViewClosed;
_welcomeView.Show();
}
private void ShowMainWindow()
{
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
desktop.ShutdownMode = ShutdownMode.OnMainWindowClose;
_mainWindow = new MainWindow();
_mainWindow.Closing += _mainWindow.OnMainWindowClosing;
desktop.MainWindow = _mainWindow;
desktop.MainWindow.Show();
}
private void Shutdown()
{
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
desktop.Shutdown();
}
private void CloseMainWindow()
{
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
if (_mainWindow != null)
{
desktop.MainWindow.Closing -= _mainWindow.OnMainWindowClosing;
}
desktop.MainWindow.Close();
_mainWindow = null;
desktop.MainWindow = null;
}
private void OnWelcomeViewClosed(object? obj, EventArgs args)
{
if (_welcomeView != null) _welcomeView.Closed -= OnWelcomeViewClosed;
_welcomeView = null;
if (ProfileManager.CurrentProfile == null)
{
Shutdown();
}
else
{
ShowMainWindow();
}
}
}
}
|