From 87b3ac704c43559a5b74a1ac8176de9ab59bc539 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 9 Apr 2020 03:28:08 +0100 Subject: [PATCH] Add splash window skeleton. --- .idea/.idea.Aaru/.idea/contentModel.xml | 3 ++ Aaru.Gui/Aaru.Gui.csproj | 6 +++ Aaru.Gui/App.xaml.cs | 13 +++--- Aaru.Gui/ViewModels/SplashWindowViewModel.cs | 45 ++++++++++++++++++++ Aaru.Gui/Views/SplashWindow.xaml | 20 +++++++++ Aaru.Gui/Views/SplashWindow.xaml.cs | 27 ++++++++++++ 6 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 Aaru.Gui/ViewModels/SplashWindowViewModel.cs create mode 100644 Aaru.Gui/Views/SplashWindow.xaml create mode 100644 Aaru.Gui/Views/SplashWindow.xaml.cs diff --git a/.idea/.idea.Aaru/.idea/contentModel.xml b/.idea/.idea.Aaru/.idea/contentModel.xml index 3d65adbb8..b72678f32 100644 --- a/.idea/.idea.Aaru/.idea/contentModel.xml +++ b/.idea/.idea.Aaru/.idea/contentModel.xml @@ -1299,11 +1299,14 @@ + + + diff --git a/Aaru.Gui/Aaru.Gui.csproj b/Aaru.Gui/Aaru.Gui.csproj index b4039605f..a17da200c 100644 --- a/Aaru.Gui/Aaru.Gui.csproj +++ b/Aaru.Gui/Aaru.Gui.csproj @@ -317,6 +317,12 @@ Designer + + Designer + + + SplashWindow.xaml + diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index 147b665fc..8eaa8d4c9 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -8,22 +8,19 @@ namespace Aaru.Gui { public class App : Application { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } + public override void Initialize() => AvaloniaXamlLoader.Load(this); public override void OnFrameworkInitializationCompleted() { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + if(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow + desktop.MainWindow = new SplashWindow { - DataContext = new MainWindowViewModel(), + DataContext = new SplashWindowViewModel() }; } base.OnFrameworkInitializationCompleted(); } } -} +} \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/SplashWindowViewModel.cs new file mode 100644 index 000000000..b81de68e4 --- /dev/null +++ b/Aaru.Gui/ViewModels/SplashWindowViewModel.cs @@ -0,0 +1,45 @@ +using Avalonia.Threading; +using ReactiveUI; + +namespace Aaru.Gui.ViewModels +{ + public class SplashWindowViewModel : ViewModelBase + { + double _currentProgress; + double _maxProgress; + string _message; + + public string Message + { + get => _message; + set => this.RaiseAndSetIfChanged(ref _message, value); + } + + public double MaxProgress + { + get => _maxProgress; + set => this.RaiseAndSetIfChanged(ref _maxProgress, value); + } + + public double CurrentProgress + { + get => _currentProgress; + set => this.RaiseAndSetIfChanged(ref _currentProgress, value); + } + + internal void OnOpened() + { + Message = "Welcome to Aaru!"; + MaxProgress = 2; + CurrentProgress = 0; + + Dispatcher.UIThread.Post(InitializeConsole); + } + + void InitializeConsole() + { + CurrentProgress++; + Message = "Initializing console..."; + } + } +} \ No newline at end of file diff --git a/Aaru.Gui/Views/SplashWindow.xaml b/Aaru.Gui/Views/SplashWindow.xaml new file mode 100644 index 000000000..fd1d471fb --- /dev/null +++ b/Aaru.Gui/Views/SplashWindow.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aaru.Gui/Views/SplashWindow.xaml.cs b/Aaru.Gui/Views/SplashWindow.xaml.cs new file mode 100644 index 000000000..696f9dd90 --- /dev/null +++ b/Aaru.Gui/Views/SplashWindow.xaml.cs @@ -0,0 +1,27 @@ +using System; +using Aaru.Gui.ViewModels; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Aaru.Gui.Views +{ + public class SplashWindow : Window + { + public SplashWindow() + { + InitializeComponent(); + #if DEBUG + this.AttachDevTools(); + #endif + } + + void InitializeComponent() => AvaloniaXamlLoader.Load(this); + + protected override void OnOpened(EventArgs e) + { + base.OnOpened(e); + (DataContext as SplashWindowViewModel)?.OnOpened(); + } + } +} \ No newline at end of file