mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Updated Settings page
Added new settings (history and clipboard) Renamed and moved Settings Vms
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user