Add splash window skeleton.

This commit is contained in:
2020-04-09 03:28:08 +01:00
parent 142f8249ef
commit 87b3ac704c
6 changed files with 106 additions and 8 deletions

View File

@@ -1299,11 +1299,14 @@
<e p="ViewLocator.cs" t="Include" /> <e p="ViewLocator.cs" t="Include" />
<e p="ViewModels" t="Include"> <e p="ViewModels" t="Include">
<e p="MainWindowViewModel.cs" t="Include" /> <e p="MainWindowViewModel.cs" t="Include" />
<e p="SplashWindowViewModel.cs" t="Include" />
<e p="ViewModelBase.cs" t="Include" /> <e p="ViewModelBase.cs" t="Include" />
</e> </e>
<e p="Views" t="Include"> <e p="Views" t="Include">
<e p="MainWindow.xaml" t="Include" /> <e p="MainWindow.xaml" t="Include" />
<e p="MainWindow.xaml.cs" t="Include" /> <e p="MainWindow.xaml.cs" t="Include" />
<e p="SplashWindow.xaml" t="Include" />
<e p="SplashWindow.xaml.cs" t="Include" />
</e> </e>
</e> </e>
<e p="Aaru.Helpers" t="IncludeRecursive"> <e p="Aaru.Helpers" t="IncludeRecursive">

View File

@@ -317,6 +317,12 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</AvaloniaResource> </AvaloniaResource>
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />
<AvaloniaResource Update="Views\SplashWindow.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<Compile Update="Views\SplashWindow.xaml.cs">
<DependentUpon>SplashWindow.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<UpToDateCheckInput Remove="Views\MainWindow.xaml" /> <UpToDateCheckInput Remove="Views\MainWindow.xaml" />

View File

@@ -8,22 +8,19 @@ namespace Aaru.Gui
{ {
public class App : Application public class App : Application
{ {
public override void Initialize() public override void Initialize() => AvaloniaXamlLoader.Load(this);
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted() 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(); base.OnFrameworkInitializationCompleted();
} }
} }
} }

View File

@@ -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...";
}
}
}

View File

@@ -0,0 +1,20 @@
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels;assembly=Aaru.Gui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800"
d:DesignHeight="450" x:Class="Aaru.Gui.Views.SplashWindow" Icon="/Assets/avalonia-logo.ico" Title="Aaru"
HasSystemDecorations="False">
<Design.DataContext>
<vm:SplashWindowViewModel />
</Design.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="/Assets/avalonia-logo.ico" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Grid.Row="0" />
<TextBlock Text="{Binding Message}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" />
<ProgressBar Maximum="{Binding MaxProgress}" Minimum="0" Value="{Binding CurrentProgress}"
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="2" />
</Grid>
</Window>

View File

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