mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP New database (and open and recent...)
This commit is contained in:
@@ -8,7 +8,6 @@ namespace ModernKeePass.ViewModels
|
||||
private bool _isSelected;
|
||||
public string Token { get; set; }
|
||||
public string Name { get; set; }
|
||||
public StorageFile File { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
|
@@ -53,7 +53,10 @@ namespace ModernKeePass.ViewModels
|
||||
Title = "Open", PageType = typeof(OpenDatabasePage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Page2,
|
||||
IsSelected = app.Database.Status == DatabaseHelper.DatabaseStatus.Opening
|
||||
},
|
||||
new MainMenuItemVm {Title = "New" /*, PageType = typeof(NewDatabasePage)*/, Destination = destinationFrame, SymbolIcon = Symbol.Add},
|
||||
new MainMenuItemVm
|
||||
{
|
||||
Title = "New" , PageType = typeof(NewDatabasePage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Add
|
||||
},
|
||||
new MainMenuItemVm
|
||||
{
|
||||
Title = "Save" , PageType = typeof(SaveDatabasePage), Destination = destinationFrame, Parameter = referenceFrame, SymbolIcon = Symbol.Save,
|
||||
|
43
ModernKeePass/ViewModels/NewVm.cs
Normal file
43
ModernKeePass/ViewModels/NewVm.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,25 +1,25 @@
|
||||
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 File != null; }
|
||||
get { return ((App)Application.Current).Database.Status == DatabaseHelper.DatabaseStatus.Opening; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return File?.Name; }
|
||||
get { return ((App)Application.Current).Database.Name; }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
private void NotifyPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
@@ -27,7 +27,8 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public void OpenFile(StorageFile file)
|
||||
{
|
||||
File = file;
|
||||
var database = ((App)Application.Current).Database;
|
||||
database.DatabaseFile = file;
|
||||
NotifyPropertyChanged("Name");
|
||||
NotifyPropertyChanged("ShowPasswordBox");
|
||||
AddToRecentList(file);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.UI.Xaml;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
@@ -36,7 +37,14 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
|
||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||
_selectedItem.File = mru.GetFileAsync(SelectedItem.Token).GetAwaiter().GetResult();
|
||||
var database = ((App)Application.Current).Database;
|
||||
try
|
||||
{
|
||||
database.DatabaseFile = mru.GetFileAsync(SelectedItem.Token).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user