Added Save As function

This commit is contained in:
2017-10-12 11:45:00 +02:00
committed by BONNEVILLE Geoffroy
parent 676365460c
commit 10b6330ac6
6 changed files with 39 additions and 48 deletions

View File

@@ -1,43 +0,0 @@
using System.ComponentModel;
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.UI.Xaml;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels
{
public class NewVm : INotifyPropertyChanged
{
public bool ShowPasswordBox
{
get { return ((App)Application.Current).Database.Status == DatabaseHelper.DatabaseStatus.Opening; }
}
public string Name
{
get { return ((App)Application.Current).Database.Name; }
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void OpenFile(StorageFile file)
{
var database = ((App)Application.Current).Database;
database.DatabaseFile = file;
NotifyPropertyChanged("Name");
NotifyPropertyChanged("ShowPasswordBox");
AddToRecentList(file);
}
private void AddToRecentList(StorageFile file)
{
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
mru.Add(file, file.DisplayName);
}
}
}

View File

@@ -1,6 +1,8 @@
using System.ComponentModel;
using Windows.UI.Xaml;
using ModernKeePass.Common;
using System;
using Windows.Storage;
namespace ModernKeePass.ViewModels
{
@@ -29,5 +31,12 @@ namespace ModernKeePass.ViewModels
app.Database.Close();
NotifyPropertyChanged("IsSaveEnabled");
}
internal void Save(StorageFile file)
{
var app = (App)Application.Current;
app.Database.Save(file);
NotifyPropertyChanged("IsSaveEnabled");
}
}
}