示例#1
0
        private static void HandleBoundPasswordChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
        {
            PasswordBox passwordBox = dp as PasswordBox;

            if (passwordBox == null)
            {
                return;
            }

            // If we're being called because we set the value of the property we're bound to (from inside
            // HandlePasswordChanged, then do nothing - we already have the latest value).
            if ((bool)passwordBox.GetValue(SettingPasswordProperty))
            {
                return;
            }

            // If this is the initial set (see the comment on PasswordProperty), set ourselves up
            if (!(bool)passwordBox.GetValue(PasswordInitializedProperty))
            {
                passwordBox.SetValue(PasswordInitializedProperty, true);
                passwordBox.PasswordChanged += HandlePasswordChanged;
            }

            passwordBox.Password = e.NewValue as string;
        }
        /// <summary>Writes the password to EncryptedPasswordProperty, in order not to have its clear text in memory.</summary>
        private static void PasswordChanged(object Sender, RoutedEventArgs EventArguments)
        {
            byte[]      abPlain, abEncrypted;
            int         iPasswordLength;
            PasswordBox PwdBox = Sender as PasswordBox;

            RSACng RsaEncryptor = (RSACng)PwdBox.GetValue(PublicRsaEncryptorProperty);

            if (RsaEncryptor != null)
            {
                abPlain = Encoding.UTF8.GetBytes(PwdBox.Password);   // we could be using SecurePassword.ToString() here to the same effect

                iPasswordLength = PwdBox.Password.Length;
                if (iPasswordLength == 0)
                {
                    abEncrypted = null;
                }
                else
                {
                    abEncrypted = RsaEncryptor.Encrypt(abPlain, RSAEncryptionPadding.Pkcs1);
                }

                PwdBox.SetValue(PasswordLengthProperty, iPasswordLength);
                PwdBox.SetValue(EncryptedPasswordProperty, abEncrypted);
            }
        }
示例#3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="T:T:ReactNative.Views.TextInput.PlaceholderAdorner"/> class.
 /// </summary>
 /// <param name="adornedElement">
 ///   The element to bind the adorner to.
 /// </param>
 /// <param name="textControl"></param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   Raised when adornedElement is null.
 /// </exception>
 public PlaceholderAdorner(UIElement adornedElement, PasswordBox textControl)
     : this(adornedElement, (Control)textControl)
 {
     if (!(textControl.IsFocused && (bool)textControl.GetValue(HideOnFocusProperty)))
     {
         textControl.PasswordChanged += this.AdornedElement_ContentChanged;
     }
 }
示例#4
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="T:T:ReactNative.Views.TextInput.PlaceholderAdorner"/> class.
 /// </summary>
 /// <param name="adornedElement">
 ///   The element to bind the adorner to.
 /// </param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   Raised when adornedElement is null.
 /// </exception>
 public PlaceholderAdorner(PasswordBox adornedElement)
     : this((Control)adornedElement)
 {
     if (!(adornedElement.IsFocused && (bool)adornedElement.GetValue(HideOnFocusProperty)))
     {
         adornedElement.PasswordChanged += this.AdornedElement_ContentChanged;
     }
 }
        private static void OnListViewItemClick(object sender, RoutedEventArgs e)
        {
            PasswordBox passwordBox = sender as PasswordBox;

            if (passwordBox != null)
            {
                ICommand command  = (ICommand)passwordBox.GetValue(CommandProperty);
                var      password = passwordBox.Password;
                command.Execute(password);
            }
        }
示例#6
0
        /// <summary>Приватное свойство для получения объекта-слушателя.</summary>
        private static ListenerTextPasswordBox GetListenerText(PasswordBox passwordBox)
        {
            ListenerTextPasswordBox listener = (ListenerTextPasswordBox)passwordBox.GetValue(ListenerTextPropertyKey.DependencyProperty);

            // Если элемент не задан, то его создание и сохранение.
            if (listener == null)
            {
                passwordBox.SetValue(ListenerTextPropertyKey, listener = new ListenerTextPasswordBox(passwordBox));
            }

            return(listener);
        }
示例#7
0
        private static void OnPasswordChanged(object sender, RoutedEventArgs e)
        {
            PasswordBox passwordBox = sender as PasswordBox;

            if (passwordBox == null)
            {
                return;
            }

            OverlayTextAdorner adorner = (OverlayTextAdorner)passwordBox.GetValue(OverlayTextAdornerProperty);

            if (adorner != null)
            {
                adorner.OnTargetElementTextChanged(passwordBox.Password);
            }
        }
示例#8
0
        private static void OnGotFocus(object sender, RoutedEventArgs e)
        {
            TextBox textBox = FocusManager.GetFocusedElement() as TextBox;

            if (textBox != null && !(bool)textBox.GetValue(AttachedProperties.PreventAutoSelectTextProperty))
            {
                textBox.SelectAll();
            }
            else
            {
                PasswordBox passwordBox = FocusManager.GetFocusedElement() as PasswordBox;
                if (passwordBox == null || (bool)passwordBox.GetValue(AttachedProperties.PreventAutoSelectTextProperty))
                {
                    return;
                }
                passwordBox.SelectAll();
            }
        }
