Skip to content

Commit

Permalink
seems that Splash Screen is working now
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed Feb 11, 2024
1 parent b064488 commit 542e4ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/Wissance.Zerial/Wissance.Zerial.Desktop/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
Expand All @@ -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();
};
});
}
}

Expand All @@ -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;
Expand Down

0 comments on commit 542e4ea

Please sign in to comment.