mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50: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:
@@ -0,0 +1,101 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user