2 Commits
Author SHA1 Message Date
admin 1d9521fc60 SplashScreen
CI / build-and-test (push) Canceled after 0s
2026-09-01 22:51:50 +02:00
admin 4af83c3e68 Update Launch.json 2026-09-01 22:43:10 +02:00
5 changed files with 65 additions and 26 deletions
+6 -5
View File
@@ -47,11 +47,12 @@
} }
}, },
{ {
"name": "Desktop + API (gleichzeitig)", "name": "API Tests starten",
"configurations": [ "type": "coreclr",
"Desktop App starten", "request": "launch",
"API Server starten" "preLaunchTask": "API bauen",
] "program": "${workspaceFolder}/LehrerApp.Api.Tests/bin/Debug/net10.0/LehrerApp.Api.Tests.dll",
"args": [],
} }
], ],
"compounds": [ "compounds": [
+25 -9
View File
@@ -1,7 +1,9 @@
using Avalonia; using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Styling; using Avalonia.Styling;
using Avalonia.Threading;
using LehrerApp.Core.Interfaces; using LehrerApp.Core.Interfaces;
using LehrerApp.Core.Models; using LehrerApp.Core.Models;
using LehrerApp.Core.Services; using LehrerApp.Core.Services;
@@ -37,6 +39,21 @@ public class App : Application
ApplyTheme(new AppearanceSettingsService(AppBootstrapper.ResolveAppDataPath()).Load()); ApplyTheme(new AppearanceSettingsService(AppBootstrapper.ResolveAppDataPath()).Load());
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
// Erst den Splashscreen anzeigen und die synchrone Initialisierung in den ersten
// Dispatcher-Durchlauf verschieben, damit das Ladebild vorher gezeichnet wird.
var splash = new SplashWindow();
desktop.MainWindow = splash;
Dispatcher.UIThread.Post(
() => ContinueStartup(desktop, splash),
DispatcherPriority.Background);
}
base.OnFrameworkInitializationCompleted();
}
private static void ContinueStartup(
IClassicDesktopStyleApplicationLifetime desktop, SplashWindow splash)
{ {
// Verschlüsselte Datenbank (13.3.4): Passwort abfragen, bevor die Datenbank // Verschlüsselte Datenbank (13.3.4): Passwort abfragen, bevor die Datenbank
// (und damit BuildServices, das sie öffnet) angefasst wird. // (und damit BuildServices, das sie öffnet) angefasst wird.
@@ -48,22 +65,20 @@ public class App : Application
promptVm.OnUnlocked = password => promptVm.OnUnlocked = password =>
{ {
AppBootstrapper.DbPassword = password; AppBootstrapper.DbPassword = password;
StartMainApp(desktop, showImmediately: true); StartMainApp(desktop, splash);
promptWindow.Close(); promptWindow.Close();
}; };
desktop.MainWindow = promptWindow; desktop.MainWindow = promptWindow;
} promptWindow.Show();
else splash.Close();
{ return;
StartMainApp(desktop, showImmediately: false);
}
} }
base.OnFrameworkInitializationCompleted(); StartMainApp(desktop, splash);
} }
private static void StartMainApp( private static void StartMainApp(
IClassicDesktopStyleApplicationLifetime desktop, bool showImmediately) IClassicDesktopStyleApplicationLifetime desktop, Window? windowToClose = null)
{ {
_serviceProvider = AppBootstrapper.BuildServices(); _serviceProvider = AppBootstrapper.BuildServices();
Services = _serviceProvider; Services = _serviceProvider;
@@ -96,7 +111,8 @@ public class App : Application
if (Services.GetService<SyncEngine>() is { } syncEngine) if (Services.GetService<SyncEngine>() is { } syncEngine)
main.EnableFinalSync(syncEngine); main.EnableFinalSync(syncEngine);
desktop.MainWindow = main; desktop.MainWindow = main;
if (showImmediately) main.Show(); main.Show();
windowToClose?.Close();
} }
/// <summary>Wechselt die Darstellung sofort, ohne Neustart (12.4) — Avalonia stylt den /// <summary>Wechselt die Darstellung sofort, ohne Neustart (12.4) — Avalonia stylt den
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

@@ -0,0 +1,14 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="LehrerApp.Desktop.Views.SplashWindow"
Title="LehrerPlaner Organizer wird geladen"
Width="450" Height="600"
CanResize="False"
ShowInTaskbar="False"
WindowDecorations="None"
WindowStartupLocation="CenterScreen">
<Image Source="/Assets/SplashScreen.png"
Stretch="UniformToFill"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</Window>
@@ -0,0 +1,8 @@
using Avalonia.Controls;
namespace LehrerApp.Desktop.Views;
public partial class SplashWindow : Window
{
public SplashWindow() => InitializeComponent();
}