Пример #1
0
		public static SecureString AskForPassword(string label, Window owner)
		{
			SecureString secureString = null;
			var passwordDialog = new PasswordDialog(label) { Owner = owner };
			if (passwordDialog.ShowDialog() == true)
			{
				secureString = new SecureString();
				foreach (var character in passwordDialog.Password)
				{
					secureString.AppendChar(character);
				}
			}

			passwordDialog.TextPassword.Password = String.Empty;

			return secureString;
		}
Пример #2
0
        private bool TryOpenPdf()
        {
            if (!HasPdfHeader())
            {
                return(false);
            }

            String password = null;

            do
            {
                try
                {
                    PdfViewer.Open(new MemorySource(_largeBinaryValue.Value), password);
                    TabPdf.Visibility = Visibility.Visible;
                    TabPdf.IsSelected = true;
                    return(true);
                }
                catch (MissingOrInvalidPdfPasswordException)
                {
                    if (password != null)
                    {
                        Messages.ShowError("Invalid password");
                    }

                    var securePassword = PasswordDialog.AskForPassword("PDF password: ", this);
                    if (securePassword == null)
                    {
                        return(false);
                    }

                    password = securePassword.ToString();
                }
                catch
                {
                    break;
                }
            }while (true);

            return(false);
        }
Пример #3
0
        public static SecureString AskForPassword(string label, Window owner)
        {
            SecureString secureString   = null;
            var          passwordDialog = new PasswordDialog(label)
            {
                Owner = owner
            };

            if (passwordDialog.ShowDialog() == true)
            {
                secureString = new SecureString();
                foreach (var character in passwordDialog.Password)
                {
                    secureString.AppendChar(character);
                }
            }

            passwordDialog.TextPassword.Password = String.Empty;

            return(secureString);
        }