diff --git a/Speculator/CSharp.Utils/UI/DialogService.cs b/Speculator/CSharp.Utils/UI/DialogService.cs index 87a2579..e2fd1c6 100644 --- a/Speculator/CSharp.Utils/UI/DialogService.cs +++ b/Speculator/CSharp.Utils/UI/DialogService.cs @@ -19,7 +19,7 @@ public class DialogService { public static DialogService Instance { get; } = new DialogService(); - public void Warn(string message, string detail, string cancelButton, string actionButton, Action action, MaterialIconKind? icon = null) + public void Warn(string message, string detail, string cancelButton, string actionButton, Action onClose, MaterialIconKind? icon = null) { DialogHost.Show(new ConfirmationDialog { @@ -30,10 +30,6 @@ public void Warn(string message, string detail, string cancelButton, string acti ActionBrush = Brushes.Red, Icon = icon }, - (_, args) => - { - if (Convert.ToBoolean(args.Parameter)) - action(); - }); + (_, args) => onClose(Convert.ToBoolean(args.Parameter))); } } \ No newline at end of file diff --git a/Speculator/Speculator/ViewModels/MainWindowViewModel.cs b/Speculator/Speculator/ViewModels/MainWindowViewModel.cs index 3943efa..b16027d 100644 --- a/Speculator/Speculator/ViewModels/MainWindowViewModel.cs +++ b/Speculator/Speculator/ViewModels/MainWindowViewModel.cs @@ -93,14 +93,18 @@ public void SaveRom() command.Cancelled += (_, _) => keyBlocker.Dispose(); command.Execute(null); } - + public void ResetMachine() => DialogService.Instance.Warn( "Reset Emulator?", "This will simulate a restart of the ZX Spectrum.", "CANCEL", "RESET", - () => Speccy.TheCpu.ResetAsync(), + confirmed => + { + if (confirmed) + Speccy.TheCpu.ResetAsync(); + }, MaterialIconKind.Power); public void SetCursorJoystick(bool b) =>