From 2bd00bff491a5c3e508a0288be9f089fab4ec76e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 3 May 2018 22:07:41 +0100 Subject: [PATCH 01/10] Add a PasswordBox control. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 7 +- src/Avalonia.Controls/PasswordBox.cs | 47 ++++++++++++++ src/Avalonia.Themes.Default/PasswordBox.xaml | 64 +++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/Avalonia.Controls/PasswordBox.cs create mode 100644 src/Avalonia.Themes.Default/PasswordBox.xaml diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 7bfcad6d51..87fb1f0b4e 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -14,9 +14,14 @@ Watermark="Floating Watermark" UseFloatingWatermark="True" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/> + + - + diff --git a/src/Avalonia.Controls/PasswordBox.cs b/src/Avalonia.Controls/PasswordBox.cs new file mode 100644 index 0000000000..a7dd03445a --- /dev/null +++ b/src/Avalonia.Controls/PasswordBox.cs @@ -0,0 +1,47 @@ +using Avalonia.Controls.Primitives; +using Avalonia.Styling; +using System; + +namespace Avalonia.Controls +{ + public class PasswordBox : TextBox, IStyleable + { + Type IStyleable.StyleKey => typeof(PasswordBox); + + public PasswordBox() + { + this.GetObservable(TextProperty).Subscribe(text => + { + if (text != null) + { + DisplayText = new string(PasswordChar, text.Length); + } + else + { + DisplayText = null; + } + }); + } + + public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar), '*'); + + public char PasswordChar + { + get => GetValue(PasswordCharProperty); + set => SetValue(PasswordCharProperty, value); + } + + public static readonly StyledProperty DisplayTextProperty = AvaloniaProperty.Register(nameof(DisplayText)); + + public string DisplayText + { + get => GetValue(DisplayTextProperty); + set => SetValue(DisplayTextProperty, value); + } + + protected override void OnTemplateApplied(TemplateAppliedEventArgs e) + { + base.OnTemplateApplied(e); + } + } +} diff --git a/src/Avalonia.Themes.Default/PasswordBox.xaml b/src/Avalonia.Themes.Default/PasswordBox.xaml new file mode 100644 index 0000000000..4297a69bab --- /dev/null +++ b/src/Avalonia.Themes.Default/PasswordBox.xaml @@ -0,0 +1,64 @@ + + + + + + \ No newline at end of file From aca0fb3eba886449f0f381dcf94b0e0f99411c2e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 3 May 2018 22:37:53 +0100 Subject: [PATCH 02/10] Implement password char on TextBox rather than separate control. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 3 +- src/Avalonia.Controls/PasswordBox.cs | 47 -------------- src/Avalonia.Controls/TextBox.cs | 40 ++++++++++-- src/Avalonia.Themes.Default/PasswordBox.xaml | 64 ------------------- src/Avalonia.Themes.Default/TextBox.xaml | 4 +- 5 files changed, 39 insertions(+), 119 deletions(-) delete mode 100644 src/Avalonia.Controls/PasswordBox.cs delete mode 100644 src/Avalonia.Themes.Default/PasswordBox.xaml diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 87fb1f0b4e..96b534fc58 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -15,9 +15,10 @@ UseFloatingWatermark="True" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/> - diff --git a/src/Avalonia.Controls/PasswordBox.cs b/src/Avalonia.Controls/PasswordBox.cs deleted file mode 100644 index a7dd03445a..0000000000 --- a/src/Avalonia.Controls/PasswordBox.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Avalonia.Controls.Primitives; -using Avalonia.Styling; -using System; - -namespace Avalonia.Controls -{ - public class PasswordBox : TextBox, IStyleable - { - Type IStyleable.StyleKey => typeof(PasswordBox); - - public PasswordBox() - { - this.GetObservable(TextProperty).Subscribe(text => - { - if (text != null) - { - DisplayText = new string(PasswordChar, text.Length); - } - else - { - DisplayText = null; - } - }); - } - - public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar), '*'); - - public char PasswordChar - { - get => GetValue(PasswordCharProperty); - set => SetValue(PasswordCharProperty, value); - } - - public static readonly StyledProperty DisplayTextProperty = AvaloniaProperty.Register(nameof(DisplayText)); - - public string DisplayText - { - get => GetValue(DisplayTextProperty); - set => SetValue(DisplayTextProperty, value); - } - - protected override void OnTemplateApplied(TemplateAppliedEventArgs e) - { - base.OnTemplateApplied(e); - } - } -} diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 890926db54..a0096ef7ae 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -30,7 +30,10 @@ namespace Avalonia.Controls nameof(CaretIndex), o => o.CaretIndex, (o, v) => o.CaretIndex = v); - + + public static readonly StyledProperty PasswordCharProperty = + AvaloniaProperty.Register(nameof(PasswordChar)); + public static readonly StyledProperty IsReadOnlyProperty = AvaloniaProperty.Register(nameof(IsReadOnly)); @@ -53,6 +56,9 @@ namespace Avalonia.Controls defaultBindingMode: BindingMode.TwoWay, enableDataValidation: true); + public static readonly StyledProperty DisplayTextProperty = + AvaloniaProperty.Register(nameof(DisplayText)); + public static readonly StyledProperty TextAlignmentProperty = TextBlock.TextAlignmentProperty.AddOwner(); @@ -78,7 +84,7 @@ namespace Avalonia.Controls public bool Equals(UndoRedoState other) => ReferenceEquals(Text, other.Text) || Equals(Text, other.Text); } - + private string _text; private int _caretIndex; private int _selectionStart; @@ -117,6 +123,18 @@ namespace Avalonia.Controls horizontalScrollBarVisibility, BindingPriority.Style); _undoRedoHelper = new UndoRedoHelper(this); + + this.GetObservable(TextProperty).Subscribe(text => + { + if (PasswordChar != default(char)) + { + DisplayText = new string(PasswordChar, text.Length); + } + else + { + DisplayText = Text; + } + }); } public bool AcceptsReturn @@ -147,7 +165,13 @@ namespace Avalonia.Controls _undoRedoHelper.UpdateLastState(); } } - + + public char PasswordChar + { + get => GetValue(PasswordCharProperty); + set => SetValue(PasswordCharProperty, value); + } + public bool IsReadOnly { get { return GetValue(IsReadOnlyProperty); } @@ -208,6 +232,12 @@ namespace Avalonia.Controls } } + public string DisplayText + { + get => GetValue(DisplayTextProperty); + set => SetValue(DisplayTextProperty, value); + } + public TextAlignment TextAlignment { get { return GetValue(TextAlignmentProperty); } @@ -832,9 +862,9 @@ namespace Avalonia.Controls private void SetTextInternal(string value) { try - { + { _ignoreTextChanges = true; - SetAndRaise(TextProperty, ref _text, value); + SetAndRaise(TextProperty, ref _text, value); } finally { diff --git a/src/Avalonia.Themes.Default/PasswordBox.xaml b/src/Avalonia.Themes.Default/PasswordBox.xaml deleted file mode 100644 index 4297a69bab..0000000000 --- a/src/Avalonia.Themes.Default/PasswordBox.xaml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml index e228aebf58..52e98b0c57 100644 --- a/src/Avalonia.Themes.Default/TextBox.xaml +++ b/src/Avalonia.Themes.Default/TextBox.xaml @@ -38,12 +38,12 @@ Text="{TemplateBinding Watermark}" IsVisible="{TemplateBinding Path=Text, Converter={x:Static StringConverters.NullOrEmpty}}"/> + TextWrapping="{TemplateBinding TextWrapping}"/> From a9747e0bd67ce574996feece816c3645faac5292 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 3 May 2018 22:40:22 +0100 Subject: [PATCH 03/10] whitespace. --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 6 +++--- src/Avalonia.Controls/TextBox.cs | 14 +++++++------- src/Avalonia.Themes.Default/TextBox.xaml | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 96b534fc58..db1c9cb69d 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -10,8 +10,8 @@ - @@ -22,7 +22,7 @@ Text="Password" /> - + diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index a0096ef7ae..78ef532a26 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -32,7 +32,7 @@ namespace Avalonia.Controls (o, v) => o.CaretIndex = v); public static readonly StyledProperty PasswordCharProperty = - AvaloniaProperty.Register(nameof(PasswordChar)); + AvaloniaProperty.Register(nameof(PasswordChar)); public static readonly StyledProperty IsReadOnlyProperty = AvaloniaProperty.Register(nameof(IsReadOnly)); @@ -84,7 +84,7 @@ namespace Avalonia.Controls public bool Equals(UndoRedoState other) => ReferenceEquals(Text, other.Text) || Equals(Text, other.Text); } - + private string _text; private int _caretIndex; private int _selectionStart; @@ -93,7 +93,7 @@ namespace Avalonia.Controls private UndoRedoHelper _undoRedoHelper; private bool _isUndoingRedoing; private bool _ignoreTextChanges; - private static readonly string[] invalidCharacters = new String[1]{"\u007f"}; + private static readonly string[] invalidCharacters = new String[1] { "\u007f" }; static TextBox() { @@ -267,7 +267,7 @@ namespace Avalonia.Controls _presenter = e.NameScope.Get("PART_TextPresenter"); _presenter.Cursor = new Cursor(StandardCursorType.Ibeam); - if(IsFocused) + if (IsFocused) { _presenter.ShowCaret(); } @@ -608,7 +608,7 @@ namespace Avalonia.Controls DataValidationErrors.SetError(this, status.Error); } } - + private int CoerceCaretIndex(int value) => CoerceCaretIndex(value, Text?.Length ?? 0); private int CoerceCaretIndex(int value, int length) @@ -862,9 +862,9 @@ namespace Avalonia.Controls private void SetTextInternal(string value) { try - { + { _ignoreTextChanges = true; - SetAndRaise(TextProperty, ref _text, value); + SetAndRaise(TextProperty, ref _text, value); } finally { diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml index 52e98b0c57..89c445eac5 100644 --- a/src/Avalonia.Themes.Default/TextBox.xaml +++ b/src/Avalonia.Themes.Default/TextBox.xaml @@ -11,7 +11,7 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> - + - + + TextWrapping="{TemplateBinding TextWrapping}"/> From d1200e1e4727baa1232e05749d64252d14952bcf Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 3 May 2018 22:43:18 +0100 Subject: [PATCH 04/10] protect against copy and cut. --- src/Avalonia.Controls/TextBox.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 78ef532a26..df68a01722 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -126,7 +126,7 @@ namespace Avalonia.Controls this.GetObservable(TextProperty).Subscribe(text => { - if (PasswordChar != default(char)) + if (IsPasswordBox) { DisplayText = new string(PasswordChar, text.Length); } @@ -345,7 +345,7 @@ namespace Avalonia.Controls private async void Copy() { await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))) - .SetTextAsync(GetSelection()); + .SetTextAsync(GetSelection()); } private async void Paste() @@ -379,7 +379,10 @@ namespace Avalonia.Controls case Key.C: if (modifiers == InputModifiers.Control) { - Copy(); + if (!IsPasswordBox) + { + Copy(); + } handled = true; } break; @@ -387,8 +390,11 @@ namespace Avalonia.Controls case Key.X: if (modifiers == InputModifiers.Control) { - Copy(); - DeleteSelection(); + if (!IsPasswordBox) + { + Copy(); + DeleteSelection(); + } handled = true; } break; @@ -886,6 +892,8 @@ namespace Avalonia.Controls SelectionEnd = CaretIndex; } + private bool IsPasswordBox => PasswordChar != default(char); + UndoRedoState UndoRedoHelper.IUndoRedoHost.UndoRedoState { get { return new UndoRedoState(Text, CaretIndex); } From a4221ad809296d41c79d9d1f1832c9e2a12a763a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 3 May 2018 22:45:22 +0100 Subject: [PATCH 05/10] whitespace. --- src/Avalonia.Controls/TextBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index df68a01722..b09c380faa 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -345,7 +345,7 @@ namespace Avalonia.Controls private async void Copy() { await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))) - .SetTextAsync(GetSelection()); + .SetTextAsync(GetSelection()); } private async void Paste() From 8493ce8f0427eb1627ab18e148aa8487f9ea7823 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 9 May 2018 19:25:59 +0100 Subject: [PATCH 06/10] correctly order the properties. --- src/Avalonia.Controls/TextBox.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index b09c380faa..fb3eef742a 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -31,12 +31,12 @@ namespace Avalonia.Controls o => o.CaretIndex, (o, v) => o.CaretIndex = v); - public static readonly StyledProperty PasswordCharProperty = - AvaloniaProperty.Register(nameof(PasswordChar)); - public static readonly StyledProperty IsReadOnlyProperty = AvaloniaProperty.Register(nameof(IsReadOnly)); + public static readonly StyledProperty PasswordCharProperty = + AvaloniaProperty.Register(nameof(PasswordChar)); + public static readonly DirectProperty SelectionStartProperty = AvaloniaProperty.RegisterDirect( nameof(SelectionStart), @@ -166,18 +166,18 @@ namespace Avalonia.Controls } } - public char PasswordChar - { - get => GetValue(PasswordCharProperty); - set => SetValue(PasswordCharProperty, value); - } - public bool IsReadOnly { get { return GetValue(IsReadOnlyProperty); } set { SetValue(IsReadOnlyProperty, value); } } + public char PasswordChar + { + get => GetValue(PasswordCharProperty); + set => SetValue(PasswordCharProperty, value); + } + public int SelectionStart { get From 8befbacba018f8d36bb271d1d6a4c5ea8203c5c1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 9 May 2018 19:41:53 +0100 Subject: [PATCH 07/10] Use textpresenter to replace with password char. --- .../Presenters/TextPresenter.cs | 14 +++++++++++ src/Avalonia.Controls/TextBox.cs | 23 +------------------ src/Avalonia.Themes.Default/TextBox.xaml | 5 ++-- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index d2d4151e3d..902f951146 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -17,6 +17,9 @@ namespace Avalonia.Controls.Presenters o => o.CaretIndex, (o, v) => o.CaretIndex = v); + public static readonly StyledProperty PasswordCharProperty = + AvaloniaProperty.Register(nameof(PasswordChar)); + public static readonly DirectProperty SelectionStartProperty = TextBox.SelectionStartProperty.AddOwner( o => o.SelectionStart, @@ -63,6 +66,12 @@ namespace Avalonia.Controls.Presenters } } + public char PasswordChar + { + get => GetValue(PasswordCharProperty); + set => SetValue(PasswordCharProperty, value); + } + public int SelectionStart { get @@ -204,6 +213,11 @@ namespace Avalonia.Controls.Presenters protected override FormattedText CreateFormattedText(Size constraint) { + if (PasswordChar != default(char)) + { + Text = new string(PasswordChar, Text.Length); + } + var result = base.CreateFormattedText(constraint); var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index fb3eef742a..874d2a3229 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -56,9 +56,6 @@ namespace Avalonia.Controls defaultBindingMode: BindingMode.TwoWay, enableDataValidation: true); - public static readonly StyledProperty DisplayTextProperty = - AvaloniaProperty.Register(nameof(DisplayText)); - public static readonly StyledProperty TextAlignmentProperty = TextBlock.TextAlignmentProperty.AddOwner(); @@ -122,19 +119,7 @@ namespace Avalonia.Controls ScrollViewer.HorizontalScrollBarVisibilityProperty, horizontalScrollBarVisibility, BindingPriority.Style); - _undoRedoHelper = new UndoRedoHelper(this); - - this.GetObservable(TextProperty).Subscribe(text => - { - if (IsPasswordBox) - { - DisplayText = new string(PasswordChar, text.Length); - } - else - { - DisplayText = Text; - } - }); + _undoRedoHelper = new UndoRedoHelper(this); } public bool AcceptsReturn @@ -232,12 +217,6 @@ namespace Avalonia.Controls } } - public string DisplayText - { - get => GetValue(DisplayTextProperty); - set => SetValue(DisplayTextProperty, value); - } - public TextAlignment TextAlignment { get { return GetValue(TextAlignmentProperty); } diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml index 89c445eac5..c57e5b792d 100644 --- a/src/Avalonia.Themes.Default/TextBox.xaml +++ b/src/Avalonia.Themes.Default/TextBox.xaml @@ -38,12 +38,13 @@ Text="{TemplateBinding Watermark}" IsVisible="{TemplateBinding Path=Text, Converter={x:Static StringConverters.NullOrEmpty}}"/> + TextWrapping="{TemplateBinding TextWrapping}" + PasswordChar="{TemplateBinding PasswordChar}"/> From 58daa9390b185bb3bc15443c9437f9d69ae2dc92 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 May 2018 15:28:37 +0100 Subject: [PATCH 08/10] Allow CreateFormattedText to have the string it renders overridden. --- src/Avalonia.Controls/Presenters/TextPresenter.cs | 11 ++++++++--- src/Avalonia.Controls/Primitives/AccessText.cs | 11 ++--------- src/Avalonia.Controls/TextBlock.cs | 7 ++++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 902f951146..4d63148b5f 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -211,14 +211,19 @@ namespace Avalonia.Controls.Presenters } } - protected override FormattedText CreateFormattedText(Size constraint) + protected override FormattedText CreateFormattedText(Size constraint, string text) { + FormattedText result = null; + if (PasswordChar != default(char)) { - Text = new string(PasswordChar, Text.Length); + result = base.CreateFormattedText(constraint, new string(PasswordChar, Text.Length)); + } + else + { + result = base.CreateFormattedText(constraint, Text); } - var result = base.CreateFormattedText(constraint); var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; var start = Math.Min(selectionStart, selectionEnd); diff --git a/src/Avalonia.Controls/Primitives/AccessText.cs b/src/Avalonia.Controls/Primitives/AccessText.cs index 4bb80e6d3f..5b0f79c9c8 100644 --- a/src/Avalonia.Controls/Primitives/AccessText.cs +++ b/src/Avalonia.Controls/Primitives/AccessText.cs @@ -83,16 +83,9 @@ namespace Avalonia.Controls.Primitives /// /// The constraint of the text. /// A object. - protected override FormattedText CreateFormattedText(Size constraint) + protected override FormattedText CreateFormattedText(Size constraint, string text) { - return new FormattedText - { - Constraint = constraint, - Typeface = new Typeface(FontFamily, FontSize, FontStyle, FontWeight), - Text = StripAccessKey(Text), - TextAlignment = TextAlignment, - Wrapping = TextWrapping, - }; + return base.CreateFormattedText(constraint, StripAccessKey(text)); } /// diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index 88a9fe077d..35600a213c 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -197,7 +197,7 @@ namespace Avalonia.Controls { if (_formattedText == null) { - _formattedText = CreateFormattedText(_constraint); + _formattedText = CreateFormattedText(_constraint, Text); } return _formattedText; @@ -348,14 +348,15 @@ namespace Avalonia.Controls /// Creates the used to render the text. /// /// The constraint of the text. + /// The text to generated the for. /// A object. - protected virtual FormattedText CreateFormattedText(Size constraint) + protected virtual FormattedText CreateFormattedText(Size constraint, string text) { return new FormattedText { Constraint = constraint, Typeface = new Typeface(FontFamily, FontSize, FontStyle, FontWeight), - Text = Text ?? string.Empty, + Text = text ?? string.Empty, TextAlignment = TextAlignment, Wrapping = TextWrapping, }; From 515e180cdbcd9b6827e9a6c7847d4e8841575f91 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 14 May 2018 15:30:58 +0100 Subject: [PATCH 09/10] update documentation for CreateFormattedText method. --- src/Avalonia.Controls/Presenters/TextPresenter.cs | 6 ++++++ src/Avalonia.Controls/Primitives/AccessText.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 4d63148b5f..c241466aea 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -211,6 +211,12 @@ namespace Avalonia.Controls.Presenters } } + /// + /// Creates the used to render the text. + /// + /// The constraint of the text. + /// The text to generated the for. + /// A object. protected override FormattedText CreateFormattedText(Size constraint, string text) { FormattedText result = null; diff --git a/src/Avalonia.Controls/Primitives/AccessText.cs b/src/Avalonia.Controls/Primitives/AccessText.cs index 5b0f79c9c8..55f047b009 100644 --- a/src/Avalonia.Controls/Primitives/AccessText.cs +++ b/src/Avalonia.Controls/Primitives/AccessText.cs @@ -82,6 +82,7 @@ namespace Avalonia.Controls.Primitives /// Creates the used to render the text. /// /// The constraint of the text. + /// The text to generated the for. /// A object. protected override FormattedText CreateFormattedText(Size constraint, string text) { From cb39aa0426f6b076bdceb457dad2b1c7bb45a70a Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 15 May 2018 09:13:41 +0200 Subject: [PATCH 10/10] Fixed doc comments. --- src/Avalonia.Controls/Primitives/AccessText.cs | 7 +------ src/Avalonia.Controls/TextBlock.cs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/Primitives/AccessText.cs b/src/Avalonia.Controls/Primitives/AccessText.cs index 55f047b009..32a0efc440 100644 --- a/src/Avalonia.Controls/Primitives/AccessText.cs +++ b/src/Avalonia.Controls/Primitives/AccessText.cs @@ -78,12 +78,7 @@ namespace Avalonia.Controls.Primitives } } - /// - /// Creates the used to render the text. - /// - /// The constraint of the text. - /// The text to generated the for. - /// A object. + /// protected override FormattedText CreateFormattedText(Size constraint, string text) { return base.CreateFormattedText(constraint, StripAccessKey(text)); diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index 35600a213c..1fee309360 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -348,7 +348,7 @@ namespace Avalonia.Controls /// Creates the used to render the text. /// /// The constraint of the text. - /// The text to generated the for. + /// The text to format. /// A object. protected virtual FormattedText CreateFormattedText(Size constraint, string text) {