using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Platform.Storage; using LehrerApp.Desktop.ViewModels.Groups; namespace LehrerApp.Desktop.Views.Groups; public partial class ExamEvaluationDialog : Window { public ExamEvaluationDialog() => InitializeComponent(); private async void OnExportClick(object? sender, RoutedEventArgs e) { if (DataContext is not ExamEvaluationDialogViewModel vm) return; var topLevel = TopLevel.GetTopLevel(this); if (topLevel is null) return; var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { Title = "Klausurauswertung exportieren", SuggestedFileName = $"Auswertung_{vm.ExamTitle}.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(); }