mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-23 02:51:26 -07:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Windows.Input;
|
|
using Bloxstrap.UI.Elements.About;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace Bloxstrap.UI.ViewModels.Settings
|
|
{
|
|
public class MainWindowViewModel : NotifyPropertyChangedViewModel
|
|
{
|
|
public ICommand OpenAboutCommand => new RelayCommand(OpenAbout);
|
|
|
|
public ICommand SaveSettingsCommand => new RelayCommand(SaveSettings);
|
|
|
|
public EventHandler? RequestSaveNoticeEvent;
|
|
|
|
private void OpenAbout() => new MainWindow().ShowDialog();
|
|
|
|
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());
|
|
}
|
|
}
|
|
}
|