using Avalonia.Controls; using Avalonia.Interactivity; using LehrerApp.Core.Interfaces; using LehrerApp.Core.Models; using LehrerApp.Core.Services; using LehrerApp.Desktop.Services; using LehrerApp.Desktop.ViewModels; using LehrerApp.Desktop.ViewModels.Students; using LehrerApp.Desktop.Views.Students; using LehrerApp.Desktop.Views.Workload; using Microsoft.Extensions.DependencyInjection; namespace LehrerApp.Desktop.Views.Dashboard; public partial class DashboardView : UserControl { public DashboardView() => InitializeComponent(); protected override void OnDataContextChanged(EventArgs e) { base.OnDataContextChanged(e); if (DataContext is DashboardViewModel vm) vm.OnAddTask = ShowAddTaskDialog; } private async Task ShowAddTaskDialog(bool startAsReminder) { var owner = TopLevel.GetTopLevel(this) as Window; if (owner is null) return null; return await WorkTaskDialogHelper.ShowDialog(owner, startAsReminder: startAsReminder); } private async void OnCompareWebUntisDocumentationClick(object? sender, RoutedEventArgs e) { var owner = TopLevel.GetTopLevel(this) as Window; if (owner is null) return; var dialogVm = new WebUntisDocumentationComparisonViewModel( App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService()); await new WebUntisDocumentationComparisonDialog { DataContext = dialogVm }.ShowDialog(owner); } }