diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs index d1510de..4a2d026 100644 --- a/ModernKeePass/App.xaml.cs +++ b/ModernKeePass/App.xaml.cs @@ -10,10 +10,8 @@ using Windows.Storage.Pickers; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Views; using MediatR; -using Messages; using Microsoft.Extensions.DependencyInjection; using Microsoft.HockeyApp; using ModernKeePass.Application; @@ -41,8 +39,8 @@ namespace ModernKeePass private readonly IMediator _mediator; private readonly ISettingsProxy _settings; private readonly INavigationService _navigation; - private readonly IMessenger _messenger; private readonly IHockeyClient _hockey; + private readonly IDialogService _dialog; public static IServiceProvider Services { get; private set; } @@ -65,47 +63,15 @@ namespace ModernKeePass _resource = Services.GetService(); _settings = Services.GetService(); _navigation = Services.GetService(); - _messenger = Services.GetService(); + _dialog = Services.GetService(); _hockey = Services.GetService(); InitializeComponent(); Suspending += OnSuspending; Resuming += OnResuming; UnhandledException += OnUnhandledException; - - ReceiveGlobalMessage(); - } - - #region Messages - private void ReceiveGlobalMessage() - { - _messenger.Register(this, async action => await ShowDatabaseOpenedDialog(action)); } - private async Task ShowDatabaseOpenedDialog(DatabaseAlreadyOpenedMessage message) - { - await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("MessageDialogDBOpenTitle"), - string.Format(_resource.GetResourceValue("MessageDialogDBOpenDesc"), message.OpenedDatabase.Name), - _resource.GetResourceValue("MessageDialogDBOpenButtonSave"), - _resource.GetResourceValue("MessageDialogDBOpenButtonDiscard"), - async command => - { - await _mediator.Send(new SaveDatabaseCommand()); - ToastNotificationHelper.ShowGenericToast( - message.OpenedDatabase.Name, - _resource.GetResourceValue("ToastSavedMessage")); - await _mediator.Send(new CloseDatabaseCommand()); - _messenger.Send(new DatabaseClosedMessage()); - }, - async command => - { - await _mediator.Send(new CloseDatabaseCommand()); - _messenger.Send(new DatabaseClosedMessage()); - }); - } - - #endregion - #region Event Handlers private async void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) @@ -123,28 +89,32 @@ namespace ModernKeePass var innerException = realException.InnerException; unhandledExceptionEventArgs.Handled = true; _hockey.TrackException(innerException); - await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("MessageDialogSaveErrorTitle"), - innerException?.Message, + await _dialog.ShowMessage(innerException?.Message, + _resource.GetResourceValue("MessageDialogSaveErrorTitle"), _resource.GetResourceValue("MessageDialogSaveErrorButtonSaveAs"), _resource.GetResourceValue("MessageDialogSaveErrorButtonDiscard"), - async command => + async isOk => { - var database = await _mediator.Send(new GetDatabaseQuery()); - var savePicker = new FileSavePicker + if (isOk) { - SuggestedStartLocation = PickerLocationId.DocumentsLibrary, - SuggestedFileName = $"{database.Name} - copy" - }; - savePicker.FileTypeChoices.Add(_resource.GetResourceValue("MessageDialogSaveErrorFileTypeDesc"), - new List {".kdbx"}); + var database = await _mediator.Send(new GetDatabaseQuery()); + var savePicker = new FileSavePicker + { + SuggestedStartLocation = PickerLocationId.DocumentsLibrary, + SuggestedFileName = $"{database.Name} - copy" + }; + savePicker.FileTypeChoices.Add( + _resource.GetResourceValue("MessageDialogSaveErrorFileTypeDesc"), + new List {".kdbx"}); - var file = await savePicker.PickSaveFileAsync().AsTask(); - if (file != null) - { - var token = StorageApplicationPermissions.FutureAccessList.Add(file); - await _mediator.Send(new SaveDatabaseCommand { FilePath = token }); + var file = await savePicker.PickSaveFileAsync().AsTask(); + if (file != null) + { + var token = StorageApplicationPermissions.FutureAccessList.Add(file); + await _mediator.Send(new SaveDatabaseCommand {FilePath = token}); + } } - }, null); + }); } } @@ -183,7 +153,7 @@ namespace ModernKeePass // Load state from previously terminated application await SuspensionManager.RestoreAsync(); #if DEBUG - await MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate"); + await _dialog.ShowMessage("Windows or an error made the app terminate", "App terminated"); #endif } diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs index c8faaa5..45bcf7d 100644 --- a/ModernKeePass/ViewModels/EntryDetailVm.cs +++ b/ModernKeePass/ViewModels/EntryDetailVm.cs @@ -5,10 +5,10 @@ using System.Linq; using System.Threading.Tasks; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; -using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Views; using MediatR; using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Database.Commands.SaveDatabase; using ModernKeePass.Application.Database.Models; using ModernKeePass.Application.Database.Queries.GetDatabase; @@ -29,6 +29,7 @@ using ModernKeePass.Interfaces; using ModernKeePass.Application.Group.Models; using ModernKeePass.Domain.AOP; using ModernKeePass.Extensions; +using RelayCommand = GalaSoft.MvvmLight.Command.RelayCommand; namespace ModernKeePass.ViewModels { @@ -227,6 +228,8 @@ namespace ModernKeePass.ViewModels private readonly IMediator _mediator; private readonly INavigationService _navigation; + private readonly IResourceProxy _resource; + private readonly IDialogService _dialog; private readonly GroupVm _parent; private EntryVm _selectedItem; private int _selectedIndex; @@ -237,12 +240,18 @@ namespace ModernKeePass.ViewModels public EntryDetailVm() { } - internal EntryDetailVm(string entryId) : this(entryId, App.Services.GetRequiredService(), App.Services.GetRequiredService()) { } + internal EntryDetailVm(string entryId) : this(entryId, + App.Services.GetRequiredService(), + App.Services.GetRequiredService(), + App.Services.GetRequiredService(), + App.Services.GetRequiredService()) { } - public EntryDetailVm(string entryId, IMediator mediator, INavigationService navigation) + public EntryDetailVm(string entryId, IMediator mediator, INavigationService navigation, IResourceProxy resource, IDialogService dialog) { _mediator = mediator; _navigation = navigation; + _resource = resource; + _dialog = dialog; SelectedItem = _mediator.Send(new GetEntryQuery { Id = entryId }).GetAwaiter().GetResult(); _parent = _mediator.Send(new GetGroupQuery { Id = SelectedItem.ParentGroupId }).GetAwaiter().GetResult(); History = new ObservableCollection { SelectedItem }; @@ -262,7 +271,50 @@ namespace ModernKeePass.ViewModels private async Task AskForDelete() { - throw new NotImplementedException(); + if (IsCurrentEntry) + { + var isRecycleOnDelete = IsRecycleOnDelete; + + var message = isRecycleOnDelete + ? _resource.GetResourceValue("EntryRecyclingConfirmation") + : _resource.GetResourceValue("EntryDeletingConfirmation"); + await _dialog.ShowMessage(message, + _resource.GetResourceValue("EntityDeleteTitle"), + _resource.GetResourceValue("EntityDeleteActionButton"), + _resource.GetResourceValue("EntityDeleteCancelButton"), + async isOk => + { + if (isOk) + { + var text = isRecycleOnDelete + ? _resource.GetResourceValue("EntryRecycled") + : _resource.GetResourceValue("EntryDeleted"); + //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); + await _mediator.Send(new DeleteEntryCommand + { + EntryId = Id, ParentGroupId = SelectedItem.ParentGroupId, + RecycleBinName = _resource.GetResourceValue("RecycleBinTitle") + }); + _navigation.GoBack(); + } + }); + } + else + { + await _dialog.ShowMessage(_resource.GetResourceValue("HistoryDeleteDescription"), _resource.GetResourceValue("HistoryDeleteTitle"), + _resource.GetResourceValue("EntityDeleteActionButton"), + _resource.GetResourceValue("EntityDeleteCancelButton"), async isOk => + { + if (isOk) + { + //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); + await _mediator.Send(new DeleteHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex - 1 }); + History.RemoveAt(SelectedIndex); + SelectedIndex = 0; + SaveCommand.RaiseCanExecuteChanged(); + } + }); + } } public async Task GeneratePassword() @@ -282,11 +334,6 @@ namespace ModernKeePass.ViewModels }); OnPropertyChanged(nameof(IsRevealPasswordEnabled)); } - - public async Task MarkForDelete(string recycleBinTitle) - { - await _mediator.Send(new DeleteEntryCommand {EntryId = Id, ParentGroupId = SelectedItem.ParentGroupId, RecycleBinName = recycleBinTitle}); - } public async Task Move(GroupVm destination) { @@ -308,20 +355,12 @@ namespace ModernKeePass.ViewModels private async Task RestoreHistory() { - await _mediator.Send(new RestoreHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex }); + await _mediator.Send(new RestoreHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex - 1 }); History.Insert(0, SelectedItem); SelectedIndex = 0; SaveCommand.RaiseCanExecuteChanged(); } - - public async Task DeleteHistory() - { - await _mediator.Send(new DeleteHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex }); - History.RemoveAt(SelectedIndex); - SelectedIndex = 0; - SaveCommand.RaiseCanExecuteChanged(); - } - + private async Task SaveChanges() { await AddHistory(); diff --git a/ModernKeePass/ViewModels/GroupDetailVm.cs b/ModernKeePass/ViewModels/GroupDetailVm.cs index 4b14db4..22b3a7e 100644 --- a/ModernKeePass/ViewModels/GroupDetailVm.cs +++ b/ModernKeePass/ViewModels/GroupDetailVm.cs @@ -154,10 +154,19 @@ namespace ModernKeePass.ViewModels _resource.GetResourceValue("EntityDeleteCancelButton"), async isOk => { - var text = IsRecycleOnDelete ? _resource.GetResourceValue("GroupRecycled") : _resource.GetResourceValue("GroupDeleted"); - //ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text); - await MarkForDelete(_resource.GetResourceValue("RecycleBinTitle")); - _navigation.GoBack(); + if (isOk) + { + var text = IsRecycleOnDelete + ? _resource.GetResourceValue("GroupRecycled") + : _resource.GetResourceValue("GroupDeleted"); + //ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text); + await _mediator.Send(new DeleteGroupCommand + { + GroupId = _group.Id, ParentGroupId = _group.ParentGroupId, + RecycleBinName = _resource.GetResourceValue("RecycleBinTitle") + }); + _navigation.GoBack(); + } }); } @@ -181,11 +190,6 @@ namespace ModernKeePass.ViewModels IsNew = true }); } - - public async Task MarkForDelete(string recycleBinTitle) - { - await _mediator.Send(new DeleteGroupCommand { GroupId = _group.Id, ParentGroupId = _group.ParentGroupId, RecycleBinName = recycleBinTitle }); - } public async Task Move(GroupVm destination) { diff --git a/ModernKeePass/Views/EntryDetailPage.xaml b/ModernKeePass/Views/EntryDetailPage.xaml index ac4fcf5..52c0aa1 100644 --- a/ModernKeePass/Views/EntryDetailPage.xaml +++ b/ModernKeePass/Views/EntryDetailPage.xaml @@ -10,7 +10,6 @@ xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:actions="using:ModernKeePass.Actions" xmlns:userControls="using:ModernKeePass.Views.UserControls" - x:Name="PageRoot" x:Class="ModernKeePass.Views.EntryDetailPage" mc:Ignorable="d" SizeChanged="EntryDetailPage_OnSizeChanged"> @@ -538,7 +537,7 @@ SaveCommand="{Binding SaveCommand}" MoveCommand="{Binding MoveCommand}" RestoreCommand="{Binding RestoreCommand}" - DeleteButtonClick="TopMenu_OnDeleteButtonClick"> + DeleteCommand="{Binding DeleteCommand}"> diff --git a/ModernKeePass/Views/EntryDetailPage.xaml.cs b/ModernKeePass/Views/EntryDetailPage.xaml.cs index 2330cfb..0235185 100644 --- a/ModernKeePass/Views/EntryDetailPage.xaml.cs +++ b/ModernKeePass/Views/EntryDetailPage.xaml.cs @@ -1,8 +1,5 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Navigation; -using Microsoft.Extensions.DependencyInjection; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Common; using ModernKeePass.Models; using ModernKeePass.ViewModels; @@ -16,14 +13,11 @@ namespace ModernKeePass.Views /// public sealed partial class EntryDetailPage { - private readonly IResourceProxy _resource; public EntryDetailVm Model => (EntryDetailVm) DataContext; - public EntryDetailPage(): this(App.Services.GetRequiredService()) { } - public EntryDetailPage(IResourceProxy resource) + public EntryDetailPage() { InitializeComponent(); - _resource = resource; } #region Inscription de NavigationHelper @@ -59,36 +53,5 @@ namespace ModernKeePass.Views VisualStateManager.GoToState(this, e.NewSize.Width < 700 ? "Small" : "Large", true); VisualStateManager.GoToState(TopMenu, e.NewSize.Width < 800 ? "Collapsed" : "Overflowed", true); } - - private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e) - { - if (Model.IsCurrentEntry) - { - var isRecycleOnDelete = Model.IsRecycleOnDelete; - - var message = isRecycleOnDelete - ? _resource.GetResourceValue("EntryRecyclingConfirmation") - : _resource.GetResourceValue("EntryDeletingConfirmation"); - await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message, - _resource.GetResourceValue("EntityDeleteActionButton"), - _resource.GetResourceValue("EntityDeleteCancelButton"), async a => - { - var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted"); - //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); - await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle")); - //NavigationHelper.GoBack(); - }, null); - } - else - { - await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("HistoryDeleteTitle"), _resource.GetResourceValue("HistoryDeleteDescription"), - _resource.GetResourceValue("EntityDeleteActionButton"), - _resource.GetResourceValue("EntityDeleteCancelButton"), async a => - { - //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); - await Model.DeleteHistory(); - }, null); - } - } } } diff --git a/ModernKeePass/Views/GroupDetailPage.xaml b/ModernKeePass/Views/GroupDetailPage.xaml index 066e9b8..1ba8306 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml +++ b/ModernKeePass/Views/GroupDetailPage.xaml @@ -250,7 +250,7 @@ MoveCommand="{Binding MoveCommand}" SortEntriesCommand="{Binding SortEntriesCommand}" SortGroupsCommand="{Binding SortGroupsCommand}" - DeleteButtonClick="TopMenu_OnDeleteButtonClick"> + DeleteCommand="{Binding DeleteCommand}"> diff --git a/ModernKeePass/Views/GroupDetailPage.xaml.cs b/ModernKeePass/Views/GroupDetailPage.xaml.cs index f9c2c0f..15fc128 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml.cs +++ b/ModernKeePass/Views/GroupDetailPage.xaml.cs @@ -120,25 +120,7 @@ namespace ModernKeePass.Views VisualStateManager.GoToState(this, e.NewSize.Width < 800 ? "Small" : "Large", true); VisualStateManager.GoToState(TopMenu, e.NewSize.Width < 800 ? "Collapsed" : "Overflowed", true); } - - private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e) - { - var isRecycleOnDelete = Model.IsRecycleOnDelete; - - var message = isRecycleOnDelete - ? _resource.GetResourceValue("GroupRecyclingConfirmation") - : _resource.GetResourceValue("GroupDeletingConfirmation"); - var text = isRecycleOnDelete ? _resource.GetResourceValue("GroupRecycled") : _resource.GetResourceValue("GroupDeleted"); - await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message, - _resource.GetResourceValue("EntityDeleteActionButton"), - _resource.GetResourceValue("EntityDeleteCancelButton"), async a => - { - //ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text); - await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle")); - //NavigationHelper.GoBack(); - }, null); - } - + #endregion } } diff --git a/ModernKeePass/Views/MainPage.xaml b/ModernKeePass/Views/MainPage.xaml index 1cfdfa3..6afd265 100644 --- a/ModernKeePass/Views/MainPage.xaml +++ b/ModernKeePass/Views/MainPage.xaml @@ -10,17 +10,20 @@ x:Name="PageRoot" mc:Ignorable="d"> - + + + + - - - - + diff --git a/ModernKeePass/Views/MainPage.xaml.cs b/ModernKeePass/Views/MainPage.xaml.cs index 3c62976..df94202 100644 --- a/ModernKeePass/Views/MainPage.xaml.cs +++ b/ModernKeePass/Views/MainPage.xaml.cs @@ -13,7 +13,7 @@ namespace ModernKeePass.Views /// public sealed partial class MainPage { - private new MainVm Model => (MainVm)Resources["ViewModel"]; + public new MainVm Model => (MainVm)DataContext; public MainPage() { diff --git a/ModernKeePass/Views/SettingsPage.xaml b/ModernKeePass/Views/SettingsPage.xaml index a69ceaf..18de4ff 100644 --- a/ModernKeePass/Views/SettingsPage.xaml +++ b/ModernKeePass/Views/SettingsPage.xaml @@ -10,16 +10,16 @@ x:Class="ModernKeePass.Views.SettingsPage" mc:Ignorable="d"> - + + + + - - - - + diff --git a/ModernKeePass/Views/SettingsPage.xaml.cs b/ModernKeePass/Views/SettingsPage.xaml.cs index b4b396b..474d0e5 100644 --- a/ModernKeePass/Views/SettingsPage.xaml.cs +++ b/ModernKeePass/Views/SettingsPage.xaml.cs @@ -12,7 +12,7 @@ namespace ModernKeePass.Views /// public sealed partial class SettingsPage { - private new SettingsVm Model => (SettingsVm)Resources["ViewModel"]; + public new SettingsVm Model => (SettingsVm)DataContext; public SettingsPage() { diff --git a/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml.cs b/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml.cs index 6c138d2..408e2c1 100644 --- a/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml.cs +++ b/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml.cs @@ -4,9 +4,6 @@ using Windows.Storage.Pickers; using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Input; -using GalaSoft.MvvmLight.Messaging; -using Messages; -using Microsoft.Extensions.DependencyInjection; using ModernKeePass.ViewModels; // Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236 @@ -29,13 +26,9 @@ namespace ModernKeePass.Views.UserControls typeof(OpenDatabaseUserControl), new PropertyMetadata(null, (o, args) => { })); - public OpenDatabaseUserControl() : this(App.Services.GetRequiredService()) { } - - public OpenDatabaseUserControl(IMessenger messenger) + public OpenDatabaseUserControl() { InitializeComponent(); - - messenger.Register(this, async action => await Model.OpenDatabase(DatabaseFilePath)); } private async void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e) diff --git a/WinAppCommon/ViewModels/UserControls/OpenDatabaseControlVm.cs b/WinAppCommon/ViewModels/UserControls/OpenDatabaseControlVm.cs index fb111c4..c862cb4 100644 --- a/WinAppCommon/ViewModels/UserControls/OpenDatabaseControlVm.cs +++ b/WinAppCommon/ViewModels/UserControls/OpenDatabaseControlVm.cs @@ -3,12 +3,16 @@ using System.Text; using System.Threading.Tasks; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Messaging; +using GalaSoft.MvvmLight.Views; using MediatR; using Messages; using Microsoft.Extensions.DependencyInjection; using ModernKeePass.Application.Common.Interfaces; +using ModernKeePass.Application.Database.Commands.CloseDatabase; +using ModernKeePass.Application.Database.Commands.SaveDatabase; using ModernKeePass.Application.Database.Queries.GetDatabase; using ModernKeePass.Application.Database.Queries.OpenDatabase; +using ModernKeePass.Common; using ModernKeePass.Domain.AOP; namespace ModernKeePass.ViewModels @@ -98,6 +102,7 @@ namespace ModernKeePass.ViewModels protected readonly IMediator Mediator; private readonly IResourceProxy _resource; private readonly IMessenger _messenger; + private readonly IDialogService _dialog; private bool _hasPassword; private bool _hasKeyFile; private bool _isOpening; @@ -112,14 +117,16 @@ namespace ModernKeePass.ViewModels public OpenDatabaseControlVm() : this( App.Services.GetRequiredService(), App.Services.GetRequiredService(), - App.Services.GetRequiredService()) + App.Services.GetRequiredService(), + App.Services.GetRequiredService()) { } - public OpenDatabaseControlVm(IMediator mediator, IResourceProxy resource, IMessenger messenger) + public OpenDatabaseControlVm(IMediator mediator, IResourceProxy resource, IMessenger messenger, IDialogService dialog) { Mediator = mediator; _resource = resource; _messenger = messenger; + _dialog = dialog; OpenDatabaseCommand = new RelayCommand(async databaseFilePath => await TryOpenDatabase(databaseFilePath), _ => IsValid); _keyFileText = _resource.GetResourceValue("CompositeKeyDefaultKeyFile"); _openButtonLabel = _resource.GetResourceValue("CompositeKeyOpenButtonLabel"); @@ -132,7 +139,27 @@ namespace ModernKeePass.ViewModels var database = await Mediator.Send(new GetDatabaseQuery()); if (database.IsOpen) { - _messenger.Send(new DatabaseAlreadyOpenedMessage { OpenedDatabase = database }); + await _dialog.ShowMessage(_resource.GetResourceValue("MessageDialogDBOpenTitle"), + string.Format(_resource.GetResourceValue("MessageDialogDBOpenDesc"), database.Name), + _resource.GetResourceValue("MessageDialogDBOpenButtonSave"), + _resource.GetResourceValue("MessageDialogDBOpenButtonDiscard"), + async isOk => + { + if (isOk) + { + await Mediator.Send(new SaveDatabaseCommand()); + ToastNotificationHelper.ShowGenericToast( + database.Name, + _resource.GetResourceValue("ToastSavedMessage")); + await Mediator.Send(new CloseDatabaseCommand()); + await OpenDatabase(databaseFilePath); + } + else + { + await Mediator.Send(new CloseDatabaseCommand()); + await OpenDatabase(databaseFilePath); + } + }); } else await OpenDatabase(databaseFilePath); }