#nullable enable using System; using System.Windows; using ReminderOrganizer.Models; using ReminderOrganizer.Services; using ReminderOrganizer.ViewModels; namespace ReminderOrganizer { public partial class TaskWindow : Window { private readonly TaskViewModel _viewModel; public ReminderTask TaskResult => _viewModel.TaskResult; public TaskWindow() : this(null) { } public TaskWindow(ReminderTask? existingTask) { InitializeComponent(); var localizationService = ServiceLocator.Services.GetService(typeof(ILocalizationService)) as ILocalizationService; if (localizationService == null) { System.Diagnostics.Debug.WriteLine("[TaskWindow] LocalizationService is null!"); localizationService = new LocalizationService(ServiceLocator.Services.GetService(typeof(IDataService)) as IDataService ?? throw new InvalidOperationException("DataService not found")); } _viewModel = new TaskViewModel(localizationService, existingTask); _viewModel.RequestClose += OnRequestClose; DataContext = _viewModel; } private void OnRequestClose(object? sender, bool result) { DialogResult = result; Close(); } private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { DragMove(); } } } }