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,31 +1,24 @@
using System.ComponentModel;
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.UI.Xaml;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels
{
public class OpenVm: INotifyPropertyChanged
{
public StorageFile File { get; set; }
public bool ShowPasswordBox
{
get { return ((App) Application.Current).Database.Status == DatabaseHelper.DatabaseStatus.Opening; }
get { return File != null; }
}
public string Name
{
get { return ((App) Application.Current).Database.Name; }
get { return File?.Name; }
}
public event PropertyChangedEventHandler PropertyChanged;
public OpenVm()
{
var database = ((App) Application.Current).Database;
if (database == null || database.Status != DatabaseHelper.DatabaseStatus.Opening) return;
OpenFile(database.DatabaseFile);
}
private void NotifyPropertyChanged(string propertyName)
{
@@ -34,8 +27,7 @@ namespace ModernKeePass.ViewModels
public void OpenFile(StorageFile file)
{
var database = ((App)Application.Current).Database;
database.DatabaseFile = file;
File = file;
NotifyPropertyChanged("Name");
NotifyPropertyChanged("ShowPasswordBox");
AddToRecentList(file);