Refactor in file open mechanisms: file is passed to user control

Confirmation dialogs on group and entry delete
This commit is contained in:
2017-10-11 14:30:07 +02:00
committed by BONNEVILLE Geoffroy
parent 454e074c44
commit 97b1475100
12 changed files with 124 additions and 62 deletions

View File

@@ -1,4 +1,5 @@
using System;
using Windows.UI.Popups;
using ModernKeePass.Common;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -25,9 +26,9 @@ namespace ModernKeePass.Pages
public EntryDetailPage()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += navigationHelper_LoadState;
InitializeComponent();
navigationHelper = new NavigationHelper(this);
navigationHelper.LoadState += navigationHelper_LoadState;
}
/// <summary>
@@ -70,11 +71,28 @@ namespace ModernKeePass.Pages
#endregion
private void AppBarButton_Click(object sender, RoutedEventArgs e)
private async void AppBarButton_Click(object sender, RoutedEventArgs e)
{
var entry = DataContext as EntryVm;
entry?.RemoveEntry();
if (Frame.CanGoBack) Frame.GoBack();
// Create the message dialog and set its content
var messageDialog = new MessageDialog("Are you sure you want to delete this entry?");
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
messageDialog.Commands.Add(new UICommand("Delete", delete =>
{
var entry = DataContext as EntryVm;
entry?.RemoveEntry();
if (Frame.CanGoBack) Frame.GoBack();
}));
messageDialog.Commands.Add(new UICommand("Cancel"));
// Set the command that will be invoked by default
messageDialog.DefaultCommandIndex = 1;
// Set the command to be invoked when escape is pressed
messageDialog.CancelCommandIndex = 1;
// Show the message dialog
await messageDialog.ShowAsync();
}
private async void UrlButton_Click(object sender, RoutedEventArgs e)