Files
@ d6859ea7177f
Branch filter:
Location: ATITD-Tools/Desert-Paint-Codex/App.axaml.cs - annotation
d6859ea7177f
2.8 KiB
text/x-csharp
Add some sanity checks on min/max concentration and min/max reagents in recipe generation. Also, clear out the search queue when generation has finished so the queue isn't loaded next time. This fixes the start/resume button state when entering the recipe generator after a prior run had finished.
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 a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a a5faa82faf6a 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();
}
public void RefreshMainWindow()
{
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return;
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
CloseMainWindow();
ShowMainWindow();
}
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();
}
}
}
}
|