예제 #1
0
        void AskSettings()
        {
            var  askForCredentials = new CredentialsDialog();
            bool?result            = askForCredentials.ShowDialog();

            if (result != null && result.Value)
            {
                _settings.IsEnabled = true;
                _settings.Username  = askForCredentials.Username.Text;
                _password           = askForCredentials.Password.SecurePassword;
                byte[] encryptedPassword = ProtectedData.Protect(
                    Encoding.Unicode.GetBytes(_password.ToInsecureString()),
                    Entropy,
                    DataProtectionScope.CurrentUser);
                _settings.Password = Convert.ToBase64String(encryptedPassword);
            }
            else
            {
                _settings.IsEnabled = false;
            }

            _config.Save();
        }
예제 #2
0
        void AskSettings()
        {
            var askForCredentials = new CredentialsDialog();
            bool? result = askForCredentials.ShowDialog();
            if ( result != null && result.Value )
            {
                _settings.IsEnabled = true;
                _settings.Username = askForCredentials.Username.Text;
                _password = askForCredentials.Password.SecurePassword;
                byte[] encryptedPassword = ProtectedData.Protect(
                    Encoding.Unicode.GetBytes( _password.ToInsecureString() ),
                    Entropy,
                    DataProtectionScope.CurrentUser );
                _settings.Password = Convert.ToBase64String( encryptedPassword );
            }
            else
            {
                _settings.IsEnabled = false;
            }

            _config.Save();
        }