Files
LehrerApp/LehrerApp.Desktop/Views/Groups/AiResponseRescueDialog.axaml.cs
T
admin fedfceb81d
CI / build-and-test (push) Canceled after 0s
KI-Backend: Antwortretten - Funktion
2026-09-04 12:10:42 +02:00

36 lines
1.2 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
using LehrerApp.Desktop.ViewModels.Groups;
namespace LehrerApp.Desktop.Views.Groups;
public partial class AiResponseRescueDialog : Window
{
public AiResponseRescueDialog() => InitializeComponent();
private void OnValidateSelection(object? sender, RoutedEventArgs e)
{
if (DataContext is not AiResponseRescueDialogViewModel vm) return;
var candidate = string.IsNullOrWhiteSpace(ResponseTextBox.SelectedText)
? ResponseTextBox.Text ?? ""
: ResponseTextBox.SelectedText;
vm.ParseSelection(candidate);
}
private void OnImportIntoExisting(object? sender, RoutedEventArgs e)
{
if (DataContext is not AiResponseRescueDialogViewModel vm || !vm.CanImportIntoExisting) return;
vm.ImportIntoExistingCommand.Execute(null);
if (vm.Result) Close(true);
}
private void OnImportAsNew(object? sender, RoutedEventArgs e)
{
if (DataContext is not AiResponseRescueDialogViewModel vm || !vm.HasParsedLesson) return;
vm.ImportAsNewCommand.Execute(null);
if (vm.Result) Close(true);
}
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
}