Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
                    }
                }
            }
            ;
        }
    }
Ejemplo n.º 11
0
 public static bool GetIsEnabled(PasswordBox passwordBox)
 {
     return((bool)passwordBox.GetValue(IsEnabledProperty));
 }
Ejemplo n.º 12
0
 private static PasswordBoxHelper GetHelperInstance(PasswordBox passwordBox)
 {
     return((PasswordBoxHelper)passwordBox.GetValue(HelperInstanceProperty));
 }
Ejemplo n.º 13
0
 public static bool GetIsPasswordBindingEnabled(PasswordBox obj)
 {
     return((bool)obj.GetValue(IsPasswordBindingEnabledProperty));
 }
Ejemplo n.º 14
0
 public static bool GetAttached(PasswordBox passwordBox)
 {
     return((bool)passwordBox.GetValue(AttachedProperty));
 }
Ejemplo n.º 15
0
 public static bool GetIsEnabled(PasswordBox dp)
 {
     return((bool)dp.GetValue(IsEnabled));
 }
Ejemplo n.º 16
0
 public static bool GetExtend(PasswordBox i) => (bool)i.GetValue(ExtendProperty);
Ejemplo n.º 17
0
 private static bool GetUpdatingPassword(PasswordBox dp)
 {
     return((bool)dp.GetValue(UpdatingPassword));
 }
 public static int GetHasText(PasswordBox obj)
 {
     return((int)obj.GetValue(HasTextProperty));
 }
Ejemplo n.º 19
0
 public static string GetBindPassword(PasswordBox dp)
 {
     return((string)dp.GetValue(BindPassword));
 }
Ejemplo n.º 20
0
 public static bool GetMonitorPassword(PasswordBox element)
 {
     return((bool)element.GetValue(MonitorPasswordProperty));
 }
Ejemplo n.º 21
0
 /// <summary>Возвращает текстовое значение пароля.</summary>
 /// <param name="passwordBox">PasswordBox к которому присоединено свойство.</param>
 /// <returns>string с паролем.</returns>
 public static string GetText(PasswordBox passwordBox)
 {
     return((string)passwordBox.GetValue(TextProperty));
 }
Ejemplo n.º 22
0
 public static bool GetHasText(PasswordBox element)
 {
     return((bool)element.GetValue(HasTextProperty));
 }
Ejemplo n.º 23
0
 public static string GetPassword(PasswordBox passwordBox)
 {
     return((string)passwordBox.GetValue(PasswordProperty));
 }
Ejemplo n.º 24
0
 public static SecureString GetSecurePassword(PasswordBox element)
 {
     return(element.GetValue(SecurePasswordBindingProperty) as SecureString);
 }
Ejemplo n.º 25
0
 public static SecureString GetPassword(PasswordBox obj)
 {
     return((SecureString)obj.GetValue(PasswordProperty));
 }
Ejemplo n.º 26
0
 public static bool GetDynamicPasswordBox(PasswordBox textBox)
 {
     return((bool)textBox.GetValue(DynamicPasswordBoxProperty));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 28
0
 public static object GetCapsLockIcon(PasswordBox element)
 {
     return(element.GetValue(CapsLockIconProperty));
 }
Ejemplo n.º 29
0
 public static uint GetPasswordLength(PasswordBox element)
 {
     return((uint)element.GetValue(PasswordLengthProperty));
 }
Ejemplo n.º 30
0
 public static object CapsLockWarningToolTipText(PasswordBox element)
 {
     return(element.GetValue(CapsLockWarningToolTipProperty));
 }