public PasswordBox() { textBoxView = new TextBoxView { IsPassword = true }; textBoxView.TextChanged += (sender, e) => this.Password = textBoxView.Text; }
public TextBox() { textBoxView = new TextBoxView(); textBoxView.HorizontalScrollBarVisibility = HorizontalScrollBarVisibility; textBoxView.VerticalScrollBarVisibility = VerticalScrollBarVisibility; textBoxView.SpellCheck = (bool)GetValue(SpellCheck.IsEnabledProperty); textBoxView.TextChanged += (sender, e) => this.Text = textBoxView.Text; textBoxView.CaretIndexChanged += (sender, e) => this.CaretIndex = textBoxView.CaretIndex; textBoxView.SelectionStartChanged += (sender, e) => this.SelectionStart = textBoxView.SelectionStart; textBoxView.SelectionLengthChanged += (sender, e) => this.SelectionLength = textBoxView.SelectionLength; }
// Token: 0x06005355 RID: 21333 RVA: 0x001728D0 File Offset: 0x00170AD0 private void SetRenderScopeToContentHost(TextBoxView renderScope) { this.ClearContentHost(); this._passwordBoxContentHost = (base.GetTemplateChild("PART_ContentHost") as FrameworkElement); this._renderScope = renderScope; if (this._passwordBoxContentHost is ScrollViewer) { ScrollViewer scrollViewer = (ScrollViewer)this._passwordBoxContentHost; if (scrollViewer.Content != null) { throw new NotSupportedException(SR.Get("TextBoxScrollViewerMarkedAsTextBoxContentMustHaveNoContent")); } scrollViewer.Content = this._renderScope; } else if (this._passwordBoxContentHost is Decorator) { Decorator decorator = (Decorator)this._passwordBoxContentHost; if (decorator.Child != null) { throw new NotSupportedException(SR.Get("TextBoxDecoratorMarkedAsTextBoxContentMustHaveNoContent")); } decorator.Child = this._renderScope; } else { this._renderScope = null; if (this._passwordBoxContentHost != null) { this._passwordBoxContentHost = null; throw new NotSupportedException(SR.Get("PasswordBoxInvalidTextContainer")); } } this.InitializeRenderScope(); FrameworkElement frameworkElement = this._renderScope; while (frameworkElement != this && frameworkElement != null) { if (frameworkElement is Border) { this._border = (Border)frameworkElement; } frameworkElement = (frameworkElement.Parent as FrameworkElement); } }
// Token: 0x06005361 RID: 21345 RVA: 0x00172D08 File Offset: 0x00170F08 private static void UpdateCaretElement(DependencyObject d, DependencyPropertyChangedEventArgs e) { PasswordBox passwordBox = (PasswordBox)d; if (passwordBox.Selection != null) { CaretElement caretElement = passwordBox.Selection.CaretElement; if (caretElement != null) { if (e.Property == PasswordBox.CaretBrushProperty) { caretElement.UpdateCaretBrush(TextSelection.GetCaretBrush(passwordBox.Selection.TextEditor)); } caretElement.InvalidateVisual(); } TextBoxView textBoxView = ((passwordBox != null) ? passwordBox.RenderScope : null) as TextBoxView; TextBoxView textBoxView2 = textBoxView; if (textBoxView2 != null && ((ITextView)textBoxView2).RendersOwnSelection) { textBoxView.InvalidateArrange(); } } }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="owner">Owner of the line.</param> internal TextBoxLine(TextBoxView owner) { _owner = owner; }
/// <summary> /// Walk the visual tree until we find a Text control with IsPasswordBoxContent == true /// and a ScrollViewer /// </summary> private void SetRenderScopeToContentHost(TextBoxView renderScope) { // Clear the content host from previous render scope (if any) ClearContentHost(); // Find ContentHostTemplateName in the style _passwordBoxContentHost = GetTemplateChild(ContentHostTemplateName) as FrameworkElement; // Note that we allow ContentHostTemplateName to be optional. // This simplifies toolability of our control styling. // When the ContentHostTemplateName is not found or incorrect // PasswordBox goes into disabled state, but does not throw. // Add renderScope as a child of ContentHostTemplateName _renderScope = renderScope; if (_passwordBoxContentHost is ScrollViewer) { ScrollViewer scrollViewer = (ScrollViewer)_passwordBoxContentHost; if (scrollViewer.Content != null) { throw new NotSupportedException(SR.Get(SRID.TextBoxScrollViewerMarkedAsTextBoxContentMustHaveNoContent)); } else { scrollViewer.Content = _renderScope; } } else if (_passwordBoxContentHost is Decorator) { Decorator decorator = (Decorator)_passwordBoxContentHost; if (decorator.Child != null) { throw new NotSupportedException(SR.Get(SRID.TextBoxDecoratorMarkedAsTextBoxContentMustHaveNoContent)); } else { decorator.Child = _renderScope; // this may replace old render scope in case of upgrade scenario in TextBox } } else { // When we implement TextContainer setting via TextView interface // all text containing element will become allowed here. _renderScope = null; // Explicitly not throwing an exception here when content host = null // -- designers need us to support no content scenarios if (_passwordBoxContentHost != null) { _passwordBoxContentHost = null; // throw new NotSupportedException(SR.Get(SRID.PasswordBoxInvalidTextContainer)); } } // Attach render scope to TextEditor InitializeRenderScope(); FrameworkElement element = _renderScope; while (element != this && element != null) // checking both just to be safe { if (element is Border) { _border = (Border)element; } element = element.Parent as FrameworkElement; } }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="owner">Owner of the line.</param> internal TextBoxLine(TextBoxView owner) { _owner = owner; PixelsPerDip = _owner.GetDpi().PixelsPerDip; }
internal TextCache(TextBoxView owner) { _lineProperties = owner.GetLineProperties(); _textRunCache = new TextRunCache(); Control hostControl = (Control)owner.Host; TextFormattingMode textFormattingMode = TextOptions.GetTextFormattingMode(hostControl); _textFormatter = System.Windows.Media.TextFormatting.TextFormatter.FromCurrentDispatcher(textFormattingMode); }
public PasswordBox() { textBoxView = new TextBoxView { IsPassword = true }; textBoxView.TextChanged += (sender, e) => this.Password = textBoxView.Text; textBoxView.GotKeyboardFocus += (sender, e) => Focus(); }
// Token: 0x0600412F RID: 16687 RVA: 0x0012A088 File Offset: 0x00128288 internal TextBoxLine(TextBoxView owner) { this._owner = owner; base.PixelsPerDip = this._owner.GetDpi().PixelsPerDip; }
// Token: 0x06004135 RID: 16693 RVA: 0x0012A278 File Offset: 0x00128478 internal TextBoxLineDrawingVisual CreateVisual(Geometry selectionGeometry) { TextBoxLineDrawingVisual textBoxLineDrawingVisual = new TextBoxLineDrawingVisual(); double x = this.CalculateXOffsetShift(); DrawingContext drawingContext = textBoxLineDrawingVisual.RenderOpen(); if (selectionGeometry != null) { TextBoxView owner = this._owner; FrameworkElement frameworkElement; if (owner == null) { frameworkElement = null; } else { ITextBoxViewHost host = owner.Host; if (host == null) { frameworkElement = null; } else { ITextContainer textContainer = host.TextContainer; if (textContainer == null) { frameworkElement = null; } else { ITextSelection textSelection = textContainer.TextSelection; if (textSelection == null) { frameworkElement = null; } else { TextEditor textEditor = textSelection.TextEditor; frameworkElement = ((textEditor != null) ? textEditor.UiScope : null); } } } } FrameworkElement frameworkElement2 = frameworkElement; if (frameworkElement2 != null) { Brush brush = frameworkElement2.GetValue(TextBoxBase.SelectionBrushProperty) as Brush; if (brush != null) { double opacity = (double)frameworkElement2.GetValue(TextBoxBase.SelectionOpacityProperty); drawingContext.PushOpacity(opacity); drawingContext.DrawGeometry(brush, new Pen { Brush = brush }, selectionGeometry); drawingContext.Pop(); } } } this._line.Draw(drawingContext, new Point(x, 0.0), (this._lineProperties.FlowDirection == FlowDirection.RightToLeft) ? InvertAxes.Horizontal : InvertAxes.None); drawingContext.Close(); return(textBoxLineDrawingVisual); }