Add animated classroom grouping with saved editable plans
CI / build-and-test (push) Canceled after 0s
CI / build-and-test (push) Canceled after 0s
This commit is contained in:
1 parent
d4b1419f9a
commit
f0462bd2a1
27 files changed
+775
-46
No files matched your search
@@ -1,10 +1,11 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
|
||||
xmlns:lottie="clr-namespace:Avalonia.Labs.Lottie;assembly=Avalonia.Labs.Lottie"
|
||||
x:Class="LehrerApp.Desktop.Views.Groups.RandomStudentPickerWindow"
|
||||
x:DataType="vm:RandomStudentPickerViewModel"
|
||||
Title="Schüler ziehen"
|
||||
Width="430" MinHeight="390"
|
||||
Width="430" MinHeight="430"
|
||||
SizeToContent="Height"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
@@ -16,12 +17,13 @@
|
||||
<TextBlock Text="Eigenständiges Fenster für die Bildschirmfreigabe"
|
||||
FontSize="12" Opacity="0.55"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Column="1" Content="↺" Command="{Binding ResetCommand}"
|
||||
<Button Grid.Column="1" x:Name="ResetButton" Content="↺" Command="{Binding ResetCommand}"
|
||||
ToolTip.Tip="Ziehung zurücksetzen" FontSize="18"
|
||||
Width="38" Height="38"/>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1" x:Name="RevealCard"
|
||||
<Grid Grid.Row="1" MinHeight="230">
|
||||
<Border x:Name="RevealCard"
|
||||
MinHeight="190" Padding="24"
|
||||
Background="{DynamicResource AppAccentSoftBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource AppFilterActiveBorderBrush}"
|
||||
@@ -42,13 +44,19 @@
|
||||
TextAlignment="Center" TextWrapping="Wrap" FontSize="12" Opacity="0.7"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<lottie:Lottie x:Name="WheelAnimation"
|
||||
Path="/Assets/Animations/LotterySpinWheel.json"
|
||||
RepeatCount="-1" AutoPlay="False"
|
||||
Width="220" Height="220" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" IsVisible="False"/>
|
||||
</Grid>
|
||||
|
||||
<Button Grid.Row="2" Content="🎲 Ziehen" x:Name="DrawButton"
|
||||
IsEnabled="{Binding CanDraw}" Click="OnDraw"
|
||||
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
|
||||
FontSize="18" FontWeight="SemiBold" Height="54" Margin="0,16,0,12"/>
|
||||
|
||||
<Expander Grid.Row="3" Header="Optionen" IsExpanded="False">
|
||||
<Expander Grid.Row="3" x:Name="OptionsExpander" Header="Optionen" IsExpanded="False">
|
||||
<StackPanel Spacing="10" Margin="0,10,0,0">
|
||||
<TextBlock Text="Lerngruppe" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding Groups}" SelectedItem="{Binding SelectedGroup}"
|
||||
|
||||
@@ -1,26 +1,60 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Labs.Lottie;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
public partial class RandomStudentPickerWindow : Window
|
||||
{
|
||||
private bool _isAnimating;
|
||||
private bool _isSpinning;
|
||||
private DateTime _spinStartedAt;
|
||||
|
||||
public RandomStudentPickerWindow() => InitializeComponent();
|
||||
|
||||
private async void OnDraw(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_isAnimating || DataContext is not RandomStudentPickerViewModel vm ||
|
||||
if (DataContext is not RandomStudentPickerViewModel vm ||
|
||||
!vm.DrawCommand.CanExecute(null)) return;
|
||||
|
||||
_isAnimating = true;
|
||||
var card = this.FindControl<Border>("RevealCard");
|
||||
if (card is not null) card.Opacity = 0.15;
|
||||
await Task.Delay(150);
|
||||
var wheel = this.FindControl<Lottie>("WheelAnimation");
|
||||
var button = this.FindControl<Button>("DrawButton");
|
||||
if (card is null || wheel is null || button is null) return;
|
||||
|
||||
if (!_isSpinning)
|
||||
{
|
||||
_isSpinning = true;
|
||||
_spinStartedAt = DateTime.UtcNow;
|
||||
card.IsVisible = false;
|
||||
wheel.IsVisible = true;
|
||||
this.FindControl<Expander>("OptionsExpander")!.IsEnabled = false;
|
||||
this.FindControl<Button>("ResetButton")!.IsEnabled = false;
|
||||
button.Content = "Dreht …";
|
||||
// Erst nach dem Layoutwechsel starten, damit das erste Bild sichtbar ist.
|
||||
await Task.Yield();
|
||||
if (!_isSpinning) return;
|
||||
wheel.Start();
|
||||
button.Content = "Ergebnis anzeigen";
|
||||
return;
|
||||
}
|
||||
|
||||
// Ein Doppelklick soll die Ziehung nicht unbemerkt sofort auflösen.
|
||||
if (DateTime.UtcNow - _spinStartedAt < TimeSpan.FromSeconds(1.2)) return;
|
||||
wheel.Stop();
|
||||
wheel.IsVisible = false;
|
||||
vm.DrawCommand.Execute(null);
|
||||
if (card is not null) card.Opacity = 1;
|
||||
_isAnimating = false;
|
||||
card.IsVisible = true;
|
||||
this.FindControl<Expander>("OptionsExpander")!.IsEnabled = true;
|
||||
this.FindControl<Button>("ResetButton")!.IsEnabled = true;
|
||||
button.Content = "🎲 Ziehen";
|
||||
_isSpinning = false;
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_isSpinning = false;
|
||||
this.FindControl<Lottie>("WheelAnimation")?.Stop();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
|
||||
xmlns:models="clr-namespace:LehrerApp.Core.Models;assembly=LehrerApp.Core"
|
||||
xmlns:lottie="clr-namespace:Avalonia.Labs.Lottie;assembly=Avalonia.Labs.Lottie"
|
||||
x:Class="LehrerApp.Desktop.Views.Groups.StudentGroupGeneratorWindow"
|
||||
x:DataType="vm:StudentGroupGeneratorViewModel"
|
||||
Title="Gruppen zusammenstellen"
|
||||
Width="780" Height="650" MinWidth="620" MinHeight="480"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Window.Styles>
|
||||
<Style Selector="Border.studentgroup.droptarget">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AppAccentTextBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="2"/>
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto,Auto" Margin="24">
|
||||
<StackPanel Grid.Row="0" Spacing="3" Margin="0,0,0,16">
|
||||
<TextBlock Text="Gruppen zusammenstellen" Classes="dialogtitle"/>
|
||||
@@ -14,7 +23,7 @@
|
||||
FontSize="12" Opacity="0.55"/>
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<ScrollViewer Grid.Row="1" x:Name="ResultsScrollViewer">
|
||||
<Grid x:Name="GroupResults">
|
||||
<Grid.Transitions>
|
||||
<Transitions>
|
||||
@@ -40,17 +49,26 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:GeneratedStudentGroup">
|
||||
<Border Width="220" Margin="7" Padding="16"
|
||||
<Border Width="220" Margin="7" Padding="16" Classes="studentgroup"
|
||||
Classes.droptarget="{Binding IsDropTarget}"
|
||||
Background="{DynamicResource AppCardBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource AppCardBorderBrush}"
|
||||
BorderThickness="1" CornerRadius="12">
|
||||
BorderThickness="1" CornerRadius="12"
|
||||
DragDrop.AllowDrop="True" DragDrop.DragEnter="OnGroupDragEnter"
|
||||
DragDrop.DragLeave="OnGroupDragLeave" DragDrop.DragOver="OnGroupDragOver"
|
||||
DragDrop.Drop="OnGroupDrop">
|
||||
<StackPanel Spacing="9">
|
||||
<TextBlock Text="{Binding Title}" FontSize="16" FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource AppAccentTextBrush}"/>
|
||||
<ItemsControl ItemsSource="{Binding Members}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:StudentGroupMember">
|
||||
<TextBlock Text="{Binding Name}" Margin="0,3" TextWrapping="Wrap"/>
|
||||
<Border Background="{DynamicResource AppChipBackgroundBrush}"
|
||||
CornerRadius="6" Padding="8,5" Margin="0,3"
|
||||
PointerPressed="OnMemberPressed" PointerMoved="OnMemberMoved"
|
||||
PointerReleased="OnMemberReleased">
|
||||
<TextBlock Text="{Binding Name}" TextWrapping="Wrap"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
@@ -61,11 +79,41 @@
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<lottie:Lottie Grid.Row="1" x:Name="TeamworkAnimation"
|
||||
Path="/Assets/Animations/Teamwork.json"
|
||||
RepeatCount="-1" AutoPlay="False"
|
||||
Width="270" Height="270" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" IsVisible="False"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Spacing="8" Margin="0,12,0,10">
|
||||
<Button Content="Gruppen zusammenstellen" Click="OnGenerate"
|
||||
<Button x:Name="GenerateButton" Content="Gruppen zusammenstellen" Click="OnGenerate"
|
||||
IsEnabled="{Binding CanGenerate}" HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center" Height="48" FontSize="16" FontWeight="SemiBold"/>
|
||||
<StackPanel x:Name="PlanActions" Spacing="8">
|
||||
<TextBlock Text="Schüler zwischen den Gruppenkarten ziehen, um die Einteilung anzupassen."
|
||||
FontSize="11" Opacity="0.65" IsVisible="{Binding HasGeneratedGroups}"/>
|
||||
<Grid ColumnDefinitions="*,10,Auto,8,Auto" IsVisible="{Binding HasSavedPlans}">
|
||||
<ComboBox ItemsSource="{Binding SavedPlans}" SelectedItem="{Binding SelectedSavedPlan}"
|
||||
PlaceholderText="Gespeicherte Einteilung auswählen">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:StudentGroupPlan">
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Button Grid.Column="2" Content="Laden" Click="OnLoadSavedPlan"
|
||||
IsEnabled="{Binding CanLoadSavedPlan}"/>
|
||||
<Button Grid.Column="4" Content="Löschen" Click="OnDeleteSavedPlan"
|
||||
IsEnabled="{Binding CanDeleteSavedPlan}"/>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,10,Auto" IsVisible="{Binding HasGeneratedGroups}">
|
||||
<TextBox Text="{Binding PlanName, Mode=TwoWay}" PlaceholderText="Name der Einteilung"/>
|
||||
<Button Grid.Column="2" Content="Speichern" Command="{Binding SavePlanCommand}"/>
|
||||
</Grid>
|
||||
<TextBlock Text="{Binding SaveStatus}" FontSize="11" Opacity="0.7" TextWrapping="Wrap"
|
||||
IsVisible="{Binding SaveStatus, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</StackPanel>
|
||||
<StackPanel x:Name="ResultSummary" Spacing="8">
|
||||
<TextBlock Text="{Binding StatusText}" HorizontalAlignment="Center" Opacity="0.65"
|
||||
IsVisible="{Binding HasGeneratedGroups}"/>
|
||||
<Border Background="{DynamicResource AppChipBackgroundBrush}" CornerRadius="8" Padding="10,7"
|
||||
@@ -73,9 +121,10 @@
|
||||
<TextBlock Text="{Binding WarningText}" TextWrapping="Wrap" FontSize="12"
|
||||
Foreground="{DynamicResource AppStatusWarningBrush}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Expander Grid.Row="3" Header="Optionen" IsExpanded="False">
|
||||
<Expander Grid.Row="3" x:Name="OptionsExpander" Header="Optionen" IsExpanded="False">
|
||||
<ScrollViewer MaxHeight="340">
|
||||
<StackPanel Spacing="11" Margin="0,10,6,4">
|
||||
<Grid ColumnDefinitions="*,16,*">
|
||||
|
||||
@@ -1,25 +1,204 @@
|
||||
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 _isAnimating;
|
||||
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<IStudentRepository>(),
|
||||
App.Services.GetRequiredService<IGroupRepository>(),
|
||||
App.Services.GetRequiredService<IGroupMembershipRepository>(),
|
||||
App.Services.GetRequiredService<IParticipationSessionRepository>(),
|
||||
App.Services.GetRequiredService<IParticipationRepository>(),
|
||||
App.Services.GetRequiredService<IGradeRepository>(),
|
||||
initialGroupId,
|
||||
savedPlans: App.Services.GetRequiredService<IStudentGroupPlanRepository>());
|
||||
if (useTodayAttendance)
|
||||
vm.ParticipantModeName = StudentGroupGeneratorViewModel.AdHocModeLabel;
|
||||
return new StudentGroupGeneratorWindow { DataContext = vm };
|
||||
}
|
||||
|
||||
private async void OnGenerate(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_isAnimating || DataContext is not StudentGroupGeneratorViewModel vm ||
|
||||
if (DataContext is not StudentGroupGeneratorViewModel vm ||
|
||||
!vm.GenerateCommand.CanExecute(null)) return;
|
||||
_isAnimating = true;
|
||||
var results = this.FindControl<Grid>("GroupResults");
|
||||
if (results is not null) results.Opacity = 0.15;
|
||||
await Task.Delay(140);
|
||||
vm.GenerateCommand.Execute(null);
|
||||
if (results is not null) results.Opacity = 1;
|
||||
_isAnimating = false;
|
||||
var results = this.FindControl<ScrollViewer>("ResultsScrollViewer");
|
||||
var teamwork = this.FindControl<Lottie>("TeamworkAnimation");
|
||||
var button = this.FindControl<Button>("GenerateButton");
|
||||
var options = this.FindControl<Expander>("OptionsExpander");
|
||||
var summary = this.FindControl<StackPanel>("ResultSummary");
|
||||
var actions = this.FindControl<StackPanel>("PlanActions");
|
||||
if (results is null || teamwork is null || button is null || options is null ||
|
||||
summary is null || actions is null) return;
|
||||
|
||||
if (!_isSpinning)
|
||||
{
|
||||
_isSpinning = true;
|
||||
_spinStartedAt = DateTime.UtcNow;
|
||||
results.IsVisible = false;
|
||||
actions.IsVisible = false;
|
||||
summary.IsVisible = false;
|
||||
teamwork.IsVisible = true;
|
||||
options.IsEnabled = false;
|
||||
button.Content = "Teamwork läuft …";
|
||||
// Nach dem Layoutwechsel starten, damit der erste Frame sichtbar ist.
|
||||
await Task.Yield();
|
||||
if (!_isSpinning) return;
|
||||
teamwork.Start();
|
||||
button.Content = "Ergebnis anzeigen";
|
||||
return;
|
||||
}
|
||||
|
||||
// Ein Doppelklick soll die Animation nicht sofort wieder schließen.
|
||||
if (DateTime.UtcNow - _spinStartedAt < TimeSpan.FromSeconds(1.2)) return;
|
||||
try
|
||||
{
|
||||
vm.GenerateCommand.Execute(null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
teamwork.Stop();
|
||||
teamwork.IsVisible = false;
|
||||
results.IsVisible = true;
|
||||
actions.IsVisible = true;
|
||||
summary.IsVisible = true;
|
||||
options.IsEnabled = true;
|
||||
button.Content = "Gruppen zusammenstellen";
|
||||
_isSpinning = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMemberPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (_isSpinning || sender is not Control { DataContext: StudentGroupMember member } control ||
|
||||
!e.GetCurrentPoint(control).Properties.IsLeftButtonPressed) return;
|
||||
_dragCandidate = member;
|
||||
_dragTrigger = e;
|
||||
_pressPosition = e.GetPosition(this);
|
||||
}
|
||||
|
||||
private async void OnLoadSavedPlan(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not StudentGroupGeneratorViewModel vm ||
|
||||
!vm.LoadSavedPlanCommand.CanExecute(null)) return;
|
||||
if (vm.HasUnsavedChanges)
|
||||
{
|
||||
var dialog = new ConfirmDialog
|
||||
{
|
||||
DataContext = new ConfirmDialogInfo
|
||||
{
|
||||
Title = "Ungespeicherte Einteilung ersetzen?",
|
||||
Message = "Die aktuelle Einteilung und manuelle Änderungen werden beim Laden verworfen.",
|
||||
ConfirmText = "Gespeicherte Einteilung laden",
|
||||
},
|
||||
};
|
||||
if (!await dialog.ShowDialog<bool>(this)) return;
|
||||
}
|
||||
vm.LoadSavedPlanCommand.Execute(null);
|
||||
}
|
||||
|
||||
private async void OnDeleteSavedPlan(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not StudentGroupGeneratorViewModel vm ||
|
||||
!vm.DeleteSavedPlanCommand.CanExecute(null)) return;
|
||||
var dialog = new ConfirmDialog
|
||||
{
|
||||
DataContext = new ConfirmDialogInfo
|
||||
{
|
||||
Title = "Einteilung löschen?",
|
||||
Message = $"Die gespeicherte Einteilung „{vm.SelectedSavedPlan!.Name}“ wird gelöscht.",
|
||||
ConfirmText = "Löschen",
|
||||
},
|
||||
};
|
||||
if (await dialog.ShowDialog<bool>(this)) vm.DeleteSavedPlanCommand.Execute(null);
|
||||
}
|
||||
|
||||
private async void OnMemberMoved(object? sender, PointerEventArgs e)
|
||||
{
|
||||
if (_dragCandidate is null || _dragTrigger is null ||
|
||||
!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
|
||||
var position = e.GetPosition(this);
|
||||
if (Math.Abs(position.X - _pressPosition.X) < 6 &&
|
||||
Math.Abs(position.Y - _pressPosition.Y) < 6) return;
|
||||
|
||||
_draggedMember = _dragCandidate;
|
||||
_pendingDropTarget = null;
|
||||
_dragCandidate = null;
|
||||
var trigger = _dragTrigger;
|
||||
_dragTrigger = null;
|
||||
var data = new DataTransfer();
|
||||
data.Add(DataTransferItem.CreateText("LehrerApp-Gruppeneinteilung"));
|
||||
var effect = await DragDrop.DoDragDropAsync(trigger, data, DragDropEffects.Move);
|
||||
var member = _draggedMember;
|
||||
var target = _pendingDropTarget;
|
||||
_draggedMember = null;
|
||||
_pendingDropTarget = null;
|
||||
if ((effect & DragDropEffects.Move) == 0 || member is null || target is null) return;
|
||||
// Die Quelle erst verändern, wenn Avalonia den Drop vollständig verarbeitet hat.
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (DataContext is StudentGroupGeneratorViewModel vm) vm.MoveStudent(member, target);
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void OnMemberReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
_dragCandidate = null;
|
||||
_dragTrigger = null;
|
||||
}
|
||||
|
||||
private bool CanDropOn(GeneratedStudentGroup target) =>
|
||||
!_isSpinning && _draggedMember is { } member &&
|
||||
!target.Members.Any(existing => existing.Id == member.Id);
|
||||
|
||||
private void OnGroupDragEnter(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is Border { DataContext: GeneratedStudentGroup target } && CanDropOn(target))
|
||||
target.IsDropTarget = true;
|
||||
}
|
||||
|
||||
private void OnGroupDragLeave(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is Border { DataContext: GeneratedStudentGroup target }) target.IsDropTarget = false;
|
||||
}
|
||||
|
||||
private void OnGroupDragOver(object? sender, DragEventArgs e) =>
|
||||
e.DragEffects = sender is Border { DataContext: GeneratedStudentGroup target } && CanDropOn(target)
|
||||
? DragDropEffects.Move : DragDropEffects.None;
|
||||
|
||||
private void OnGroupDrop(object? sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is not Border { DataContext: GeneratedStudentGroup target }) return;
|
||||
target.IsDropTarget = false;
|
||||
if (!CanDropOn(target)) { e.DragEffects = DragDropEffects.None; return; }
|
||||
_pendingDropTarget = target;
|
||||
e.DragEffects = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_isSpinning = false;
|
||||
this.FindControl<Lottie>("TeamworkAnimation")?.Stop();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@
|
||||
<Button Content="Hausaufgaben kontrollieren" Command="{Binding SeatingPlan.CheckHomeworkCommand}" IsEnabled="{Binding SeatingPlan.IsEditable}"/>
|
||||
<Button Content="Kontrolle beenden" Command="{Binding SeatingPlan.EndQuickCheckCommand}" IsVisible="{Binding SeatingPlan.IsQuickMode}"/>
|
||||
<Button Content="Listenansicht …" Command="{Binding Participation.StatusQuickInputCommand}" ToolTip.Tip="Auch Schüler ohne Sitzplatz erfassen."/>
|
||||
<Button Content="Gruppen zusammenstellen …" Click="OnOpenStudentGroups"
|
||||
ToolTip.Tip="Gruppen für diese Lerngruppe ziehen, bearbeiten und später wieder laden."/>
|
||||
<Button Content="Vollbild ↔" Click="OnFullScreen" ToolTip.Tip="Vollbild umschalten (F11); mit Escape verlassen."/>
|
||||
<Button Content="Zur Mitarbeit" Command="{Binding LessonInfo.NavigateToParticipationCommand}"
|
||||
ToolTip.Tip="Schließt den Unterrichtsmodus und springt zum Tab 'Mitarbeit' der Lerngruppe."/>
|
||||
|
||||
@@ -15,6 +15,7 @@ public partial class TeachingModeWindow : Window
|
||||
private static readonly Dictionary<Guid, TeachingModeWindow> OpenWindows = [];
|
||||
private readonly DispatcherTimer _clock = new() { Interval = TimeSpan.FromSeconds(1) };
|
||||
private WindowState _previousState = WindowState.Maximized;
|
||||
private StudentGroupGeneratorWindow? _studentGroupGeneratorWindow;
|
||||
|
||||
public static void Open(Lesson lesson)
|
||||
{
|
||||
@@ -66,6 +67,20 @@ public partial class TeachingModeWindow : Window
|
||||
}
|
||||
private void OnFullScreen(object? sender, RoutedEventArgs e) => ToggleFullScreen();
|
||||
|
||||
private void OnOpenStudentGroups(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_studentGroupGeneratorWindow is not null)
|
||||
{
|
||||
_studentGroupGeneratorWindow.Activate();
|
||||
return;
|
||||
}
|
||||
if (DataContext is not TeachingModeViewModel vm) return;
|
||||
_studentGroupGeneratorWindow = StudentGroupGeneratorWindow.Create(vm.LessonInfo.GroupId,
|
||||
useTodayAttendance: vm.LessonDate == DateOnly.FromDateTime(DateTime.Today));
|
||||
_studentGroupGeneratorWindow.Closed += (_, _) => _studentGroupGeneratorWindow = null;
|
||||
_studentGroupGeneratorWindow.Show(this);
|
||||
}
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
|
||||
Reference in new issue
Block a user