diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs
index f952f29..22cd1f3 100644
--- a/ModernKeePass/App.xaml.cs
+++ b/ModernKeePass/App.xaml.cs
@@ -149,11 +149,12 @@ namespace ModernKeePass
///
/// The source of the suspend request.
/// Details about the suspend request.
- private void OnSuspending(object sender, SuspendingEventArgs e)
+ private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
UnhandledException -= OnUnhandledException;
Database.Save();
+ await Database.Close();
deferral.Complete();
}
diff --git a/ModernKeePass/Common/MessageDialogHelper.cs b/ModernKeePass/Common/MessageDialogHelper.cs
index e576868..956e676 100644
--- a/ModernKeePass/Common/MessageDialogHelper.cs
+++ b/ModernKeePass/Common/MessageDialogHelper.cs
@@ -13,12 +13,10 @@ namespace ModernKeePass.Common
public static async void ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand)
{
// Create the message dialog and set its content
- var messageDialog = CreateBasicDialog(title, contentText, cancelButtonText);
+ var messageDialog = CreateBasicDialog(title, contentText, cancelButtonText, cancelCommand);
// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
messageDialog.Commands.Add(new UICommand(actionButtonText, actionCommand));
- // TODO: correct this
- //messageDialog.Commands.Add(new UICommand(cancelButtonText, cancelCommand));
// Show the message dialog
await messageDialog.ShowAsync();
@@ -71,13 +69,13 @@ namespace ModernKeePass.Common
await dialog.ShowAsync();
}
- private static MessageDialog CreateBasicDialog(string title, string message, string dismissActionText)
+ private static MessageDialog CreateBasicDialog(string title, string message, string dismissActionText, UICommandInvokedHandler cancelCommand = null)
{
// Create the message dialog and set its content
var messageDialog = new MessageDialog(message, title);
// Add commands and set their callbacks;
- messageDialog.Commands.Add(new UICommand(dismissActionText));
+ messageDialog.Commands.Add(new UICommand(dismissActionText, cancelCommand));
// Set the command that will be invoked by default
messageDialog.DefaultCommandIndex = 1;
diff --git a/ModernKeePass/Services/DatabaseService.cs b/ModernKeePass/Services/DatabaseService.cs
index fcf64a5..8c44fd2 100644
--- a/ModernKeePass/Services/DatabaseService.cs
+++ b/ModernKeePass/Services/DatabaseService.cs
@@ -17,15 +17,6 @@ namespace ModernKeePass.Services
{
public class DatabaseService: IDatabase
{
- /*public enum DatabaseStatus
- {
- Error = -3,
- NoCompositeKey = -2,
- CompositeKeyError = -1,
- Closed = 0,
- Opening = 1,
- Opened = 2
- }*/
private readonly PwDatabase _pwDatabase = new PwDatabase();
private readonly ISettings _settings;
private StorageFile _realDatabaseFile;
@@ -44,7 +35,6 @@ namespace ModernKeePass.Services
}
}
- //public int Status { get; set; } = (int)DatabaseStatus.Closed;
public string Name => DatabaseFile?.Name;
public bool RecycleBinEnabled
@@ -58,26 +48,9 @@ namespace ModernKeePass.Services
get { return _databaseFile; }
set
{
- // No file, database is closed
- /*if (value == null)
- Status = (int) DatabaseStatus.Closed;
- else
- {
- // There already is an opened file
- if (Status == (int) DatabaseStatus.Opened)
- {
- if (_pwDatabase.Modified)
- throw new DatabaseOpenedException();
- Close().GetAwaiter().GetResult();
- }
- _databaseFile = value;
- Status = (int) DatabaseStatus.Opening;
- }*/
if (IsOpen)
{
- //if (_pwDatabase.Modified)
- throw new DatabaseOpenedException();
- //Close().GetAwaiter().GetResult();
+ throw new DatabaseOpenedException();
}
_databaseFile = value;
}
@@ -126,8 +99,6 @@ namespace ModernKeePass.Services
{
if (key == null)
{
- //Status = (int)DatabaseStatus.NoCompositeKey;
- //return;
throw new ArgumentNullException(nameof(key));
}
var ioConnection = IOConnectionInfo.FromFile(DatabaseFile);
@@ -164,14 +135,8 @@ namespace ModernKeePass.Services
}
catch (InvalidCompositeKeyException ex)
{
- //Status = (int)DatabaseStatus.CompositeKeyError;
throw new ArgumentException(ex.Message, ex);
}
- /*catch (Exception)
- {
- //Status = (int)DatabaseStatus.Error;
- throw;
- }*/
}
///
@@ -213,10 +178,6 @@ namespace ModernKeePass.Services
DatabaseFile = oldFile;
throw;
}
- /*finally
- {
- Status = (int)DatabaseStatus.Opened;
- }*/
}
///
@@ -234,7 +195,6 @@ namespace ModernKeePass.Services
await DatabaseFile.DeleteAsync();
}
DatabaseFile = null;
-
}
public void AddDeletedItem(PwUuid id)
diff --git a/ModernKeePass/ViewModels/EntryVm.cs b/ModernKeePass/ViewModels/EntryVm.cs
index 9f17918..6a59abb 100644
--- a/ModernKeePass/ViewModels/EntryVm.cs
+++ b/ModernKeePass/ViewModels/EntryVm.cs
@@ -46,12 +46,7 @@ namespace ModernKeePass.ViewModels
public string Name
{
- get
- {
- /*var title = GetEntryValue(PwDefs.TitleField);
- return title == null ? _resource.GetResourceValue("EntryNew") : title;*/
- return GetEntryValue(PwDefs.TitleField);
- }
+ get { return GetEntryValue(PwDefs.TitleField); }
set { SetEntryValue(PwDefs.TitleField, value); }
}