28 lines
974 B
C#
28 lines
974 B
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Platform.Storage;
|
|
using LehrerApp.Desktop.ViewModels.Students;
|
|
|
|
namespace LehrerApp.Desktop.Views.Students;
|
|
|
|
public partial class CreateLetterDialog : Window
|
|
{
|
|
public CreateLetterDialog() => InitializeComponent();
|
|
|
|
private async void OnGenerate(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is not CreateLetterDialogViewModel vm) return;
|
|
var file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
|
{
|
|
Title = "Word-Brief speichern",
|
|
SuggestedFileName = vm.SuggestedFileName,
|
|
DefaultExtension = "docx",
|
|
FileTypeChoices = [new FilePickerFileType("Word-Dokumente") { Patterns = ["*.docx"] }],
|
|
});
|
|
if (file is null || !vm.Generate(file.Path.LocalPath)) return;
|
|
Close(file.Path.LocalPath);
|
|
}
|
|
|
|
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
|
}
|