diff --git a/app/Wissance.Zerial/Wissance.Zerial.Desktop/App.axaml.cs b/app/Wissance.Zerial/Wissance.Zerial.Desktop/App.axaml.cs index 8cd78fc..546b5a4 100644 --- a/app/Wissance.Zerial/Wissance.Zerial.Desktop/App.axaml.cs +++ b/app/Wissance.Zerial/Wissance.Zerial.Desktop/App.axaml.cs @@ -17,7 +17,8 @@ public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow(); + desktop.MainWindow = new SplashScreenWindow(); + //new MainWindow(); } base.OnFrameworkInitializationCompleted(); diff --git a/app/Wissance.Zerial/Wissance.Zerial.Desktop/ViewModels/SplashScreenViewModel.cs b/app/Wissance.Zerial/Wissance.Zerial.Desktop/ViewModels/SplashScreenViewModel.cs index 132bb72..4510ad1 100644 --- a/app/Wissance.Zerial/Wissance.Zerial.Desktop/ViewModels/SplashScreenViewModel.cs +++ b/app/Wissance.Zerial/Wissance.Zerial.Desktop/ViewModels/SplashScreenViewModel.cs @@ -1,6 +1,8 @@ using System; using System.Threading; using Avalonia.Controls; +using Avalonia.Threading; +using ReactiveUI; using Wissance.Zerial.Desktop.Models; using Wissance.Zerial.Desktop.Views; @@ -11,6 +13,8 @@ public class SplashScreenViewModel : ViewModelBase { public SplashScreenViewModel(SplashScreenWindow window, AppVersionModel model) { + _window = window; + _model = model; SecondsToStart = DefaultWait; // TODO(UMV): ADD 1sec Timer TimerCallback tm = new TimerCallback(CountToStart); @@ -20,14 +24,26 @@ public SplashScreenViewModel(SplashScreenWindow window, AppVersionModel model) public void CountToStart(object obj) { SecondsToStart--; + //Dispatcher.UIThread.Post(() => + //{ + this.RaisePropertyChanged(nameof(SecondsToStart)); + //}); + if (SecondsToStart == 0) { //Close this and start MainWindow _timer.Change(-1, -1); _timer.Dispose(); - _window.Close(); - MainWindow mainWindow = new MainWindow(); - mainWindow.Show(); + Dispatcher.UIThread.Post(() => + { + _window.Hide(); + MainWindow mainWindow = new MainWindow(); + mainWindow.Show(); + mainWindow.Closed += (sender, args) => + { + _window.Close(); + }; + }); } } @@ -45,7 +61,7 @@ public string Years private const int YearOfWorksStarted = 2023; - private const int DefaultWait = 3; + private const int DefaultWait = 6; // this time start parallel to Window drawing private readonly Timer _timer; private readonly SplashScreenWindow _window;