using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Labs.Lottie; using Avalonia.Threading; using LehrerApp.Core.Interfaces; using LehrerApp.Desktop.ViewModels.Groups; using LehrerApp.Desktop.Views.Shared; using Microsoft.Extensions.DependencyInjection; namespace LehrerApp.Desktop.Views.Groups; public partial class StudentGroupGeneratorWindow : Window { private bool _isSpinning; private DateTime _spinStartedAt; private StudentGroupMember? _dragCandidate; private PointerPressedEventArgs? _dragTrigger; private Avalonia.Point _pressPosition; private StudentGroupMember? _draggedMember; private GeneratedStudentGroup? _pendingDropTarget; public StudentGroupGeneratorWindow() => InitializeComponent(); public static StudentGroupGeneratorWindow Create(Guid? initialGroupId, bool useTodayAttendance = false) { var vm = new StudentGroupGeneratorViewModel( App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), initialGroupId, savedPlans: App.Services.GetRequiredService()); if (useTodayAttendance) vm.ParticipantModeName = StudentGroupGeneratorViewModel.AdHocModeLabel; return new StudentGroupGeneratorWindow { DataContext = vm }; } private async void OnGenerate(object? sender, RoutedEventArgs e) { if (DataContext is not StudentGroupGeneratorViewModel vm || !vm.GenerateCommand.CanExecute(null)) return; var results = this.FindControl("ResultsScrollViewer"); var teamwork = this.FindControl("TeamworkAnimation"); var button = this.FindControl