public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///HomePage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); pageRoot = (_8Tracks.Common.LayoutAwarePage) this.FindName("pageRoot"); groupedItemsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource) this.FindName("groupedItemsViewSource"); passwordPrompt = (Windows.UI.Xaml.Controls.Grid) this.FindName("passwordPrompt"); itemGridView = (Windows.UI.Xaml.Controls.GridView) this.FindName("itemGridView"); itemListView = (Windows.UI.Xaml.Controls.ListView) this.FindName("itemListView"); backButton = (Windows.UI.Xaml.Controls.Button) this.FindName("backButton"); pageTitle = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("pageTitle"); loginText = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("loginText"); loginBox = (Windows.UI.Xaml.Controls.TextBox) this.FindName("loginBox"); passwordText = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("passwordText"); passwordBox = (Windows.UI.Xaml.Controls.PasswordBox) this.FindName("passwordBox"); doneButton = (Windows.UI.Xaml.Controls.Button) this.FindName("doneButton"); ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup) this.FindName("ApplicationViewStates"); FullScreenLandscape = (Windows.UI.Xaml.VisualState) this.FindName("FullScreenLandscape"); Filled = (Windows.UI.Xaml.VisualState) this.FindName("Filled"); FullScreenPortrait = (Windows.UI.Xaml.VisualState) this.FindName("FullScreenPortrait"); Snapped = (Windows.UI.Xaml.VisualState) this.FindName("Snapped"); }
/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); if(Element == null ) { return; } var view = (ExtendedEntry)Element; //Because Xamarin EntryRenderer switches the type of control we need to find the right one if (view.IsPassword) { _thisPasswordBox = (PasswordBox) (Control.Content as Windows.UI.Xaml.Controls.Grid).Children.FirstOrDefault(c => c is PasswordBox); } else { _thisPhoneTextBox = (TextBox) (Control.Content as Windows.UI.Xaml.Controls.Grid).Children.FirstOrDefault(c => c is TextBox); } SetFont(view); SetTextAlignment(view); SetBorder(view); SetPlaceholderTextColor(view); SetMaxLength(view); SetIsPasswordRevealButtonEnabled(view); }
public void InitializeComponent() { if (_contentLoaded) return; _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///HomePage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); pageRoot = (_8Tracks.Common.LayoutAwarePage)this.FindName("pageRoot"); groupedItemsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("groupedItemsViewSource"); passwordPrompt = (Windows.UI.Xaml.Controls.Grid)this.FindName("passwordPrompt"); itemGridView = (Windows.UI.Xaml.Controls.GridView)this.FindName("itemGridView"); itemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView"); backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton"); pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle"); loginText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("loginText"); loginBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("loginBox"); passwordText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("passwordText"); passwordBox = (Windows.UI.Xaml.Controls.PasswordBox)this.FindName("passwordBox"); doneButton = (Windows.UI.Xaml.Controls.Button)this.FindName("doneButton"); ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ApplicationViewStates"); FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape"); Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled"); FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait"); Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped"); }
/// <summary> /// Simple method to add a new TextBlock into the visual tree of the PasswordBox which will present the watermark. /// </summary> /// <param name="pbox">The target PasswordBox.</param> /// <param name="text">The watermark text.</param> private static void AddWatermarkElement(PasswordBox pbox, string text) { var watermarkTextBlock = pbox.FindVisualChildByName<TextBlock>(pbox.Name+pbox.Name+WatermarkId); if (watermarkTextBlock == null) { var fe = pbox.FindVisualChildByName<ScrollViewer>("ContentElement"); if (fe != null) { var panelOwner = fe.FindVisualParent<Panel>(); if (panelOwner != null) { // Add the TextBlock var textBlock = new TextBlock { Name = pbox.Name + WatermarkId, Text = text, TextAlignment = TextAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(3, 0, 0, 0), Foreground = new SolidColorBrush(Colors.Gray) }; int index = panelOwner.Children.IndexOf(fe); panelOwner.Children.Insert(index + 1, textBlock); } } } }
private void PersistentObjectAttributePassword_Loaded(object sender, RoutedEventArgs e) { passwordBox = (PasswordBox)GetTemplateChild("PasswordBox"); if (passwordBox != null) { PersistentObjectAttributeControlBase.SetHookDatavalidationStates(passwordBox, true); passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
private UWPControls.StackPanel CreateInputStackPanel() { var inputStackPanel = new UWPControls.StackPanel(); UWPControls.Button getTokenButton = new UWPControls.Button(); getTokenButton.Content = "Lấy Facebook Token"; getTokenButton.Width = 300; getTokenButton.HorizontalAlignment = UWPXaml.HorizontalAlignment.Center; getTokenButton.Margin = new UWPXaml.Thickness(10); getTokenButton.SetBinding(UWPControls.Button.CommandProperty, new UWPXaml.Data.Binding() { Source = _viewModel, Path = new UWPXaml.PropertyPath("GetTokenCommand") }); UWPControls.PasswordBox passwordBox = new UWPControls.PasswordBox(); passwordBox.PlaceholderText = "Nhập password"; passwordBox.Width = 300; passwordBox.Margin = new UWPXaml.Thickness(10); passwordBox.PasswordChanged += (o, args) => { _viewModel.UserPassword = passwordBox.Password; }; //Thêm tooltip cho password TextBox UWPControls.ToolTip passwordToolTip = new UWPControls.ToolTip(); passwordToolTip.Content = "Để giảm thiểu khả năng checkpoint và tăng độ bảo mật, các bạn nên dùng Mật khẩu ứng dụng. Để lấy Mật khẩu ứng dụng: Cài đặt > Bảo mật và đăng nhập > Xác thực 2 yếu tố > Mật khẩu ứng dụng"; UWPControls.ToolTipService.SetToolTip(passwordBox, passwordToolTip); UWPControls.TextBox emailTextBox = new UWPControls.TextBox(); emailTextBox.PlaceholderText = "Nhập email"; emailTextBox.IsSpellCheckEnabled = false; emailTextBox.Width = 300; emailTextBox.Margin = new UWPXaml.Thickness(10); //https://github.com/Microsoft/XamlIslandBlogPostSample/blob/master/WpfApp1/BindingPage.xaml.cs emailTextBox.SetBinding(UWPControls.TextBox.TextProperty, new UWPXaml.Data.Binding() { Source = _viewModel, Path = new UWPXaml.PropertyPath("UserEmail"), UpdateSourceTrigger = UWPXaml.Data.UpdateSourceTrigger.PropertyChanged, Mode = UWPXaml.Data.BindingMode.TwoWay }); inputStackPanel.Children.Add(emailTextBox); inputStackPanel.Children.Add(passwordBox); inputStackPanel.Children.Add(getTokenButton); return(inputStackPanel); }
public void InitializeComponent() { if (_contentLoaded) return; _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///BlankPage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); LoginGridAppear = (Windows.UI.Xaml.Media.Animation.Storyboard)this.FindName("LoginGridAppear"); LoginGridDisappear = (Windows.UI.Xaml.Media.Animation.Storyboard)this.FindName("LoginGridDisappear"); InfoAppear = (Windows.UI.Xaml.Media.Animation.Storyboard)this.FindName("InfoAppear"); InfoDisappear = (Windows.UI.Xaml.Media.Animation.Storyboard)this.FindName("InfoDisappear"); MainPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("MainPanel"); LoginGrid = (Windows.UI.Xaml.Controls.Grid)this.FindName("LoginGrid"); InfoGrid = (Windows.UI.Xaml.Controls.Grid)this.FindName("InfoGrid"); TitleInfoTbx = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("TitleInfoTbx"); SubtitleInfoTbx = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("SubtitleInfoTbx"); SummaryInfoTbx = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("SummaryInfoTbx"); LoginProgbar = (Windows.UI.Xaml.Controls.ProgressBar)this.FindName("LoginProgbar"); UsernameTBx = (Windows.UI.Xaml.Controls.TextBox)this.FindName("UsernameTBx"); PwBx = (Windows.UI.Xaml.Controls.PasswordBox)this.FindName("PwBx"); LoginBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("LoginBtn"); SignUpBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("SignUpBtn"); AlbumArtHolder = (Windows.UI.Xaml.Controls.Image)this.FindName("AlbumArtHolder"); SongTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("SongTitle"); Artist = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("Artist"); LoveBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("LoveBtn"); BanBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("BanBtn"); Collection = (Windows.UI.Xaml.Controls.Button)this.FindName("Collection"); RecoArtistsButton = (Windows.UI.Xaml.Controls.Button)this.FindName("RecoArtistsButton"); RecoTracksButton = (Windows.UI.Xaml.Controls.Button)this.FindName("RecoTracksButton"); TrendsButton = (Windows.UI.Xaml.Controls.Button)this.FindName("TrendsButton"); TweetButton = (Windows.UI.Xaml.Controls.Button)this.FindName("TweetButton"); MapButton = (Windows.UI.Xaml.Controls.Button)this.FindName("MapButton"); MuConnectButton = (Windows.UI.Xaml.Controls.Button)this.FindName("MuConnectButton"); InfoBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("InfoBtn"); }
/// <summary> /// Detaches this instance. /// </summary> public void Detach() { if (_associatedObject == null) return; _associatedObject.KeyUp -= AssociatedObjectOnGotFocus; _associatedObject = null; }
private void Attach(PasswordBox associatedObject) { Detach(); _associatedObject = associatedObject; _associatedObject.GotFocus += AssociatedObjectOnGotFocus; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordAutoSelectOnFocusHandler"/> class. /// </summary> /// <param name="associatedObject">The associated object.</param> public PasswordAutoSelectOnFocusHandler(PasswordBox associatedObject) { Attach(associatedObject); }
private void Attach(PasswordBox associatedObject) { Detach(); _associatedObject = associatedObject; _associatedObject.KeyUp += AssociatedObjectOnKeyUp; }
private void UnloadControl(InputType type) { if (type == InputType.text) { _udfTB1.KeyUp -= ittext_KeyUp; } else if (type == InputType.password) { _udfPB1.PasswordChanged -= itpassword_PasswordChanged; } else if (type == InputType.checkbox) { } else if (type == InputType.radio) { } else if (type == InputType.combobox) { if (_ccInput != null) { var sp = (Grid)_ccInput.Content; var cb = (ComboBox)sp.Children[1]; cb.SelectionChanged -= itcombobox_SelectionChanged; Value2 = null; //if (cb.Items != null && cb.Items.Count > 0) cb.Items.Clear(); //if (cb.ItemsSource != null) cb.ItemsSource = null; } } if (_udfTS1 != null) { _udfTS1.Toggled -= ittoggleswitch_Toggled; } if (_udfProgBr1 != null) { _udfProgBr1.ValueChanged -= itProgBr_ValueChanged; } if (_udfSl1 != null) { _udfSl1.ValueChanged -= itSl_ValueChanged; } if (_udfRB1 != null) { _udfRB1.Checked -= itradio_Changed; _udfRB1.Unchecked -= itradio_Changed; } if (_udfChkB1 != null) { _udfChkB1.Checked -= itcheckbox_Changed; _udfChkB1.Unchecked -= itcheckbox_Changed; } if (_udfTBut1 != null) { _udfTBut1.Checked -= ittogglebutton_changed; _udfTBut1.Unchecked -= ittogglebutton_changed; } if (_udfProgRn1 != null) { _udfProgRn1.IsActive = false; } if (_udfg1 != null) { _udfg1.Children.Clear(); _udfg1 = null; } if (dtInvalidate != null) { dtInvalidate.Stop(); dtInvalidate.Tick += DtInvalidate_Tick; } _sbHideBgLayer?.Stop(); _sbHideBgLayer = null; _sbShowBgLayer?.Stop(); _sbShowBgLayer = null; _udfProgBr1 = null; _udfPB1 = null; _udfTB1 = null; _udfTBL1 = null; _udfCB1 = null; _udfChkB1 = null; _udfRB1 = null; _udfTS1 = null; _udfProgRn1 = null; _udfTBut1 = null; dtInvalidate = null; if (_ccInput != null && _ccInput.Content != null) _ccInput.Content = null; if (_ccInput != null) _ccInput = null; _grdContainer = null; if (_grdRoot != null) { _grdRoot.DataContext = null; _grdRoot = null; } _model = null; hasInitialized = false; }
public void PasswordChanged(PasswordBox passwordBox) { Configuration.SubsonicServiceConfiguration.Password = passwordBox.Password; NotifyOfPropertyChange(() => CanApplyChanges); }
private Grid CreateLogin() { var content = Window.Current.Content as FrameworkElement; if (content == null) { // The dialog is being shown before content has been created for the window Window.Current.Activated += OnWindowActivated; return null; } Style basicTextStyle = Application.Current.Resources["BaseTextBlockStyle"] as Style; Style subHeaderTextStyle = Application.Current.Resources["SubheaderTextBlockStyle"] as Style; double width = Window.Current.Bounds.Width; double height = Window.Current.Bounds.Height; var rootPanel = new Grid { Width = width, Height = height }; var overlay = new Grid { Background = new SolidColorBrush(Colors.Black), Opacity = 0.2D }; rootPanel.Children.Add(overlay); var dialog = new Grid { VerticalAlignment = VerticalAlignment.Center, RequestedTheme = ElementTheme.Light}; dialog.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); dialog.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); dialog.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); dialog.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(410, GridUnitType.Star) }); dialog.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); dialog.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(500, GridUnitType.Star) }); rootPanel.Children.Add(dialog); var titleBorder = new Border { Background = HeaderBrush, Height = 80D }; Grid.SetColumnSpan(titleBorder, 3); dialog.Children.Add(titleBorder); _titleTextBlock = new TextBlock(); _titleTextBlock.Text = Title; _titleTextBlock.Style = subHeaderTextStyle; _titleTextBlock.Margin = new Thickness(0, 0, 0, 20); _titleTextBlock.VerticalAlignment = VerticalAlignment.Bottom; Grid.SetColumn(_titleTextBlock, 1); dialog.Children.Add(_titleTextBlock); var infoBorder = new Border { Background = new SolidColorBrush(Colors.White) }; Grid.SetRow(infoBorder, 1); Grid.SetColumnSpan(infoBorder, 3); Grid.SetRowSpan(infoBorder, 2); dialog.Children.Add(infoBorder); var grid = new Grid { MinHeight = 220 }; Grid.SetRow(grid, 1); Grid.SetColumn(grid, 1); dialog.Children.Add(grid); StackPanel informationPanel = new StackPanel(); informationPanel.Margin = new Thickness(0, 20, 0, 30); informationPanel.Width = 456D; Grid.SetColumn(informationPanel, 1); Grid.SetRow(informationPanel, 1); var descriptionTextBlock = new TextBlock(); descriptionTextBlock.Text = LoginMessage; descriptionTextBlock.Style = basicTextStyle; descriptionTextBlock.Width = 456D; informationPanel.Children.Add(descriptionTextBlock); _userNameTextBlock = new TextBlock(); _userNameTextBlock.Text = UserNameTitle; _userNameTextBlock.Style = basicTextStyle; _userNameTextBlock.Margin = new Thickness(0, 20, 0, 4); informationPanel.Children.Add(_userNameTextBlock); _userTextBox = new TextBox(); _userTextBox.BorderBrush = new SolidColorBrush(Colors.Black); _userTextBox.BorderThickness = new Thickness(1); informationPanel.Children.Add(_userTextBox); TextBlock passwordTextBlock = new TextBlock(); passwordTextBlock.Text = "Pasword"; passwordTextBlock.Style = basicTextStyle; passwordTextBlock.FontSize = 16D; passwordTextBlock.Margin = new Thickness(0, 16, 0, 0); informationPanel.Children.Add(passwordTextBlock); _passwordTextBox = new PasswordBox(); _passwordTextBox.BorderBrush = new SolidColorBrush(Colors.Black); _passwordTextBox.BorderThickness = new Thickness(1); _passwordTextBox.KeyUp += PasswordTextBoxOnKeyUp; informationPanel.Children.Add(_passwordTextBox); grid.Children.Add(informationPanel); Button connectButton = new Button(); connectButton.BorderThickness = new Thickness(); connectButton.Padding = new Thickness(10, 5, 10, 5); // TODO: Fill with user input connectButton.Content = "Connect"; connectButton.HorizontalAlignment = HorizontalAlignment.Right; connectButton.Background = HeaderBrush; connectButton.Margin = new Thickness(0, 0, 0, 20); connectButton.MinWidth = 90D; connectButton.Click += (okSender, okArgs) => OnCompleted(); Grid.SetColumn(connectButton, 1); Grid.SetRow(connectButton, 2); dialog.Children.Add(connectButton); Button cancelButton = new Button(); cancelButton.BorderThickness = new Thickness(); cancelButton.Padding = new Thickness(10, 5, 10, 5); cancelButton.Content = "Cancel"; cancelButton.HorizontalAlignment = HorizontalAlignment.Left; cancelButton.Background = new SolidColorBrush(Color.FromArgb(255, 165, 165, 165)); cancelButton.Margin = new Thickness(20, 0, 0, 20); cancelButton.MinWidth = 90D; cancelButton.Click += (cancelSender, cancelArgs) => OnCanceled(); Grid.SetColumn(cancelButton, 2); Grid.SetRow(cancelButton, 2); dialog.Children.Add(cancelButton); return rootPanel; }
private void BuildControl(InputType type, string label, string placeholderText, double labelFontSize, double labelTranslateY, string groupName, ContentControl ccInput) { FrameworkElement fe = null; if (type == InputType.text) { var tb = new TextBox(); tb.PlaceholderText = placeholderText; tb.Style = _GeneralTextBoxStyle; tb.KeyUp += ittext_KeyUp; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment= VerticalAlignment.Top}; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(tb); fe = gd; } else if (type == InputType.password) { var tb = new PasswordBox(); tb.PlaceholderText = placeholderText; tb.Style = _GeneralPasswordBoxStyle; tb.PasswordChanged += itpassword_PasswordChanged; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(tb); fe = gd; } else if (type == InputType.checkbox) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); var cb = new CheckBox(); cb.Checked += itcheckbox_Checked; cb.Content = lb; cb.Style = _GeneralCheckBoxStyle; sp.Children.Add(cb); fe = sp; } else if (type == InputType.radio) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); var rb = new RadioButton(); rb.GroupName = groupName; rb.Checked += itradio_Checked; rb.Content = lb; rb.Style = _GeneralRadioButtonStyle; sp.Children.Add(rb); fe = sp; } fe.HorizontalAlignment = HorizontalAlignment.Stretch; fe.VerticalAlignment = VerticalAlignment.Stretch; ccInput.Content = fe; }
protected virtual void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config) { var txt = new PasswordBox { PlaceholderText = config.Placeholder ?? String.Empty, Password = config.Text ?? String.Empty }; if (config.MaxLength != null) txt.MaxLength = config.MaxLength.Value; stack.Children.Add(txt); dialog.PrimaryButtonCommand = new Command(() => { config.OnAction?.Invoke(new PromptResult(true, txt.Password)); dialog.Hide(); }); }
private void BuildControl(InputType type, string label, string placeholderText, double labelFontSize, double labelTranslateY, string groupName, ContentControl ccInput) { FrameworkElement fe = null; if (type == InputType.text) { _udfTB1 = new TextBox(); _udfTB1.PlaceholderText = placeholderText; _udfTB1.Style = _GeneralTextBoxStyle; _udfTB1.SetBinding(TextBox.DataContextProperty, new Binding() { Path= new PropertyPath("{x:Null}") }); _udfTB1.SetBinding(TextBox.TextProperty, new Binding() { Source = Value }); _udfTB1.KeyUp += ittext_KeyUp; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment= VerticalAlignment.Top}; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfTB1); fe = gd; } else if (type == InputType.password) { _udfPB1 = new PasswordBox(); _udfPB1.PlaceholderText = placeholderText; _udfPB1.Style = _GeneralPasswordBoxStyle; _udfPB1.PasswordChanged += itpassword_PasswordChanged; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfPB1); fe = gd; } else if (type == InputType.combobox) { _udfCB1 = new ComboBox(); _udfCB1.Style = _GeneralComboBoxStyle; _udfCB1.PlaceholderText = placeholderText; _udfCB1.SetBinding(ComboBox.ItemsSourceProperty, new Binding() { Source = Items }); _udfCB1.Width = this.Width; _udfCB1.SelectionChanged += itcombobox_SelectionChanged; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfCB1); fe = gd; } else if (type == InputType.checkbox) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); _udfChkB1 = new CheckBox(); _udfChkB1.Checked += itcheckbox_Changed; _udfChkB1.Unchecked += itcheckbox_Changed; _udfChkB1.Content = lb; _udfChkB1.Style = _GeneralCheckBoxStyle; sp.Children.Add(_udfChkB1); fe = sp; } else if (type == InputType.toggleButton) { _udfTBut1 = new ToggleButton(); _udfTBut1.Style = _GeneralToggleButtonStyle; _udfTBut1.Checked += ittogglebutton_changed; _udfTBut1.Unchecked += ittogglebutton_changed; _udfTBut1.FontSize = FontSize; _udfTBut1.Content = Content1; fe = _udfTBut1; } else if (type == InputType.toggleSwitch) { _udfTS1 = new ToggleSwitch(); _udfTS1.Style = _GeneralToggleSwitchStyle; _udfTS1.Toggled += ittoggleswitch_Toggled; _udfTS1.FontSize = FontSize; _udfTS1.OnContent = Content1; _udfTS1.OffContent = Content2; fe = _udfTS1; } else if (type == InputType.radio) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); _udfRB1 = new RadioButton(); _udfRB1.GroupName = groupName; _udfRB1.Checked += itradio_Changed; _udfRB1.Unchecked += itradio_Changed; _udfRB1.Content = lb; _udfRB1.Style = _GeneralRadioButtonStyle; sp.Children.Add(_udfRB1); fe = sp; } else if (type == InputType.progress) { _udfProgBr1 = new ProgressBar(); _udfProgBr1.Style = _GeneralProgressBarStyle; _udfProgBr1.ValueChanged += itProgBr_ValueChanged; _udfProgBr1.FontSize = FontSize; _udfProgBr1.DataContext = this; _udfProgBr1.SetBinding(ProgressBar.MaximumProperty, new Binding() { Path= new PropertyPath("Maximum1") }); _udfProgBr1.SetBinding(ProgressBar.MinimumProperty, new Binding() { Path = new PropertyPath("Minimum1") }); _udfProgBr1.SetBinding(ProgressBar.ValueProperty, new Binding() { Path = new PropertyPath("Value1") }); _udfProgBr1.SetBinding(ProgressBar.SmallChangeProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfProgBr1.SetBinding(ProgressBar.LargeChangeProperty, new Binding() { Path = new PropertyPath("LargeChange1") }); fe = _udfProgBr1; } else if (type == InputType.progressRing) { _udfProgRn1 = new ProgressRing(); _udfProgRn1.Style = _GeneralProgressRingStyle; //_udfProgRn1.val += itProgBr_ValueChanged; _udfProgRn1.FontSize = FontSize; _udfProgRn1.DataContext = this; _udfProgRn1.SetBinding(ProgressRing.IsActiveProperty, new Binding() { Path = new PropertyPath("IsActive") }); fe = _udfProgRn1; } else if (type == InputType.slider) { _udfSl1 = new Slider(); _udfSl1.Style = _GeneralSliderStyle; _udfSl1.ValueChanged += itSl_ValueChanged; _udfSl1.FontSize = FontSize; _udfSl1.DataContext = this; _udfSl1.SetBinding(Slider.MaximumProperty, new Binding() { Path = new PropertyPath("Maximum1") }); _udfSl1.SetBinding(Slider.MinimumProperty, new Binding() { Path = new PropertyPath("Minimum1") }); _udfSl1.SetBinding(Slider.ValueProperty, new Binding() { Path = new PropertyPath("Value1") }); _udfSl1.SetBinding(Slider.SmallChangeProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfSl1.SetBinding(Slider.StepFrequencyProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfSl1.SetBinding(Slider.LargeChangeProperty, new Binding() { Path = new PropertyPath("LargeChange1") }); fe = _udfSl1; } fe.HorizontalAlignment = HorizontalAlignment.Stretch; fe.VerticalAlignment = VerticalAlignment.Stretch; ccInput.Content = fe; }
private void loginButtonClick(object sender, Windows.UI.Xaml.RoutedEventArgs e) { bool found = false; int i = 0; loginNIUTB = (TextBox)FindName("niuLoginTB"); String NIU = loginNIUTB.Text; loginResult = (TextBlock)FindName("loginRes"); while (!found && i < userdb.Count) { Usuario useri = userdb.ElementAt(i); if (useri.NIU.ToString().Equals(NIU)) { found = true; loginPassTB = (PasswordBox)FindName("passLoginTB"); String password = loginPassTB.Password; if (useri.Password.Equals(password)) { loginResult.Text = "Autenticación correcta"; this.Frame.Navigate(typeof(DashBoardPage), "AllGroups"); } else { loginResult.Text = "Password erróneo"; } } else i++; if (!found) loginResult.Text = "NIU erróneo"; } }
private void regButton_Click(object sender, RoutedEventArgs e) { regPassTB1 = (PasswordBox)FindName("pass1RegTB"); regPassTB2 = (PasswordBox)FindName("pass2RegTB"); regNiuTB = (TextBox)FindName("regNIUTB"); registerRes = (TextBlock)FindName("regRes"); if (regPassTB1.Password == regPassTB2.Password) { bool found = false; int i = 0; while (!found && i < userdb.Count) { Usuario useri = userdb.ElementAt(i); if (useri.NIU.ToString().Equals(regNiuTB.Text)) { found = true; registerRes.Text = "NIU ya registrado"; } else i++; } if (!found) { regName = (TextBox)FindName("regNameTB"); regSurname = (TextBox)FindName("regSurnameTB"); Usuario newUser = new Usuario(); newUser.NIU = regNiuTB.Text; newUser.Nombre = regName.Text; newUser.Apellidos = regSurname.Text; newUser.Comentario = ""; newUser.Password = regPassTB1.Password; userdb.Add(newUser); registerRes.Text = "Registrado Correctamente"; } } else { registerRes.Text = "Passwords no coinciden"; } }
public PasswordBoxEvents(PasswordBox This) : base(This) { this.This = This; }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _layoutRoot = GetTemplateChild(LayoutRootPanelName) as Panel; _contentBorder = GetTemplateChild(ContentBorderName) as Border; _inputTextBox = GetTemplateChild(InputTextBoxName) as TextBox; _inputPasswordBox = GetTemplateChild(InputPasswordBoxName) as PasswordBox; _titleTextBlock = GetTemplateChild(TitleTextBlockName) as TextBlock; _textTextBlock = GetTemplateChild(TextTextBlockName) as TextBlock; _buttonsPanel = GetTemplateChild(ButtonsPanelName) as Panel; _virtualKeyboardSlideStoryboard = GetTemplateChild(VirtualKeyboardSlideStoryBoardName) as Storyboard; _virtualKeyboardSlideAnimation = GetTemplateChild(VirtualKeyboardAnimationName) as DoubleAnimation; _blackStripeTransform = this.GetTemplateChild(BlackStripeTransformName) as TranslateTransform; if (_layoutRoot != null) _layoutRoot.Tapped += OnLayoutRootTapped; if (_inputTextBox != null && _inputPasswordBox != null) { _inputTextBox.Text = InputText; _inputTextBox.TextChanged += OnInputTextBoxTextChanged; _inputTextBox.KeyUp += OnInputTextBoxKeyUp; _inputPasswordBox.Password = InputText; _inputPasswordBox.PasswordChanged += OnInputPasswordBoxTextChanged; _inputPasswordBox.KeyUp += OnInputTextBoxKeyUp; if (_usePasswordMode) { _inputTextBox.Visibility = Visibility.Collapsed; _inputTextBox = null; _inputPasswordBox.Visibility = Visibility.Visible; } else { _inputTextBox.Visibility = Visibility.Visible; _inputPasswordBox.Visibility = Visibility.Collapsed; _inputPasswordBox = null; } } if (_contentBorder != null) _contentBorder.Tapped += OnContentBorderTapped; }
/// <summary> /// Gets the watermark text /// </summary> /// <param name="pbox">The target PasswordBox.</param> /// <returns> /// The watermark text. /// </returns> public static string GetWatermark(PasswordBox pbox) { return (string)pbox.GetValue(WatermarkProperty); }
/// <summary>Handles the password box.</summary> /// <param name="input">The input.</param> /// <param name="bind">if set to <c>true</c> [bind].</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> private static bool HandlePasswordBox(PasswordBox input, bool bind) { var handled = false; if (input != null) { if (bind && HasBinding(input)) { input.PasswordChanged += PasswordBoxChanged; } else { input.PasswordChanged -= PasswordBoxChanged; } handled = true; } return handled; }
private void Attach(PasswordBox associatedObject) { Detach(); if (!IsSearchEnabled) { return; } _associatedObject = associatedObject; _associatedObject.GotFocus += AssociatedObjectOnGotFocus; _associatedObject.LostFocus += AssociatedObjectOnLostFocus; }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _layoutRoot = GetTemplateChild(LayoutRootPanelName) as Panel; _contentBorder = GetTemplateChild(ContentBorderName) as Border; _inputTextBox = GetTemplateChild(InputTextBoxName) as TextBox; _inputPasswordBox = GetTemplateChild(InputPasswordBoxName) as PasswordBox; _titleTextBlock = GetTemplateChild(TitleTextBlockName) as TextBlock; _textTextBlock = GetTemplateChild(TextTextBlockName) as TextBlock; _buttonsPanel = GetTemplateChild(ButtonsPanelName) as Panel; if (_layoutRoot != null) _layoutRoot.Tapped += OnLayoutRootTapped; if (_inputTextBox != null && _inputPasswordBox != null) { _inputTextBox.Text = InputText; _inputTextBox.TextChanged += OnInputTextBoxTextChanged; _inputTextBox.KeyUp += OnInputTextBoxKeyUp; _inputPasswordBox.Password = InputText; _inputPasswordBox.PasswordChanged += OnInputPasswordBoxTextChanged; _inputPasswordBox.KeyUp += OnInputTextBoxKeyUp; if (_usePasswordMode) { _inputTextBox.Visibility = Visibility.Collapsed; _inputTextBox = null; _inputPasswordBox.Visibility = Visibility.Visible; } else { _inputTextBox.Visibility = Visibility.Visible; _inputPasswordBox.Visibility = Visibility.Collapsed; _inputPasswordBox = null; } } if (_contentBorder != null) _contentBorder.Tapped += OnContentBorderTapped; }
/// <summary> /// Initializes a new instance of the <see cref="PasswordAutoTabOnMaxLengthHandler"/> class. /// </summary> /// <param name="associatedObject">The associated object.</param> public PasswordAutoTabOnMaxLengthHandler(PasswordBox associatedObject) { Attach(associatedObject); }
/// <summary> /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class. /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); _innerPasswordBox = (PasswordBox)GetTemplateChild(InnerPasswordBoxName); _innerPasswordBox.PasswordChanged += InnerPasswordBoxOnPasswordChanged; _innerPasswordBox.KeyUp += InnerPasswordBoxOnKeyUp; _innerPasswordBox.GotFocus += InnerPasswordBoxOnGotFocus; _innerPasswordBox.LostFocus += InnerPasswordBoxOnLostFocus; _innerPasswordBox.ContextMenuOpening += InnerPasswordBoxOnContextMenuOpening; _innerPasswordBox.SetBinding( PasswordBox.PasswordProperty, new Binding { Path = new PropertyPath("Password"), Mode = BindingMode.TwoWay, Source = this }); _innerPasswordBox.SetBinding( PasswordBox.PasswordCharProperty, new Binding { Path = new PropertyPath("PasswordChar"), Mode = BindingMode.TwoWay, Source = this }); _innerPasswordBox.SetBinding( PasswordBox.PasswordRevealModeProperty, new Binding { Path = new PropertyPath("PasswordRevealMode"), Mode = BindingMode.TwoWay, Source = this }); _innerPasswordBox.SetBinding( PasswordBox.MaxLengthProperty, new Binding { Path = new PropertyPath("MaxLength"), Mode = BindingMode.TwoWay, Source = this }); UpdateWatermarkVisualState(false, false); }
private void Logout_click(object sender, PointerRoutedEventArgs e) { ButtonsVisibility(Visibility.Collapsed); var dialog = new ContentDialog() { Title = "Log in:", RequestedTheme = ElementTheme.Dark, MaxWidth = ActualWidth }; var usrnName = new TextBox() { Name = "UsernameBox", PlaceholderText = "Username", TextWrapping = TextWrapping.Wrap }; var passwd = new PasswordBox { PlaceholderText = "Password:"******"PasswdBox" }; usrnName.TextChanged += delegate { dialog.IsPrimaryButtonEnabled = (passwd.Password != "" && usrnName.Text != "") ? true : false; }; passwd.PasswordChanged += delegate { dialog.IsPrimaryButtonEnabled = (passwd.Password != "" && usrnName.Text != "") ? true : false; }; var cb = new CheckBox { Name = "registercheck" }; var dockTop = new StackPanel { Orientation = Orientation.Horizontal, Children = { new TextBlock { Text = "I want to register \t" }, cb } }; var panel = new StackPanel { Children = { usrnName, passwd, dockTop } }; dialog.Content = panel; dialog.PrimaryButtonText = "Log"; dialog.IsPrimaryButtonEnabled = false; dialog.PrimaryButtonClick += async delegate { var namepath = cb.IsChecked.HasValue && cb.IsChecked.Value ? "RegisterUser" : "LoginUser"; try { var respondLoginInfo = (BackLogin) await SerwerFunction.Getfromserver<BackLogin>( namepath, "POST", new Login(usrnName.Text, passwd.Password)); if (respondLoginInfo == null) dialog.ShowAsync(); SerwerFunction.password = respondLoginInfo?.token; SerwerFunction.login = respondLoginInfo?.login; SerwerFunction.Uid = respondLoginInfo.uid; TitleBlock.Text = "COLLECTOR - welcome: " + respondLoginInfo.login; } catch { dialog.Title = "This name is already taken or password is wrong"; } }; dialog.SecondaryButtonText = "Cancel"; dialog.SecondaryButtonClick += delegate { Application.Current.Exit(); }; var result = dialog.ShowAsync(); }
/// <summary> /// Simple method to remove the TextBlock from the PasswordBox visual tree. /// </summary> /// <param name="pbox">The target PasswordBox.</param> private static void RemoveWatermarkElement(PasswordBox pbox) { var watermarkTextBlock = pbox.FindVisualChildByName<TextBlock>(pbox.Name + WatermarkId); if (watermarkTextBlock != null) { var panelOwner = watermarkTextBlock.FindVisualParent<Panel>(); if (panelOwner != null) { panelOwner.Children.Remove(watermarkTextBlock); } } }
void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config) { var txt = new PasswordBox { PlaceholderText = config.Placeholder, Password = config.Text ?? String.Empty }; stack.Children.Add(txt); dialog.PrimaryButtonCommand = new Command(() => { config.OnResult?.Invoke(new PromptResult { Ok = true, Text = txt.Password }); dialog.Hide(); }); }
/// <summary> /// Sets the watermark text. /// </summary> /// <param name="pbox">The target PasswordBox.</param> /// <param name="text">The watermark text to be set.</param> public static void SetWatermark(PasswordBox pbox, string text) { pbox.SetValue(WatermarkProperty, text); }
/// <summary> /// Initializes a new instance of the <see cref="PasswordDisableSearchPaneOnFocusHandler"/> class. /// </summary> /// <param name="associatedObject">The associated object.</param> public PasswordDisableSearchPaneOnFocusHandler(PasswordBox associatedObject) { Attach(associatedObject); }