mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Moved application code to the Application layer
Imported Win10 project Code cleanup WIP - Use common UWP services for Win8.1 and Win10
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Database.Queries.OpenDatabase;
|
||||
using ModernKeePass.Application.Security.Commands.GenerateKeyFile;
|
||||
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -55,7 +54,7 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsValid => !_isOpening && (HasPassword || HasKeyFile && KeyFile != null || HasUserAccount);
|
||||
public bool IsValid => !_isOpening && (HasPassword || HasKeyFile && KeyFilePath != null || HasUserAccount);
|
||||
|
||||
public string Status
|
||||
{
|
||||
@@ -75,20 +74,19 @@ namespace ModernKeePass.ViewModels
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
OnPropertyChanged("PasswordComplexityIndicator");
|
||||
OnPropertyChanged(nameof(PasswordComplexityIndicator));
|
||||
StatusType = (int)StatusTypes.Normal;
|
||||
Status = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public StorageFile KeyFile
|
||||
public string KeyFilePath
|
||||
{
|
||||
get { return _keyFile; }
|
||||
get { return _keyFilePath; }
|
||||
set
|
||||
{
|
||||
_keyFile = value;
|
||||
KeyFileText = value?.Name;
|
||||
OnPropertyChanged("IsValid");
|
||||
_keyFilePath = value;
|
||||
OnPropertyChanged(nameof(IsValid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,21 +107,21 @@ namespace ModernKeePass.ViewModels
|
||||
private string _password = string.Empty;
|
||||
private string _status;
|
||||
private StatusTypes _statusType;
|
||||
private StorageFile _keyFile;
|
||||
private string _keyFilePath;
|
||||
private string _keyFileText;
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IResourceService _resource;
|
||||
private readonly ResourceHelper _resource;
|
||||
|
||||
public CompositeKeyVm() : this(App.Mediator, new ResourcesService()) { }
|
||||
public CompositeKeyVm() : this(App.Services.GetService<IMediator>()) { }
|
||||
|
||||
public CompositeKeyVm(IMediator mediator, IResourceService resource)
|
||||
public CompositeKeyVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_resource = new ResourceHelper();
|
||||
_keyFileText = _resource.GetResourceValue("CompositeKeyDefaultKeyFile");
|
||||
}
|
||||
|
||||
public async Task<bool> OpenDatabase(StorageFile databaseFile, bool createNew)
|
||||
public async Task<bool> OpenDatabase(string databaseFilePath, bool createNew)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -131,9 +129,9 @@ namespace ModernKeePass.ViewModels
|
||||
OnPropertyChanged(nameof(IsValid));
|
||||
|
||||
await _mediator.Send(new OpenDatabaseQuery {
|
||||
FilePath = StorageApplicationPermissions.FutureAccessList.Add(databaseFile),
|
||||
KeyFilePath = HasKeyFile && KeyFile != null ? StorageApplicationPermissions.FutureAccessList.Add(KeyFile) : null,
|
||||
Password = Password = HasPassword ? Password : null,
|
||||
FilePath = databaseFilePath,
|
||||
KeyFilePath = HasKeyFile ? KeyFilePath : null,
|
||||
Password = HasPassword ? Password : null,
|
||||
});
|
||||
RootGroupId = (await _mediator.Send(new GetDatabaseQuery())).RootGroupId;
|
||||
return true;
|
||||
@@ -163,18 +161,18 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
await _mediator.Send(new UpdateCredentialsCommand
|
||||
{
|
||||
KeyFilePath = HasKeyFile && KeyFile != null ? StorageApplicationPermissions.FutureAccessList.Add(KeyFile) : null,
|
||||
Password = Password = HasPassword ? Password : null,
|
||||
KeyFilePath = HasKeyFile ? KeyFilePath : null,
|
||||
Password = HasPassword ? Password : null,
|
||||
});
|
||||
UpdateStatus(_resource.GetResourceValue("CompositeKeyUpdated"), StatusTypes.Success);
|
||||
}
|
||||
|
||||
public async Task CreateKeyFile(StorageFile file)
|
||||
public async Task CreateKeyFile(FileInfo file)
|
||||
{
|
||||
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
||||
// TODO: implement entropy generator
|
||||
await _mediator.Send(new GenerateKeyFileCommand {KeyFilePath = token});
|
||||
KeyFile = file;
|
||||
await _mediator.Send(new GenerateKeyFileCommand {KeyFilePath = file.Path});
|
||||
KeyFilePath = file.Path;
|
||||
KeyFileText = file.Name;
|
||||
}
|
||||
|
||||
private void UpdateStatus(string text, StatusTypes type)
|
||||
|
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
@@ -22,6 +23,7 @@ using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -49,21 +51,13 @@ namespace ModernKeePass.ViewModels
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set
|
||||
{
|
||||
_isSelected = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public double PasswordLength
|
||||
{
|
||||
get { return _passwordLength; }
|
||||
set
|
||||
{
|
||||
_passwordLength = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
set { SetProperty(ref _passwordLength, value); }
|
||||
}
|
||||
|
||||
public string Title
|
||||
@@ -191,31 +185,19 @@ namespace ModernKeePass.ViewModels
|
||||
public bool IsEditMode
|
||||
{
|
||||
get { return IsSelected && _isEditMode; }
|
||||
set
|
||||
{
|
||||
_isEditMode = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
set { SetProperty(ref _isEditMode, value); }
|
||||
}
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get { return _isVisible; }
|
||||
set
|
||||
{
|
||||
_isVisible = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
set { SetProperty(ref _isVisible, value); }
|
||||
}
|
||||
|
||||
public bool IsRevealPassword
|
||||
{
|
||||
get { return _isRevealPassword; }
|
||||
set
|
||||
{
|
||||
_isRevealPassword = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
set { SetProperty(ref _isRevealPassword, value); }
|
||||
}
|
||||
|
||||
public bool CanRestore => _entry.ParentGroupId == _database.RecycleBinId;
|
||||
@@ -237,7 +219,7 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public EntryDetailVm() { }
|
||||
|
||||
internal EntryDetailVm(string entryId, bool isNewEntry = false) : this(entryId, App.Mediator, isNewEntry) { }
|
||||
internal EntryDetailVm(string entryId, bool isNewEntry = false) : this(entryId, App.Services.GetService<IMediator>(), isNewEntry) { }
|
||||
|
||||
public EntryDetailVm(string entryId, IMediator mediator, bool isNewEntry = false)
|
||||
{
|
||||
|
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
@@ -23,6 +24,7 @@ using ModernKeePass.Application.Group.Commands.SortGroups;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
@@ -122,7 +124,7 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public GroupDetailVm() {}
|
||||
|
||||
internal GroupDetailVm(string groupId) : this(groupId, App.Mediator)
|
||||
internal GroupDetailVm(string groupId) : this(groupId, App.Services.GetService<IMediator>())
|
||||
{ }
|
||||
|
||||
public GroupDetailVm(string groupId, IMediator mediator, bool isEditMode = false)
|
||||
|
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
|
@@ -1,20 +1,20 @@
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Common;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentItemVm: NotifyPropertyChangedBase, ISelectableModel, IRecentItem
|
||||
public class RecentItemVm: NotifyPropertyChangedBase, ISelectableModel
|
||||
{
|
||||
private readonly IRecentProxy _recent;
|
||||
private bool _isSelected;
|
||||
|
||||
public StorageFile DatabaseFile { get; }
|
||||
public string Token { get; }
|
||||
public string Name { get; }
|
||||
public string Path => DatabaseFile?.Path;
|
||||
public string Path => string.Empty;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
@@ -22,22 +22,17 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public RecentItemVm() {}
|
||||
public RecentItemVm(string token, string metadata, IStorageItem file)
|
||||
public RecentItemVm(FileInfo file): this(App.Services.GetService<IRecentProxy>(), file) {}
|
||||
public RecentItemVm(IRecentProxy recent, FileInfo file)
|
||||
{
|
||||
Token = token;
|
||||
Name = metadata;
|
||||
DatabaseFile = file as StorageFile;
|
||||
_recent = recent;
|
||||
Token = file.Path;
|
||||
Name = file.Name;
|
||||
}
|
||||
|
||||
public void UpdateAccessTime()
|
||||
public async Task UpdateAccessTime()
|
||||
{
|
||||
UpdateAccessTime(RecentService.Instance).Wait();
|
||||
}
|
||||
|
||||
public async Task UpdateAccessTime(IRecentService recent)
|
||||
{
|
||||
await recent.GetFileAsync(Token);
|
||||
await _recent.Get(Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
@@ -15,7 +16,7 @@ using ModernKeePass.Application.Parameters.Models;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCiphers;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCompressions;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -73,7 +74,7 @@ namespace ModernKeePass.ViewModels
|
||||
set { _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id}).Wait(); }
|
||||
}
|
||||
|
||||
public SettingsDatabaseVm() : this(App.Mediator) { }
|
||||
public SettingsDatabaseVm() : this(App.Services.GetService<IMediator>()) { }
|
||||
|
||||
public SettingsDatabaseVm(IMediator mediator)
|
||||
{
|
||||
|
@@ -1,17 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SettingsNewVm
|
||||
{
|
||||
private readonly ISettingsService _settings;
|
||||
private readonly ISettingsProxy _settings;
|
||||
|
||||
public SettingsNewVm() : this(SettingsService.Instance)
|
||||
public SettingsNewVm() : this(App.Services.GetService<ISettingsProxy>())
|
||||
{ }
|
||||
|
||||
public SettingsNewVm(ISettingsService settings)
|
||||
public SettingsNewVm(ISettingsProxy settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
@@ -1,16 +1,16 @@
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class SettingsSaveVm
|
||||
{
|
||||
private readonly ISettingsService _settings;
|
||||
private readonly ISettingsProxy _settings;
|
||||
|
||||
public SettingsSaveVm() : this(SettingsService.Instance)
|
||||
public SettingsSaveVm() : this(App.Services.GetService<ISettingsProxy>())
|
||||
{ }
|
||||
|
||||
public SettingsSaveVm(ISettingsService settings)
|
||||
public SettingsSaveVm(ISettingsProxy settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
@@ -1,14 +1,15 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
using ModernKeePass.Views;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
@@ -48,12 +49,13 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public MainVm() {}
|
||||
|
||||
internal MainVm(Frame referenceFrame, Frame destinationFrame, StorageFile databaseFile = null) : this(referenceFrame, destinationFrame,
|
||||
App.Mediator, new ResourcesService(), RecentService.Instance, databaseFile)
|
||||
internal MainVm(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile = null) : this(referenceFrame, destinationFrame,
|
||||
App.Services.GetService<IMediator>(), App.Services.GetService<IRecentProxy>(), databaseFile)
|
||||
{ }
|
||||
|
||||
public MainVm(Frame referenceFrame, Frame destinationFrame, IMediator mediator, IResourceService resource, IRecentService recent, StorageFile databaseFile = null)
|
||||
public MainVm(Frame referenceFrame, Frame destinationFrame, IMediator mediator, IRecentProxy recent, FileInfo databaseFile = null)
|
||||
{
|
||||
var resource = new ResourceHelper();
|
||||
var database = mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
|
||||
var mainMenuItems = new ObservableCollection<MainMenuItemVm>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Entry.Commands.SetFieldValue;
|
||||
using ModernKeePass.Application.Group.Commands.CreateEntry;
|
||||
@@ -8,15 +10,13 @@ using ModernKeePass.Application.Group.Commands.CreateGroup;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class NewVm : OpenVm
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly ISettingsService _settings;
|
||||
private readonly ISettingsProxy _settings;
|
||||
private string _importFormatHelp;
|
||||
public string Password { get; set; }
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public string ImportFileExtensionFilter { get; set; } = "*";
|
||||
|
||||
public IFormat ImportFormat { get; set; }
|
||||
public IImportFormat ImportFormat { get; set; }
|
||||
|
||||
public string ImportFormatHelp
|
||||
{
|
||||
@@ -38,9 +38,9 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public NewVm(): this(App.Mediator, new SettingsService()) { }
|
||||
public NewVm(): this(App.Services.GetService<IMediator>(), App.Services.GetService<ISettingsProxy>()) { }
|
||||
|
||||
public NewVm(IMediator mediator, ISettingsService settings)
|
||||
public NewVm(IMediator mediator, ISettingsProxy settings)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_settings = settings;
|
||||
|
@@ -1,38 +1,38 @@
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class OpenVm: NotifyPropertyChangedBase
|
||||
{
|
||||
private readonly IRecentService _recent;
|
||||
public bool IsFileSelected => DatabaseFile != null;
|
||||
private readonly IRecentProxy _recent;
|
||||
public bool IsFileSelected => !string.IsNullOrEmpty(Path);
|
||||
|
||||
public string Name => DatabaseFile?.DisplayName;
|
||||
public string Name { get; private set; }
|
||||
public string Path { get; private set; }
|
||||
|
||||
public StorageFile DatabaseFile { get; private set; }
|
||||
public OpenVm(): this(App.Services.GetService<IRecentProxy>()) { }
|
||||
|
||||
public OpenVm(): this(new RecentService()) { }
|
||||
|
||||
public OpenVm(IRecentService recent)
|
||||
public OpenVm(IRecentProxy recent)
|
||||
{
|
||||
_recent = recent;
|
||||
}
|
||||
|
||||
public void OpenFile(StorageFile file)
|
||||
public async Task OpenFile(FileInfo file)
|
||||
{
|
||||
DatabaseFile = file;
|
||||
OnPropertyChanged("Name");
|
||||
OnPropertyChanged("IsFileSelected");
|
||||
OnPropertyChanged("DatabaseFile");
|
||||
AddToRecentList(file);
|
||||
Name = file.Name;
|
||||
Path = file.Path;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
OnPropertyChanged(nameof(IsFileSelected));
|
||||
await AddToRecentList(file);
|
||||
}
|
||||
|
||||
private void AddToRecentList(StorageFile file)
|
||||
private async Task AddToRecentList(FileInfo file)
|
||||
{
|
||||
_recent.Add(file, file.DisplayName);
|
||||
await _recent.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,21 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Services;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
public class RecentVm : NotifyPropertyChangedBase, IHasSelectableObject
|
||||
{
|
||||
private readonly IRecentService _recent;
|
||||
private readonly IRecentProxy _recent;
|
||||
private ISelectableModel _selectedItem;
|
||||
private ObservableCollection<IRecentItem> _recentItems = new ObservableCollection<IRecentItem>();
|
||||
private ObservableCollection<RecentItemVm> _recentItems;
|
||||
|
||||
public ObservableCollection<IRecentItem> RecentItems
|
||||
public ObservableCollection<RecentItemVm> RecentItems
|
||||
{
|
||||
get { return _recentItems; }
|
||||
set { SetProperty(ref _recentItems, value); }
|
||||
@@ -39,15 +41,16 @@ namespace ModernKeePass.ViewModels
|
||||
|
||||
public ICommand ClearAllCommand { get; }
|
||||
|
||||
public RecentVm() : this (RecentService.Instance)
|
||||
public RecentVm() : this (App.Services.GetService<IRecentProxy>())
|
||||
{ }
|
||||
|
||||
public RecentVm(IRecentService recent)
|
||||
public RecentVm(IRecentProxy recent)
|
||||
{
|
||||
_recent = recent;
|
||||
ClearAllCommand = new RelayCommand(ClearAll);
|
||||
|
||||
RecentItems = _recent.GetAllFiles();
|
||||
RecentItems = new ObservableCollection<RecentItemVm>(_recent.GetAll().GetAwaiter().GetResult()
|
||||
.Select(r => new RecentItemVm(r)));
|
||||
if (RecentItems.Count > 0)
|
||||
SelectedItem = RecentItems[0] as RecentItemVm;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Commands.CloseDatabase;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
|
||||
@@ -10,7 +11,7 @@ namespace ModernKeePass.ViewModels
|
||||
public class SaveVm
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
public SaveVm() : this(App.Mediator) { }
|
||||
public SaveVm() : this(App.Services.GetService<IMediator>()) { }
|
||||
|
||||
public SaveVm(IMediator mediator)
|
||||
{
|
||||
|
@@ -2,12 +2,12 @@
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Interfaces;
|
||||
using ModernKeePass.Views;
|
||||
using ModernKeePass.Services;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -43,10 +43,11 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsVm() : this(App.Mediator, new ResourcesService()) { }
|
||||
public SettingsVm() : this(App.Services.GetService<IMediator>()) { }
|
||||
|
||||
public SettingsVm(IMediator mediator, IResourceService resource)
|
||||
public SettingsVm(IMediator mediator)
|
||||
{
|
||||
var resource = new ResourceHelper();
|
||||
var database = mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var menuItems = new ObservableCollection<ListMenuItemVm>
|
||||
{
|
||||
|
Reference in New Issue
Block a user