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(); 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 (vm.Generate(path)) System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(path) { UseShellExecute = true }); } private void OnClose(object? sender, RoutedEventArgs e) => Close(); }