|
|
@ -14,6 +14,9 @@ namespace Avalonia.Controls.Presenters |
|
|
o => o.CaretIndex, |
|
|
o => o.CaretIndex, |
|
|
(o, v) => o.CaretIndex = v); |
|
|
(o, v) => o.CaretIndex = v); |
|
|
|
|
|
|
|
|
|
|
|
public static readonly StyledProperty<bool> ShowPasswordCharProperty = |
|
|
|
|
|
AvaloniaProperty.Register<TextPresenter, bool>(nameof(ShowPasswordChar), true); |
|
|
|
|
|
|
|
|
public static readonly StyledProperty<char> PasswordCharProperty = |
|
|
public static readonly StyledProperty<char> PasswordCharProperty = |
|
|
AvaloniaProperty.Register<TextPresenter, char>(nameof(PasswordChar)); |
|
|
AvaloniaProperty.Register<TextPresenter, char>(nameof(PasswordChar)); |
|
|
|
|
|
|
|
|
@ -75,7 +78,7 @@ namespace Avalonia.Controls.Presenters |
|
|
static TextPresenter() |
|
|
static TextPresenter() |
|
|
{ |
|
|
{ |
|
|
AffectsRender<TextPresenter>(SelectionBrushProperty); |
|
|
AffectsRender<TextPresenter>(SelectionBrushProperty); |
|
|
AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty, |
|
|
AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty, ShowPasswordCharProperty, |
|
|
TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty, |
|
|
TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty, |
|
|
TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty); |
|
|
TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty); |
|
|
|
|
|
|
|
|
@ -84,7 +87,7 @@ namespace Avalonia.Controls.Presenters |
|
|
TextBlock.FontSizeProperty.Changed, TextBlock.FontStyleProperty.Changed, |
|
|
TextBlock.FontSizeProperty.Changed, TextBlock.FontStyleProperty.Changed, |
|
|
TextBlock.FontWeightProperty.Changed, TextBlock.FontFamilyProperty.Changed, |
|
|
TextBlock.FontWeightProperty.Changed, TextBlock.FontFamilyProperty.Changed, |
|
|
SelectionStartProperty.Changed, SelectionEndProperty.Changed, |
|
|
SelectionStartProperty.Changed, SelectionEndProperty.Changed, |
|
|
SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed |
|
|
SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed, ShowPasswordCharProperty.Changed |
|
|
).AddClassHandler<TextPresenter>((x, _) => x.InvalidateFormattedText()); |
|
|
).AddClassHandler<TextPresenter>((x, _) => x.InvalidateFormattedText()); |
|
|
|
|
|
|
|
|
CaretIndexProperty.Changed.AddClassHandler<TextPresenter>((x, e) => x.CaretIndexChanged((int)e.NewValue)); |
|
|
CaretIndexProperty.Changed.AddClassHandler<TextPresenter>((x, e) => x.CaretIndexChanged((int)e.NewValue)); |
|
|
@ -210,6 +213,12 @@ namespace Avalonia.Controls.Presenters |
|
|
set => SetValue(PasswordCharProperty, value); |
|
|
set => SetValue(PasswordCharProperty, value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool ShowPasswordChar |
|
|
|
|
|
{ |
|
|
|
|
|
get => GetValue(ShowPasswordCharProperty); |
|
|
|
|
|
set => SetValue(ShowPasswordCharProperty, value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public IBrush SelectionBrush |
|
|
public IBrush SelectionBrush |
|
|
{ |
|
|
{ |
|
|
get => GetValue(SelectionBrushProperty); |
|
|
get => GetValue(SelectionBrushProperty); |
|
|
@ -426,7 +435,7 @@ namespace Avalonia.Controls.Presenters |
|
|
|
|
|
|
|
|
var text = Text; |
|
|
var text = Text; |
|
|
|
|
|
|
|
|
if (PasswordChar != default(char)) |
|
|
if (PasswordChar != default(char) && ShowPasswordChar) |
|
|
{ |
|
|
{ |
|
|
result = CreateFormattedTextInternal(_constraint, new string(PasswordChar, text?.Length ?? 0)); |
|
|
result = CreateFormattedTextInternal(_constraint, new string(PasswordChar, text?.Length ?? 0)); |
|
|
} |
|
|
} |
|
|
|