CI / build-and-test (push) Canceled after 0s
Ein Klassensatz dauert spürbar und fror den Dialog ein. GenerateAsync setzt jetzt per Task.Run, RenderBatchToPdf meldet jeden gesetzten Datensatz über ein optionales IProgress<int>. Das abschließende Document.Merge meldet nichts, dort läuft der Balken unbestimmt. Währenddessen sind die Schaltflächen gesperrt und der Dialog bleibt offen. Ein einzelnes Deckblatt wird nicht mehr doppelt gesetzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Platform.Storage;
|
|
using LehrerApp.Desktop.ViewModels.Groups;
|
|
|
|
namespace LehrerApp.Desktop.Views.Groups;
|
|
|
|
public partial class ExamCoverSheetDialog : Window
|
|
{
|
|
public ExamCoverSheetDialog()
|
|
{
|
|
InitializeComponent();
|
|
// Solange das PDF entsteht, bleibt der Dialog offen — sonst liefe die Erzeugung ohne
|
|
// sichtbare Rückmeldung weiter.
|
|
Closing += (_, e) => e.Cancel = DataContext is ExamCoverSheetDialogViewModel { IsGenerating: true };
|
|
}
|
|
|
|
private async void OnGenerate(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is not ExamCoverSheetDialogViewModel vm) return;
|
|
var file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
|
{
|
|
Title = "Deckblätter speichern",
|
|
SuggestedFileName = vm.SuggestedFileName,
|
|
DefaultExtension = "pdf",
|
|
FileTypeChoices = [new FilePickerFileType("PDF") { Patterns = ["*.pdf"] }],
|
|
});
|
|
if (file is null) return;
|
|
var path = file.Path.LocalPath;
|
|
if (await vm.GenerateAsync(path))
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(path) { UseShellExecute = true });
|
|
}
|
|
|
|
private void OnClose(object? sender, RoutedEventArgs e) => Close();
|
|
}
|