示例#9
0
        private static void PasswordChanged(object sender, RoutedEventArgs e)
        {
            PasswordBox passwordBox = sender as PasswordBox;

            SetIsUpdating(passwordBox, true);
            SetPassword(passwordBox, passwordBox.Password);
            SetIsUpdating(passwordBox, false);
            // noww we call.
            var command = passwordBox.GetValue(ItemChangedCommandProperty) as ICommand;

            if (command != null)
            {
                IDictionary <string, object> objectName = new Dictionary <string, object>();
                objectName["DataObject"]     = GetDataSource(passwordBox);
                objectName["DataSourcePath"] = GetDataSourcePath(passwordBox);
                objectName["ChangedValue"]   = passwordBox.Password;
                objectName["PreviousValue"]  = _lastPassBoxValue;
                _lastPassBoxValue            = passwordBox.Password;
                command.Execute(objectName);
            }
        }
示例#10
0
        private static void OnIsDirtyEnabledChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
        {
            PasswordBox pb = (PasswordBox)dependencyObject;

            if (pb != null)
            {
                pb.LostFocus += delegate
                {
                    if (pb.GetBindingExpression(PasswordBox.CacheModeProperty) != null)
                    {
                        //Validation.ClearInvalid(pb.GetBindingExpression(PasswordBox.CacheModeProperty));
                        pb.GetBindingExpression(PasswordBox.CacheModeProperty).UpdateTarget();
                    }

                    if (!(bool)pb.GetValue(ShowErrorTemplateProperty))
                    {
                        pb.SetValue(ShowErrorTemplateProperty, true);
                    }
                }
            }
            ;
        }
    }
示例#11
0
 public static bool GetIsEnabled(PasswordBox passwordBox)
 {
     return((bool)passwordBox.GetValue(IsEnabledProperty));
 }
示例#12
0
 private static PasswordBoxHelper GetHelperInstance(PasswordBox passwordBox)
 {
     return((PasswordBoxHelper)passwordBox.GetValue(HelperInstanceProperty));
 }
示例#13
0
 public static bool GetIsPasswordBindingEnabled(PasswordBox obj)
 {
     return((bool)obj.GetValue(IsPasswordBindingEnabledProperty));
 }
示例#14
0
 public static bool GetAttached(PasswordBox passwordBox)
 {
     return((bool)passwordBox.GetValue(AttachedProperty));
 }
 public static bool GetIsEnabled(PasswordBox dp)
 {
     return((bool)dp.GetValue(IsEnabled));
 }
示例#16
0
 public static bool GetExtend(PasswordBox i) => (bool)i.GetValue(ExtendProperty);
 private static bool GetUpdatingPassword(PasswordBox dp)
 {
     return((bool)dp.GetValue(UpdatingPassword));
 }
 public static int GetHasText(PasswordBox obj)
 {
     return((int)obj.GetValue(HasTextProperty));
 }
 public static string GetBindPassword(PasswordBox dp)
 {
     return((string)dp.GetValue(BindPassword));
 }
示例#20
0
 public static bool GetMonitorPassword(PasswordBox element)
 {
     return((bool)element.GetValue(MonitorPasswordProperty));
 }
示例#21
0
 /// <summary>Возвращает текстовое значение пароля.</summary>
 /// <param name="passwordBox">PasswordBox к которому присоединено свойство.</param>
 /// <returns>string с паролем.</returns>
 public static string GetText(PasswordBox passwordBox)
 {
     return((string)passwordBox.GetValue(TextProperty));
 }
示例#22
0
 public static bool GetHasText(PasswordBox element)
 {
     return((bool)element.GetValue(HasTextProperty));
 }
示例#23
0
 public static string GetPassword(PasswordBox passwordBox)
 {
     return((string)passwordBox.GetValue(PasswordProperty));
 }
示例#24
0
 public static SecureString GetSecurePassword(PasswordBox element)
 {
     return(element.GetValue(SecurePasswordBindingProperty) as SecureString);
 }
示例#25
0
 public static SecureString GetPassword(PasswordBox obj)
 {
     return((SecureString)obj.GetValue(PasswordProperty));
 }
示例#26
0
 public static bool GetDynamicPasswordBox(PasswordBox textBox)
 {
     return((bool)textBox.GetValue(DynamicPasswordBoxProperty));
 }
示例#27
0
 /// <summary>
 /// Gets a value that specifies whether the password is always, never, or
 /// optionally obscured.
 /// </summary>
 /// <param name="passwordBox">The element from which to read the property value.</param>
 /// <returns>
 /// A value of the enumeration that specifies whether the password is always, never,
 /// or optionally obscured. The default is **Peek**.
 /// </returns>
 public static PasswordRevealMode GetPasswordRevealMode(PasswordBox passwordBox)
 {
     return((PasswordRevealMode)passwordBox.GetValue(PasswordRevealModeProperty));
 }
 public static object GetCapsLockIcon(PasswordBox element)
 {
     return(element.GetValue(CapsLockIconProperty));
 }
示例#29
0
 public static uint GetPasswordLength(PasswordBox element)
 {
     return((uint)element.GetValue(PasswordLengthProperty));
 }
 public static object CapsLockWarningToolTipText(PasswordBox element)
 {
     return(element.GetValue(CapsLockWarningToolTipProperty));
 }