001b945ea1
TODO: Update SceneTreeView after adding new objects
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using NrxDebugVisualizer.ViewModels;
|
|
using Num.Roto.Visualization.Types;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.Threading;
|
|
|
|
namespace NrxDebugVisualizer.Views;
|
|
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
|
InitializeComponent();
|
|
|
|
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();
|
|
}
|
|
} |