diff --git a/src/App.axaml b/src/App.axaml index f568dc0..f917010 100644 --- a/src/App.axaml +++ b/src/App.axaml @@ -103,6 +103,9 @@ + + + diff --git a/src/ViewModels/ConfirmViewModel.cs b/src/ViewModels/ConfirmViewModel.cs new file mode 100644 index 0000000..54b05a4 --- /dev/null +++ b/src/ViewModels/ConfirmViewModel.cs @@ -0,0 +1,52 @@ +#nullable enable + +using DialogHostAvalonia; +using MayShow.Helpers; + +namespace MayShow.ViewModels; + +class ConfirmViewModel +{ + private string _title; + private string _message; + private string _confirmTitle; + private string _declineTitle; + + public ConfirmViewModel(string title, string message, string confirmTitle = "Yes", string declineTitle = "No") + { + _title = title; + _message = message; + _confirmTitle = confirmTitle; + _declineTitle = declineTitle; + } + + public string Title + { + get => _title; + } + + public string Message + { + get => _message; + } + + public string ConfirmTitle + { + get => _confirmTitle; + } + + public string DeclineTitle + { + get => _declineTitle; + } + + public void Confirm() + { + DialogHost.Close("DialogHost", true); + } + + public void Decline() + { + DialogHost.Close("DialogHost", false); + } +} \ No newline at end of file diff --git a/src/ViewModels/MainViewModel.cs b/src/ViewModels/MainViewModel.cs index 075aa03..de5fad3 100644 --- a/src/ViewModels/MainViewModel.cs +++ b/src/ViewModels/MainViewModel.cs @@ -366,6 +366,17 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown } } + public async void RemoveAllItems() + { + var result = await DialogHost.Show(new ConfirmViewModel("Warning!", "Are you sure you want to remove all items from this report?", "Remove All Items", "Cancel")); + if (result != null && (bool)result) + { + ReportFiles.Clear(); + HasUnsavedWork = true; + NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); + } + } + public void LocateFile(object f) => LocateFileImpl((ReportFile) f); public async void LocateFileImpl(ReportFile reportFile) { diff --git a/src/Views/ConfirmView.axaml b/src/Views/ConfirmView.axaml new file mode 100644 index 0000000..94125fd --- /dev/null +++ b/src/Views/ConfirmView.axaml @@ -0,0 +1,35 @@ + + + + + + - - +