mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-23 02:51:26 -07:00
this was done to: - ensure robloxplayerbeta launches as an orphaned process - help alleviate problems with multiple instances - alleviate problems with the notifyicon causing blocking conflicts on the bootstrapper ui thread - help reduce functional dependency on the bootstrapper, makes it less monolithic and more maintainable ive always wanted to do this for a long while, but have always put it off because of how painful it would be this may genuinely be the most painful refactoring i've ever had to do, but after 2 days, i managed to do it, and it works great!
48 lines
1.4 KiB
C#
48 lines
1.4 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 ICommand CloseWindowCommand => new RelayCommand(CloseWindow);
|
|
|
|
public EventHandler? RequestSaveNoticeEvent;
|
|
|
|
public EventHandler? RequestCloseWindowEvent;
|
|
|
|
private void OpenAbout() => new MainWindow().ShowDialog();
|
|
|
|
private void CloseWindow() => RequestCloseWindowEvent?.Invoke(this, EventArgs.Empty);
|
|
|
|
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, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|