2025-08-13 20:13:40 -07:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2025-08-06 17:03:37 -07:00
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Styling;
|
2025-08-13 20:13:40 -07:00
|
|
|
using Avalonia.Threading;
|
|
|
|
|
using MercuryConverter.UI.Dialogs;
|
|
|
|
|
using MercuryConverter.UI.Views;
|
2025-08-06 17:03:37 -07:00
|
|
|
|
2025-08-11 23:02:15 -07:00
|
|
|
namespace MercuryConverter.UI;
|
2025-08-06 17:03:37 -07:00
|
|
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2025-08-13 20:13:40 -07:00
|
|
|
public static MainWindow? Instance { get; private set; }
|
|
|
|
|
private bool initialShown = false;
|
|
|
|
|
|
2025-08-06 17:03:37 -07:00
|
|
|
public MainWindow()
|
|
|
|
|
{
|
2025-08-13 20:13:40 -07:00
|
|
|
Instance = this;
|
2025-08-06 17:03:37 -07:00
|
|
|
InitializeComponent();
|
2025-08-19 00:27:53 -07:00
|
|
|
DataContext = this;
|
2025-08-06 17:03:37 -07:00
|
|
|
|
|
|
|
|
// Force dark mode in designer
|
|
|
|
|
if (Design.IsDesignMode)
|
|
|
|
|
{
|
|
|
|
|
RequestedThemeVariant = ThemeVariant.Dark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup tab views
|
|
|
|
|
SelectionControl.Content = new Selection();
|
2025-08-13 20:13:40 -07:00
|
|
|
|
|
|
|
|
// Show dialog on startup
|
|
|
|
|
Activated += OnActivated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnActivated(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (initialShown) return;
|
|
|
|
|
initialShown = true;
|
|
|
|
|
|
|
|
|
|
Dialog.DialogContent = new Welcome().Content;
|
|
|
|
|
Dialog.IsOpen = true;
|
2025-08-06 17:03:37 -07:00
|
|
|
}
|
2025-08-19 00:27:53 -07:00
|
|
|
|
|
|
|
|
public void OpenDataHandler()
|
|
|
|
|
{
|
|
|
|
|
Dialog.IsOpen = true;
|
|
|
|
|
Dialog.DialogContent = new DataScanning().Content;
|
|
|
|
|
}
|
2025-08-19 01:53:25 -07:00
|
|
|
|
|
|
|
|
public void OpenDataHOWTO()
|
|
|
|
|
{
|
|
|
|
|
var launcher = GetTopLevel(this)?.Launcher;
|
|
|
|
|
if (launcher != null)
|
|
|
|
|
{
|
|
|
|
|
launcher.LaunchUriAsync(new Uri("https://github.com/muskit/MercuryConverter/blob/main/HOWTO.md"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-06 17:03:37 -07:00
|
|
|
}
|