Update credentials better looking

This commit is contained in:
Geoffroy BONNEVILLE
2020-04-30 15:32:42 +02:00
parent d2814c6c67
commit 1b981b00d5
8 changed files with 145 additions and 45 deletions

View File

@@ -2,6 +2,6 @@
{
public class SaveErrorMessage
{
public string Message { get; set; }
}
}

View File

@@ -19,6 +19,7 @@ namespace ModernKeePass.ViewModels
set
{
Set(() => HasPassword, ref _hasPassword, value);
RaisePropertyChanged(nameof(IsPasswordValid));
RaisePropertyChanged(nameof(IsValid));
GenerateCredentialsCommand.RaiseCanExecuteChanged();
}
@@ -30,23 +31,19 @@ namespace ModernKeePass.ViewModels
set
{
Set(() => HasKeyFile, ref _hasKeyFile, value);
RaisePropertyChanged(nameof(IsKeyFileValid));
RaisePropertyChanged(nameof(IsValid));
GenerateCredentialsCommand.RaiseCanExecuteChanged();
}
}
public string Status
{
get { return _status; }
set { Set(() => Status, ref _status, value); }
}
public string Password
{
get { return _password; }
set
{
_password = value;
RaisePropertyChanged(nameof(IsPasswordValid));
RaisePropertyChanged(nameof(IsValid));
RaisePropertyChanged(nameof(PasswordComplexityIndicator));
GenerateCredentialsCommand.RaiseCanExecuteChanged();
@@ -58,6 +55,7 @@ namespace ModernKeePass.ViewModels
set
{
_confirmPassword = value;
RaisePropertyChanged(nameof(IsPasswordValid));
RaisePropertyChanged(nameof(IsValid));
GenerateCredentialsCommand.RaiseCanExecuteChanged();
}
@@ -69,6 +67,7 @@ namespace ModernKeePass.ViewModels
set
{
_keyFilePath = value;
RaisePropertyChanged(nameof(IsKeyFileValid));
RaisePropertyChanged(nameof(IsValid));
GenerateCredentialsCommand.RaiseCanExecuteChanged();
}
@@ -79,27 +78,21 @@ namespace ModernKeePass.ViewModels
get { return _keyFileText; }
set { Set(() => KeyFileText, ref _keyFileText, value); }
}
public string OpenButtonLabel
{
get { return _openButtonLabel; }
set { Set(() => OpenButtonLabel, ref _openButtonLabel, value); }
}
public double PasswordComplexityIndicator => _credentials.EstimatePasswordComplexity(Password);
public bool IsValid => HasPassword && Password == ConfirmPassword || HasKeyFile && !string.IsNullOrEmpty(KeyFilePath);
public bool IsPasswordValid => HasPassword && Password == ConfirmPassword || !HasPassword;
public bool IsKeyFileValid => HasKeyFile && !string.IsNullOrEmpty(KeyFilePath) || !HasKeyFile;
public bool IsValid => (IsPasswordValid || IsKeyFileValid) && (HasPassword || HasKeyFile);
public RelayCommand GenerateCredentialsCommand{ get; }
private bool _hasPassword;
private bool _hasKeyFile;
private string _password = string.Empty;
private string _confirmPassword;
private string _status;
private string _confirmPassword = string.Empty;
private string _keyFilePath;
private string _keyFileText;
private string _openButtonLabel;
public SetCredentialsVm(IMediator mediator, ICredentialsProxy credentials, IResourceProxy resource)
{