WIP Split composite key user control

Some refactoring
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-20 20:02:43 +02:00
parent 73670e8689
commit 310bd777b2
54 changed files with 849 additions and 1200 deletions

View File

@@ -1,31 +0,0 @@
using System;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.AOP;
using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.ViewModels.ListItems
{
public class ListMenuItemViewModel : NotifyPropertyChangedBase, IIsEnabled, ISelectableModel
{
private bool _isSelected;
public string Title { get; set; }
public string Group { get; set; } = "_";
public Type PageType { get; set; }
public Symbol SymbolIcon { get; set; }
public bool IsEnabled { get; set; } = true;
public bool IsSelected
{
get => _isSelected;
set => SetProperty(ref _isSelected, value);
}
public override string ToString()
{
return Title;
}
}
}

View File

@@ -1,10 +0,0 @@
using Windows.UI.Xaml.Controls;
namespace ModernKeePass.ViewModels.ListItems
{
public class MainMenuItemViewModel: ListMenuItemViewModel
{
public object Parameter { get; set; }
public Frame Destination { get; set; }
}
}

View File

@@ -1,36 +0,0 @@
using System.Threading.Tasks;
using Autofac;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.AOP;
using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.ViewModels.ListItems
{
public class RecentItemViewModel: NotifyPropertyChangedBase, ISelectableModel
{
private readonly IRecentService _recentService;
private bool _isSelected;
public string Token { get; set; }
public string Name { get; set; }
public bool IsSelected
{
get => _isSelected;
set => SetProperty(ref _isSelected, value);
}
public RecentItemViewModel(): this (App.Container.Resolve<IRecentService>())
{ }
public RecentItemViewModel(IRecentService recentService)
{
_recentService = recentService;
}
public async Task UpdateAccessTime()
{
await _recentService.Get(Token);
}
}
}

View File

@@ -1,101 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Autofac;
using ModernKeePass.Domain.AOP;
using ModernKeePass.Domain.Entities;
using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.ViewModels.ListItems
{
// TODO: implement Kdf settings
public class SettingsDatabaseViewModel: NotifyPropertyChangedBase
{
private readonly IDatabaseService _databaseService;
private readonly ICryptographyService _cryptographyService;
public bool HasRecycleBin
{
get => _databaseService.IsRecycleBinEnabled;
set {
// TODO: do something here
}
}
public bool IsNewRecycleBin
{
get => _databaseService.RecycleBin == null;
set
{
// TODO: make this work
if (value) _databaseService.AddEntity(_databaseService.RootGroupEntity, new Entity{Name = "Recycle Bin"});
}
}
public ObservableCollection<GroupEntity> Groups { get; set; }
public ObservableCollection<Entity> Ciphers => new ObservableCollection<Entity>(_cryptographyService.Ciphers);
public IEnumerable<string> Compressions => _cryptographyService.CompressionAlgorithms;
public IEnumerable<Entity> KeyDerivations => _cryptographyService.KeyDerivations;
public Entity SelectedCipher
{
get => Ciphers.FirstOrDefault(c => c.Id == _databaseService.Cipher.Id);
set
{
if (_databaseService.Cipher != value)
{
_databaseService.Cipher = value;
//OnPropertyChanged(nameof(SelectedCipher));
}
}
}
public Entity SelectedKeyDerivation
{
get => _databaseService.KeyDerivation;
set
{
if (_databaseService.KeyDerivation != value)
{
_databaseService.KeyDerivation = value;
OnPropertyChanged(nameof(SelectedKeyDerivation));
}
}
}
public string SelectedCompression
{
get => _databaseService.Compression;
set
{
if (_databaseService.Compression != value)
{
_databaseService.Compression = value;
OnPropertyChanged(nameof(SelectedCompression));
}
}
}
public GroupEntity SelectedRecycleBin
{
get => _databaseService.RecycleBin;
set
{
if (_databaseService.RecycleBin != value)
{
_databaseService.RecycleBin = value;
OnPropertyChanged(nameof(SelectedRecycleBin));
}
}
}
public SettingsDatabaseViewModel() : this(App.Container.Resolve<IDatabaseService>(), App.Container.Resolve<ICryptographyService>()) { }
public SettingsDatabaseViewModel(IDatabaseService databaseService, ICryptographyService cryptographyService)
{
_databaseService = databaseService;
_cryptographyService = cryptographyService;
Groups = new ObservableCollection<GroupEntity>(_databaseService.RootGroupEntity.SubGroups);
}
}
}

View File

@@ -1,33 +0,0 @@
using System.Collections.Generic;
using Autofac;
using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsNewViewModel
{
private readonly ISettingsService _settings;
public SettingsNewViewModel() : this(App.Container.Resolve<ISettingsService>())
{ }
public SettingsNewViewModel(ISettingsService settings)
{
_settings = settings;
}
public bool IsCreateSample
{
get => _settings.GetSetting<bool>("Sample");
set => _settings.PutSetting("Sample", value);
}
public IEnumerable<string> FileFormats => new []{"2", "4"};
public string FileFormatVersion
{
get => _settings.GetSetting("DefaultFileFormat", "2");
set => _settings.PutSetting("DefaultFileFormat", value);
}
}
}

View File

@@ -1,24 +0,0 @@
using Autofac;
using ModernKeePass.Domain.Interfaces;
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsSaveViewModel
{
private readonly ISettingsService _settings;
public SettingsSaveViewModel() : this(App.Container.Resolve<ISettingsService>())
{ }
public SettingsSaveViewModel(ISettingsService settings)
{
_settings = settings;
}
public bool IsSaveSuspend
{
get => _settings.GetSetting("SaveSuspend", true);
set => _settings.PutSetting("SaveSuspend", value);
}
}
}