using System.Windows.Input; using CommunityToolkit.Mvvm.Input; namespace Bloxstrap.UI.ViewModels.Settings { public class MainWindowViewModel : NotifyPropertyChangedViewModel { public ICommand SaveSettingsCommand => new RelayCommand(SaveSettings); public EventHandler? RequestSaveNoticeEvent; private void SaveSettings() { const string LOG_IDENT = "MainWindowViewModel::SaveSettings"; App.Settings.Save(); App.State.Save(); App.FastFlags.Save(); foreach (var pair in App.PendingSettingTasks) { var task = pair.Value; if (task.Changed) { App.Logger.WriteLine(LOG_IDENT, $"Executing pending task '{task}'"); task.Execute(); } } App.PendingSettingTasks.Clear(); RequestSaveNoticeEvent?.Invoke(this, new EventArgs()); } } }