36 lines
1.2 KiB
C#
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);
|
|
}
|