From f927667732d8ccf2003047029c90ed2ccc90d49b Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Wed, 25 Feb 2026 07:29:43 +0900 Subject: [PATCH] Add remove all button --- src/App.axaml | 3 ++ src/ViewModels/ConfirmViewModel.cs | 52 ++++++++++++++++++++++++++++++ src/ViewModels/MainViewModel.cs | 11 +++++++ src/Views/ConfirmView.axaml | 35 ++++++++++++++++++++ src/Views/ConfirmView.axaml.cs | 14 ++++++++ src/Views/MainView.axaml | 20 +++++++----- 6 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 src/ViewModels/ConfirmViewModel.cs create mode 100644 src/Views/ConfirmView.axaml create mode 100644 src/Views/ConfirmView.axaml.cs 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 @@ + + + + + + - - +