Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,41 +187,39 @@ private async void EnableEncryptionAction()
settings.NegativeButtonText = Strings.Cancel;
settings.DefaultButtonFocus = MessageDialogResult.Affirmative;

if (await _dialogCoordinator.ShowMessageAsync(this, Strings.Disclaimer,
Strings.ProfileEncryptionDisclaimer,
MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative)
if (await _dialogCoordinator.ShowMessageAsync(this, Strings.Disclaimer, Strings.ProfileEncryptionDisclaimer, MessageDialogStyle.AffirmativeAndNegative, settings) != MessageDialogResult.Affirmative)
return;

var customDialog = new CustomDialog
{
var customDialog = new CustomDialog
{
Title = Strings.SetMasterPassword
};
Title = Strings.SetMasterPassword
};

var credentialsSetPasswordViewModel = new CredentialsSetPasswordViewModel(async instance =>
{
await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
var credentialsSetPasswordViewModel = new CredentialsSetPasswordViewModel(async instance =>
{
await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);

try
{
ProfileManager.EnableEncryption(SelectedProfileFile, instance.Password);
}
catch (Exception ex)
{
var metroDialogSettings = AppearanceManager.MetroDialog;
metroDialogSettings.AffirmativeButtonText = Strings.OK;

await _dialogCoordinator.ShowMessageAsync(this, Strings.EncryptionError,
$"{Strings.EncryptionErrorMessage}\n\n{ex.Message}",
MessageDialogStyle.Affirmative, metroDialogSettings);
}
}, async _ => { await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); });

customDialog.Content = new CredentialsSetPasswordDialog
try
{
DataContext = credentialsSetPasswordViewModel
};
ProfileManager.EnableEncryption(SelectedProfileFile, instance.Password);
}
catch (Exception ex)
{
var metroDialogSettings = AppearanceManager.MetroDialog;
metroDialogSettings.AffirmativeButtonText = Strings.OK;

await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
}
await _dialogCoordinator.ShowMessageAsync(this, Strings.EncryptionError,
$"{Strings.EncryptionErrorMessage}\n\n{ex.Message}",
MessageDialogStyle.Affirmative, metroDialogSettings);
}
}, async _ => { await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); });

customDialog.Content = new CredentialsSetPasswordDialog
{
DataContext = credentialsSetPasswordViewModel
};

await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
}

public ICommand ChangeMasterPasswordCommand => new RelayCommand(_ => ChangeMasterPasswordAction());
Expand Down