2026-04-08 16:06:35 +02:00
|
|
|
using Avalonia.Controls;
|
2026-04-15 15:59:42 +02:00
|
|
|
using Avalonia.Interactivity;
|
|
|
|
|
using NrxDebugVisualizer.ViewModels;
|
|
|
|
|
using Num.Roto.Visualization.Types;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Threading;
|
2026-04-08 16:06:35 +02:00
|
|
|
|
|
|
|
|
namespace NrxDebugVisualizer.Views;
|
|
|
|
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
2026-04-15 15:59:42 +02:00
|
|
|
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
2026-04-08 16:06:35 +02:00
|
|
|
InitializeComponent();
|
2026-04-15 15:59:42 +02:00
|
|
|
|
|
|
|
|
Closing += OnClosing;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoaded(e);
|
|
|
|
|
if (DataContext is not MainWindowViewModel viewModel) throw new DataException("wrong viewModel type!");
|
|
|
|
|
if (App.Settings?.CameraFrame is not { } cameraFrame) return;
|
|
|
|
|
var scene = viewModel.ProportionalDockControlViewModel.Scene;
|
|
|
|
|
var camera = scene?.SelectedCamera;
|
|
|
|
|
camera?.Frame = cameraFrame;
|
|
|
|
|
viewModel.ViewPosition = CameraView.Position.User;
|
|
|
|
|
}
|
|
|
|
|
private async void OnClosing(object? sender, System.ComponentModel.CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (DataContext is not MainWindowViewModel viewModel) throw new DataException("wrong viewModel type!");
|
|
|
|
|
var scene = viewModel.ProportionalDockControlViewModel.Scene;
|
|
|
|
|
var camera = scene?.SelectedCamera;
|
|
|
|
|
App.Settings?.MainWindow = this;
|
|
|
|
|
App.Settings?.CameraFrame = camera?.Frame;
|
|
|
|
|
App.Settings?.Save();
|
2026-04-08 16:06:35 +02:00
|
|
|
}
|
|
|
|
|
}
|