2017-10-10 15:00:31 +02:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Windows.Storage;
|
|
|
|
|
using Windows.Storage.AccessCache;
|
2017-10-11 18:43:27 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using ModernKeePass.Common;
|
2017-10-10 15:00:31 +02:00
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class OpenVm: INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public bool ShowPasswordBox
|
|
|
|
|
{
|
2017-10-11 18:43:27 +02:00
|
|
|
|
get { return ((App)Application.Current).Database.Status == DatabaseHelper.DatabaseStatus.Opening; }
|
2017-10-10 15:00:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
2017-10-11 18:43:27 +02:00
|
|
|
|
get { return ((App)Application.Current).Database.Name; }
|
2017-10-10 15:00:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
2017-10-11 14:30:07 +02:00
|
|
|
|
|
2017-10-10 15:00:31 +02:00
|
|
|
|
private void NotifyPropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenFile(StorageFile file)
|
|
|
|
|
{
|
2017-10-11 18:43:27 +02:00
|
|
|
|
var database = ((App)Application.Current).Database;
|
|
|
|
|
database.DatabaseFile = file;
|
2017-10-10 15:00:31 +02:00
|
|
|
|
NotifyPropertyChanged("Name");
|
|
|
|
|
NotifyPropertyChanged("ShowPasswordBox");
|
|
|
|
|
AddToRecentList(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddToRecentList(StorageFile file)
|
|
|
|
|
{
|
|
|
|
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
|
|
|
|
mru.Add(file, file.DisplayName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|