mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Load settings.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Models\" />
|
<Folder Include="Models\" />
|
||||||
@@ -19,4 +19,7 @@
|
|||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0-preview3" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0-preview3" />
|
||||||
<PackageReference Include="Svg.Skia.Avalonia" Version="0.10.0-preview3" />
|
<PackageReference Include="Svg.Skia.Avalonia" Version="0.10.0-preview3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RomRepoMgr.Settings\RomRepoMgr.Settings.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -23,9 +23,12 @@
|
|||||||
// Copyright © 2020 Natalia Portillo
|
// Copyright © 2020 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Threading;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace RomRepoMgr.ViewModels
|
namespace RomRepoMgr.ViewModels
|
||||||
@@ -169,5 +172,35 @@ namespace RomRepoMgr.ViewModels
|
|||||||
MigratingDatabaseText = "Migrating database...";
|
MigratingDatabaseText = "Migrating database...";
|
||||||
ExitButtonText = "Exit";
|
ExitButtonText = "Exit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void OnOpened() => Dispatcher.UIThread.Post(LoadSettings);
|
||||||
|
|
||||||
|
void LoadSettings() => Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Settings.Settings.LoadSettings();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
// TODO: Log error
|
||||||
|
Dispatcher.UIThread.Post(FailedLoadingSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Post(LoadDatabase);
|
||||||
|
});
|
||||||
|
|
||||||
|
void FailedLoadingSettings()
|
||||||
|
{
|
||||||
|
LoadingSettingsUnknown = false;
|
||||||
|
LoadingSettingsError = true;
|
||||||
|
ExitVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadDatabase()
|
||||||
|
{
|
||||||
|
LoadingSettingsUnknown = false;
|
||||||
|
LoadingSettingsOk = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,10 @@
|
|||||||
// Copyright © 2020 Natalia Portillo
|
// Copyright © 2020 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using RomRepoMgr.ViewModels;
|
||||||
|
|
||||||
namespace RomRepoMgr.Views
|
namespace RomRepoMgr.Views
|
||||||
{
|
{
|
||||||
@@ -33,5 +35,11 @@ namespace RomRepoMgr.Views
|
|||||||
public SplashWindow() => InitializeComponent();
|
public SplashWindow() => InitializeComponent();
|
||||||
|
|
||||||
void InitializeComponent() => AvaloniaXamlLoader.Load(this);
|
void InitializeComponent() => AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
|
protected override void OnOpened(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnOpened(e);
|
||||||
|
(DataContext as SplashWindowViewModel)?.OnOpened();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user