using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Platform.Storage; using LehrerApp.Desktop.ViewModels.Groups; namespace LehrerApp.Desktop.Views.Groups; public partial class ReportGradeDialog : Window { public ReportGradeDialog() => InitializeComponent(); private async void OnExportClick(object? sender, RoutedEventArgs e) { if (DataContext is not ReportGradeDialogViewModel vm) return; var topLevel = TopLevel.GetTopLevel(this); if (topLevel is null) return; var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { Title = "Zeugnisnoten exportieren", SuggestedFileName = $"Zeugnisnoten_{vm.GroupLabel}.csv", FileTypeChoices = [new FilePickerFileType("CSV-Dateien") { Patterns = ["*.csv"] }], }); if (file is null) return; await File.WriteAllTextAsync(file.Path.LocalPath, vm.ExportCsv()); } private void OnClose(object? sender, RoutedEventArgs e) => Close(); }