mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00

Refactor the Database Service (no more enum, ...) Restored the Donate page with Paypal web page Added (but not working) MS App Center integration Corrected tests accordingly WIP AOP to detect database changes
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Windows.Storage;
|
|
using ModernKeePass.Common;
|
|
using ModernKeePass.Interfaces;
|
|
using ModernKeePass.Services;
|
|
|
|
namespace ModernKeePass.ViewModels
|
|
{
|
|
public class OpenVm: NotifyPropertyChangedBase
|
|
{
|
|
public bool ShowPasswordBox => _database.IsFileOpen;
|
|
|
|
public string Name => _database?.Name;
|
|
|
|
private readonly IDatabaseService _database;
|
|
|
|
public OpenVm() : this(DatabaseService.Instance) { }
|
|
|
|
public OpenVm(IDatabaseService database)
|
|
{
|
|
_database = database;
|
|
if (database == null || !database.IsFileOpen) return;
|
|
OpenFile(database.DatabaseFile);
|
|
}
|
|
|
|
public void OpenFile(StorageFile file)
|
|
{
|
|
OpenFile(file, RecentService.Instance);
|
|
}
|
|
|
|
public void OpenFile(StorageFile file, IRecentService recent)
|
|
{
|
|
_database.DatabaseFile = file;
|
|
OnPropertyChanged("Name");
|
|
OnPropertyChanged("ShowPasswordBox");
|
|
AddToRecentList(file, recent);
|
|
}
|
|
|
|
private void AddToRecentList(StorageFile file, IRecentService recent)
|
|
{
|
|
recent.Add(file, file.DisplayName);
|
|
}
|
|
}
|
|
}
|