mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Updated Settings page
Added new settings (history and clipboard) Renamed and moved Settings Vms
This commit is contained in:
37
WinAppCommon/ViewModels/Items/SettingsCredentialsVm.cs
Normal file
37
WinAppCommon/ViewModels/Items/SettingsCredentialsVm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
{
|
||||
public class SettingsCredentialsVm: ViewModelBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INotificationService _notification;
|
||||
|
||||
public SettingsCredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_notification = notification;
|
||||
|
||||
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
|
||||
}
|
||||
|
||||
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
|
||||
{
|
||||
await _mediator.Send(new UpdateCredentialsCommand
|
||||
{
|
||||
KeyFilePath = message.KeyFilePath,
|
||||
Password = message.Password
|
||||
});
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
||||
}
|
||||
}
|
||||
}
|
7
WinAppCommon/ViewModels/Items/SettingsHistoryVm.cs
Normal file
7
WinAppCommon/ViewModels/Items/SettingsHistoryVm.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
{
|
||||
public class SettingsHistoryVm
|
||||
{
|
||||
|
||||
}
|
||||
}
|
57
WinAppCommon/ViewModels/Items/SettingsRecycleBinVm.cs
Normal file
57
WinAppCommon/ViewModels/Items/SettingsRecycleBinVm.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
|
||||
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
{
|
||||
public class SettingsRecycleBinVm: ObservableObject
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
public bool HasRecycleBin
|
||||
{
|
||||
get { return _database.IsRecycleBinEnabled; }
|
||||
set
|
||||
{
|
||||
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
|
||||
RaisePropertyChanged(nameof(HasRecycleBin));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewRecycleBin
|
||||
{
|
||||
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IEntityVm> Groups { get; }
|
||||
|
||||
public IEntityVm SelectedRecycleBin
|
||||
{
|
||||
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsRecycleBinVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
|
||||
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,37 +1,57 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetCipher;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetCompression;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation;
|
||||
using ModernKeePass.Application.Parameters.Models;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCiphers;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCompressions;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations;
|
||||
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
{
|
||||
public class SettingsSecurityVm: ViewModelBase
|
||||
// TODO: implement Kdf settings
|
||||
public class SettingsSecurityVm: ObservableObject
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INotificationService _notification;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
|
||||
public SettingsSecurityVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
|
||||
public ObservableCollection<CipherVm> Ciphers { get; }
|
||||
public IEnumerable<string> Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult();
|
||||
public ObservableCollection<KeyDerivationVm> KeyDerivations { get; }
|
||||
|
||||
public CipherVm SelectedCipher
|
||||
{
|
||||
get { return Ciphers.FirstOrDefault(c => c.Id == _database.CipherId); }
|
||||
set { _mediator.Send(new SetCipherCommand {CipherId = value.Id}).Wait(); }
|
||||
}
|
||||
|
||||
public string SelectedCompression
|
||||
{
|
||||
get { return Compressions.FirstOrDefault(c => c == _database.Compression); }
|
||||
set { _mediator.Send(new SetCompressionCommand {Compression = value}).Wait(); }
|
||||
}
|
||||
|
||||
public KeyDerivationVm SelectedKeyDerivation
|
||||
{
|
||||
get { return KeyDerivations.FirstOrDefault(c => c.Id == _database.KeyDerivationId); }
|
||||
set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); }
|
||||
}
|
||||
|
||||
public SettingsSecurityVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_notification = notification;
|
||||
|
||||
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
|
||||
}
|
||||
|
||||
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
|
||||
{
|
||||
await _mediator.Send(new UpdateCredentialsCommand
|
||||
{
|
||||
KeyFilePath = message.KeyFilePath,
|
||||
Password = message.Password
|
||||
});
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult();
|
||||
Ciphers = new ObservableCollection<CipherVm>(ciphers);
|
||||
var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult();
|
||||
KeyDerivations = new ObservableCollection<KeyDerivationVm>(keyDerivations);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
WinAppCommon/ViewModels/Settings/CredentialsVm.cs
Normal file
37
WinAppCommon/ViewModels/Settings/CredentialsVm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class CredentialsVm: ViewModelBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INotificationService _notification;
|
||||
|
||||
public CredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_notification = notification;
|
||||
|
||||
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
|
||||
}
|
||||
|
||||
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
|
||||
{
|
||||
await _mediator.Send(new UpdateCredentialsCommand
|
||||
{
|
||||
KeyFilePath = message.KeyFilePath,
|
||||
Password = message.Password
|
||||
});
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
||||
}
|
||||
}
|
||||
}
|
28
WinAppCommon/ViewModels/Settings/GeneralVm.cs
Normal file
28
WinAppCommon/ViewModels/Settings/GeneralVm.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class GeneralVm
|
||||
{
|
||||
private readonly ISettingsProxy _settings;
|
||||
|
||||
public bool IsSaveSuspend
|
||||
{
|
||||
get { return _settings.GetSetting(Constants.Settings.SaveSuspend, true); }
|
||||
set { _settings.PutSetting(Constants.Settings.SaveSuspend, value); }
|
||||
}
|
||||
|
||||
public int CopyExpiration
|
||||
{
|
||||
get { return _settings.GetSetting(Constants.Settings.ClipboardTimeout, 10); }
|
||||
set { _settings.PutSetting(Constants.Settings.ClipboardTimeout, value); }
|
||||
}
|
||||
|
||||
public GeneralVm(ISettingsProxy settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
32
WinAppCommon/ViewModels/Settings/HistoryVm.cs
Normal file
32
WinAppCommon/ViewModels/Settings/HistoryVm.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetMaxHistoryCount;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetMaxHistorySize;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class HistoryVm
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
public int MaxCount
|
||||
{
|
||||
get { return _database.MaxHistoryCount; }
|
||||
set { _mediator.Send(new SetMaxHistoryCountCommand { MaxHistoryCount = value }).Wait(); }
|
||||
}
|
||||
|
||||
public long MaxSize
|
||||
{
|
||||
get { return _database.MaxHistorySize / 1024 / 1024; }
|
||||
set { _mediator.Send(new SetMaxHistorySizeCommand { MaxHistorySize = value * 1024 * 1024 }).Wait(); }
|
||||
}
|
||||
|
||||
public HistoryVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
57
WinAppCommon/ViewModels/Settings/RecycleBinVm.cs
Normal file
57
WinAppCommon/ViewModels/Settings/RecycleBinVm.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class RecycleBinVm: ObservableObject
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
public bool HasRecycleBin
|
||||
{
|
||||
get { return _database.IsRecycleBinEnabled; }
|
||||
set
|
||||
{
|
||||
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
|
||||
RaisePropertyChanged(nameof(HasRecycleBin));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewRecycleBin
|
||||
{
|
||||
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IEntityVm> Groups { get; }
|
||||
|
||||
public IEntityVm SelectedRecycleBin
|
||||
{
|
||||
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public RecycleBinVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
|
||||
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,48 +3,24 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetCipher;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetCompression;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
|
||||
using ModernKeePass.Application.Parameters.Models;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCiphers;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetCompressions;
|
||||
using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations;
|
||||
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
// TODO: implement Kdf settings
|
||||
public class SettingsDatabaseVm: ObservableObject
|
||||
public class SecurityVm: ObservableObject
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
public bool HasRecycleBin
|
||||
{
|
||||
get { return _database.IsRecycleBinEnabled; }
|
||||
set
|
||||
{
|
||||
_mediator.Send(new SetHasRecycleBinCommand {HasRecycleBin = value}).Wait();
|
||||
RaisePropertyChanged(nameof(HasRecycleBin));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewRecycleBin
|
||||
{
|
||||
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IEntityVm> Groups { get; }
|
||||
public ObservableCollection<CipherVm> Ciphers { get; }
|
||||
public IEnumerable<string> Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult();
|
||||
public ObservableCollection<KeyDerivationVm> KeyDerivations { get; }
|
||||
@@ -67,21 +43,10 @@ namespace ModernKeePass.ViewModels.ListItems
|
||||
set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); }
|
||||
}
|
||||
|
||||
public IEntityVm SelectedRecycleBin
|
||||
{
|
||||
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id}).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsDatabaseVm(IMediator mediator)
|
||||
public SecurityVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
|
||||
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
|
||||
var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult();
|
||||
Ciphers = new ObservableCollection<CipherVm>(ciphers);
|
||||
var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult();
|
37
WinAppCommon/ViewModels/Settings/SettingsCredentialsVm.cs
Normal file
37
WinAppCommon/ViewModels/Settings/SettingsCredentialsVm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using Messages;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class SettingsCredentialsVm: ViewModelBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INotificationService _notification;
|
||||
|
||||
public SettingsCredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_resource = resource;
|
||||
_notification = notification;
|
||||
|
||||
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
|
||||
}
|
||||
|
||||
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
|
||||
{
|
||||
await _mediator.Send(new UpdateCredentialsCommand
|
||||
{
|
||||
KeyFilePath = message.KeyFilePath,
|
||||
Password = message.Password
|
||||
});
|
||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
||||
}
|
||||
}
|
||||
}
|
7
WinAppCommon/ViewModels/Settings/SettingsHistoryVm.cs
Normal file
7
WinAppCommon/ViewModels/Settings/SettingsHistoryVm.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class SettingsHistoryVm
|
||||
{
|
||||
|
||||
}
|
||||
}
|
53
WinAppCommon/ViewModels/Settings/SettingsNewVm.cs
Normal file
53
WinAppCommon/ViewModels/Settings/SettingsNewVm.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class SettingsNewVm
|
||||
{
|
||||
private readonly ISettingsProxy _settings;
|
||||
|
||||
public SettingsNewVm(ISettingsProxy settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public bool IsCreateSample
|
||||
{
|
||||
get { return _settings.GetSetting(Constants.Settings.Sample, true); }
|
||||
set { _settings.PutSetting(Constants.Settings.Sample, value); }
|
||||
}
|
||||
|
||||
public IEnumerable<DatabaseFormat> FileFormats => new []
|
||||
{
|
||||
new DatabaseFormat
|
||||
{
|
||||
Version = "4",
|
||||
DisplayText = "4 (Argon2, ChaCha20)"
|
||||
},
|
||||
new DatabaseFormat
|
||||
{
|
||||
Version = "3",
|
||||
DisplayText = "3 (AES-KDF, AES/Rijndael)"
|
||||
}
|
||||
};
|
||||
|
||||
public DatabaseFormat DatabaseFormatVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var version = _settings.GetSetting(Constants.Settings.DefaultFileFormat, "4");
|
||||
return FileFormats.FirstOrDefault(f => f.Version == version);
|
||||
}
|
||||
set { _settings.PutSetting(Constants.Settings.DefaultFileFormat, value.Version); }
|
||||
}
|
||||
}
|
||||
|
||||
public class DatabaseFormat
|
||||
{
|
||||
public string Version { get; set; }
|
||||
public string DisplayText { get; set; }
|
||||
}
|
||||
}
|
57
WinAppCommon/ViewModels/Settings/SettingsRecycleBinVm.cs
Normal file
57
WinAppCommon/ViewModels/Settings/SettingsRecycleBinVm.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Models;
|
||||
using ModernKeePass.Application.Database.Queries.GetDatabase;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
|
||||
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class SettingsRecycleBinVm: ObservableObject
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly DatabaseVm _database;
|
||||
|
||||
public bool HasRecycleBin
|
||||
{
|
||||
get { return _database.IsRecycleBinEnabled; }
|
||||
set
|
||||
{
|
||||
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
|
||||
RaisePropertyChanged(nameof(HasRecycleBin));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewRecycleBin
|
||||
{
|
||||
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IEntityVm> Groups { get; }
|
||||
|
||||
public IEntityVm SelectedRecycleBin
|
||||
{
|
||||
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
|
||||
set
|
||||
{
|
||||
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsRecycleBinVm(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
|
||||
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
|
||||
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
|
||||
}
|
||||
}
|
||||
}
|
21
WinAppCommon/ViewModels/Settings/SettingsSaveVm.cs
Normal file
21
WinAppCommon/ViewModels/Settings/SettingsSaveVm.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Common;
|
||||
|
||||
namespace ModernKeePass.ViewModels.Settings
|
||||
{
|
||||
public class SettingsSaveVm
|
||||
{
|
||||
private readonly ISettingsProxy _settings;
|
||||
|
||||
public SettingsSaveVm(ISettingsProxy settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public bool IsSaveSuspend
|
||||
{
|
||||
get { return _settings.GetSetting(Constants.Settings.SaveSuspend, true); }
|
||||
set { _settings.PutSetting(Constants.Settings.SaveSuspend, value); }
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ using GalaSoft.MvvmLight.Views;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.ViewModels.ListItems;
|
||||
using ModernKeePass.ViewModels.Settings;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
{
|
||||
@@ -57,10 +57,12 @@ namespace ModernKeePass.ViewModels
|
||||
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<INotificationService>());
|
||||
}
|
||||
|
||||
SimpleIoc.Default.Register<SettingsDatabaseVm>();
|
||||
SimpleIoc.Default.Register<SecurityVm>();
|
||||
SimpleIoc.Default.Register<SettingsNewVm>();
|
||||
SimpleIoc.Default.Register<SettingsSaveVm>();
|
||||
SimpleIoc.Default.Register<SettingsSecurityVm>();
|
||||
SimpleIoc.Default.Register<GeneralVm>();
|
||||
SimpleIoc.Default.Register<CredentialsVm>();
|
||||
SimpleIoc.Default.Register<RecycleBinVm>();
|
||||
SimpleIoc.Default.Register<HistoryVm>();
|
||||
SimpleIoc.Default.Register<OpenDatabaseControlVm>();
|
||||
SimpleIoc.Default.Register<SetCredentialsVm>();
|
||||
SimpleIoc.Default.Register<TopMenuVm>();
|
||||
@@ -70,10 +72,12 @@ namespace ModernKeePass.ViewModels
|
||||
SimpleIoc.Default.Register<SaveVm>();
|
||||
}
|
||||
|
||||
public SettingsDatabaseVm SettingsDatabase => ServiceLocator.Current.GetInstance<SettingsDatabaseVm>(Guid.NewGuid().ToString());
|
||||
public SecurityVm Security => ServiceLocator.Current.GetInstance<SecurityVm>(Guid.NewGuid().ToString());
|
||||
public SettingsNewVm SettingsNew => ServiceLocator.Current.GetInstance<SettingsNewVm>(Guid.NewGuid().ToString());
|
||||
public SettingsSaveVm SettingsSave => ServiceLocator.Current.GetInstance<SettingsSaveVm>(Guid.NewGuid().ToString());
|
||||
public SettingsSecurityVm SettingsSecurity => ServiceLocator.Current.GetInstance<SettingsSecurityVm>(Guid.NewGuid().ToString());
|
||||
public GeneralVm General => ServiceLocator.Current.GetInstance<GeneralVm>(Guid.NewGuid().ToString());
|
||||
public CredentialsVm Credentials => ServiceLocator.Current.GetInstance<CredentialsVm>(Guid.NewGuid().ToString());
|
||||
public RecycleBinVm RecycleBin => ServiceLocator.Current.GetInstance<RecycleBinVm>(Guid.NewGuid().ToString());
|
||||
public HistoryVm History => ServiceLocator.Current.GetInstance<HistoryVm>(Guid.NewGuid().ToString());
|
||||
public OpenDatabaseControlVm OpenDatabaseControl => ServiceLocator.Current.GetInstance<OpenDatabaseControlVm>(Guid.NewGuid().ToString());
|
||||
public SetCredentialsVm SetCredentials => ServiceLocator.Current.GetInstance<SetCredentialsVm>(Guid.NewGuid().ToString());
|
||||
public TopMenuVm TopMenu => ServiceLocator.Current.GetInstance<TopMenuVm>(Guid.NewGuid().ToString());
|
||||
|
@@ -43,14 +43,16 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Messages\SaveErrorMessage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\AboutVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\EntryFieldVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\CredentialsVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\HistoryVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\SettingsNewVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\RecycleBinVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\GeneralVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\SecurityVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\ViewModelLocatorCommon.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\ListMenuItemVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\MainMenuItemVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\RecentItemVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsDatabaseVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsNewVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsSaveVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsSecurityVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\NewVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\OpenVm.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\RecentVm.cs" />
|
||||
|
Reference in New Issue
Block a user