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); } }
/// <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; } }
/// <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); } }
/// <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); }
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); } }
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(); } }
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); } }
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); } } } ; } }
public static bool GetIsEnabled(PasswordBox passwordBox) { return((bool)passwordBox.GetValue(IsEnabledProperty)); }
private static PasswordBoxHelper GetHelperInstance(PasswordBox passwordBox) { return((PasswordBoxHelper)passwordBox.GetValue(HelperInstanceProperty)); }
public static bool GetIsPasswordBindingEnabled(PasswordBox obj) { return((bool)obj.GetValue(IsPasswordBindingEnabledProperty)); }
public static bool GetAttached(PasswordBox passwordBox) { return((bool)passwordBox.GetValue(AttachedProperty)); }
public static bool GetIsEnabled(PasswordBox dp) { return((bool)dp.GetValue(IsEnabled)); }
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)); }
public static bool GetMonitorPassword(PasswordBox element) { return((bool)element.GetValue(MonitorPasswordProperty)); }
/// <summary>Возвращает текстовое значение пароля.</summary> /// <param name="passwordBox">PasswordBox к которому присоединено свойство.</param> /// <returns>string с паролем.</returns> public static string GetText(PasswordBox passwordBox) { return((string)passwordBox.GetValue(TextProperty)); }
public static bool GetHasText(PasswordBox element) { return((bool)element.GetValue(HasTextProperty)); }
public static string GetPassword(PasswordBox passwordBox) { return((string)passwordBox.GetValue(PasswordProperty)); }
public static SecureString GetSecurePassword(PasswordBox element) { return(element.GetValue(SecurePasswordBindingProperty) as SecureString); }
public static SecureString GetPassword(PasswordBox obj) { return((SecureString)obj.GetValue(PasswordProperty)); }
public static bool GetDynamicPasswordBox(PasswordBox textBox) { return((bool)textBox.GetValue(DynamicPasswordBoxProperty)); }
/// <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)); }
public static uint GetPasswordLength(PasswordBox element) { return((uint)element.GetValue(PasswordLengthProperty)); }
public static object CapsLockWarningToolTipText(PasswordBox element) { return(element.GetValue(CapsLockWarningToolTipProperty)); }