Add MVVM Light library

Updated nuget packages
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-21 13:07:17 +02:00
parent 75f6e2f840
commit a1085b6010
16 changed files with 204 additions and 66 deletions

View File

@@ -0,0 +1,47 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.CreateDatabase;
using ModernKeePass.Common;
using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.ViewModels
{
public class SetCredentialsViewModel : OpenDatabaseControlVm
{
private readonly ICredentialsProxy _credentials;
private readonly ISettingsProxy _settings;
private string _confirmPassword;
public string ConfirmPassword
{
get { return _confirmPassword; }
set { SetProperty(ref _confirmPassword, value); }
}
public double PasswordComplexityIndicator => _credentials.EstimatePasswordComplexity(Password);
public new bool IsValid => HasPassword && Password == ConfirmPassword || HasKeyFile && KeyFilePath != string.Empty;
public SetCredentialsViewModel(): this(App.Services.GetRequiredService<ICredentialsProxy>(), App.Services.GetRequiredService<ISettingsProxy>()) { }
public SetCredentialsViewModel(ICredentialsProxy credentials, ISettingsProxy settings)
{
_credentials = credentials;
_settings = settings;
}
public async Task CreateDatabase(FileInfo fileInfo)
{
await Mediator.Send(new CreateDatabaseCommand
{
FilePath = fileInfo.Path,
KeyFilePath = HasKeyFile ? KeyFilePath : null,
Password = HasPassword ? Password : null,
Name = "New Database",
CreateSampleData = _settings.GetSetting<bool>(Constants.Settings.Sample)
});
}
}
}