From de46427a78848d408e89c12374f5c2a4264f731e Mon Sep 17 00:00:00 2001 From: Salman Muin Kayser Chishti <13schishti@Gmail.com> Date: Wed, 30 Oct 2019 04:08:39 +0000 Subject: [PATCH 01/13] Update PropertyKind.cs --- .../Models/PropertyDescriptor/PropertyKind.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs b/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs index a4cb9632949..1a5c1679c33 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs @@ -13,6 +13,6 @@ public enum PropertyKind Bool, Brush, TimeSpan, - Thickness + Thicknessasdfadsf } } From 74de9e30c8de9ec7c07cd599e95b178e892269f6 Mon Sep 17 00:00:00 2001 From: SalmanMKC <13schishti@gmail.com> Date: Wed, 1 Apr 2020 01:57:58 +0100 Subject: [PATCH 02/13] undo change --- .../Models/PropertyDescriptor/PropertyKind.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs b/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs index 1a5c1679c33..a4cb9632949 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/Models/PropertyDescriptor/PropertyKind.cs @@ -13,6 +13,6 @@ public enum PropertyKind Bool, Brush, TimeSpan, - Thicknessasdfadsf + Thickness } } From 89d3c6a173821712df955a50d22adca1796ee12d Mon Sep 17 00:00:00 2001 From: SalmanMKC <13schishti@gmail.com> Date: Wed, 1 Apr 2020 16:50:51 +0100 Subject: [PATCH 03/13] Functionality done --- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 6 ++-- .../InfiniteCanvas/InfiniteCanvas.cs | 8 ++--- .../InfiniteCanvas/InfiniteCanvas.xaml | 36 +++++++++++++++---- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index 6edfd098f16..360168bfd89 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -41,10 +41,10 @@ private int TextFontSize { get { - if (!string.IsNullOrWhiteSpace(_canvasTextBoxFontSizeTextBox.Text) && + if (!string.IsNullOrWhiteSpace(_canvasTextBoxFontSizeTextBox.SelectedValue.ToString()) && Regex.IsMatch(_canvasTextBoxFontSizeTextBox.Text, "^[0-9]*$")) { - var fontSize = int.Parse(_canvasTextBoxFontSizeTextBox.Text); + var fontSize = int.Parse((_canvasTextBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); _lastValidTextFontSizeValue = fontSize; } @@ -93,7 +93,7 @@ private void CanvasTextBoxItalicButton_Clicked(object sender, RoutedEventArgs e) } } - private void CanvasTextBoxFontSizeTextBox_TextChanged(object sender, TextChangedEventArgs e) + private void CanvasTextBoxFontSizeTextBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { _canvasTextBox.UpdateFontSize(TextFontSize); if (SelectedTextDrawable != null) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs index be4e955b281..c2e3904fdb1 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs @@ -71,7 +71,7 @@ public partial class InfiniteCanvas : Control private StackPanel _canvasTextBoxTools; private Windows.UI.Xaml.Controls.ColorPicker _canvasTextBoxColorPicker; - private TextBox _canvasTextBoxFontSizeTextBox; + private ComboBox _canvasTextBoxFontSizeTextBox; private ToggleButton _canvasTextBoxItalicButton; private ToggleButton _canvasTextBoxBoldButton; private Button _undoButton; @@ -244,7 +244,7 @@ protected override void OnApplyTemplate() { _canvasTextBoxTools = (StackPanel)GetTemplateChild(CanvasTextBoxToolsName); this._canvasTextBoxColorPicker = (Windows.UI.Xaml.Controls.ColorPicker)GetTemplateChild(CanvasTextBoxColorPickerName); - _canvasTextBoxFontSizeTextBox = (TextBox)GetTemplateChild(CanvasTextBoxFontSizeTextBoxName); + _canvasTextBoxFontSizeTextBox = (ComboBox)GetTemplateChild(CanvasTextBoxFontSizeTextBoxName); _canvasTextBoxItalicButton = (ToggleButton)GetTemplateChild(CanvasTextBoxItalicButtonName); _canvasTextBoxBoldButton = (ToggleButton)GetTemplateChild(CanvasTextBoxBoldButtonName); _drawingSurfaceRenderer = (InfiniteCanvasVirtualDrawingSurface)GetTemplateChild(DrawingSurfaceRendererName); @@ -296,7 +296,7 @@ protected override void OnApplyTemplate() private void UnRegisterEvents() { - _canvasTextBoxFontSizeTextBox.TextChanged -= CanvasTextBoxFontSizeTextBox_TextChanged; + _canvasTextBoxFontSizeTextBox.SelectionChanged -= CanvasTextBoxFontSizeTextBox_SelectionChanged; _canvasTextBoxItalicButton.Click -= CanvasTextBoxItalicButton_Clicked; _canvasTextBoxBoldButton.Click -= CanvasTextBoxBoldButton_Clicked; _canvasTextBoxColorPicker.ColorChanged -= CanvasTextBoxColorPicker_ColorChanged; @@ -320,7 +320,7 @@ private void UnRegisterEvents() private void RegisterEvents() { - _canvasTextBoxFontSizeTextBox.TextChanged += CanvasTextBoxFontSizeTextBox_TextChanged; + _canvasTextBoxFontSizeTextBox.SelectionChanged += CanvasTextBoxFontSizeTextBox_SelectionChanged; _canvasTextBoxItalicButton.Click += CanvasTextBoxItalicButton_Clicked; _canvasTextBoxBoldButton.Click += CanvasTextBoxBoldButton_Clicked; _canvasTextBoxColorPicker.ColorChanged += CanvasTextBoxColorPicker_ColorChanged; diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index 975ef857783..e0c546f8c43 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -97,13 +97,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + From 79661ed4d0584906edab5089387bc45be0a16f25 Mon Sep 17 00:00:00 2001 From: SalmanMKC <13schishti@gmail.com> Date: Wed, 1 Apr 2020 16:58:50 +0100 Subject: [PATCH 04/13] capitalisation corrections --- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 12 ++++++------ .../InfiniteCanvas/InfiniteCanvas.cs | 16 ++++++++-------- .../InfiniteCanvas/InfiniteCanvas.xaml | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index 360168bfd89..9b1d5ff3a89 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -41,10 +41,10 @@ private int TextFontSize { get { - if (!string.IsNullOrWhiteSpace(_canvasTextBoxFontSizeTextBox.SelectedValue.ToString()) && - Regex.IsMatch(_canvasTextBoxFontSizeTextBox.Text, "^[0-9]*$")) + if (!string.IsNullOrWhiteSpace(_canvasComboBoxFontSizeTextBox.SelectedValue.ToString()) && + Regex.IsMatch(_canvasComboBoxFontSizeTextBox.Text, "^[0-9]*$")) { - var fontSize = int.Parse((_canvasTextBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); + var fontSize = int.Parse((_canvasComboBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); _lastValidTextFontSizeValue = fontSize; } @@ -93,7 +93,7 @@ private void CanvasTextBoxItalicButton_Clicked(object sender, RoutedEventArgs e) } } - private void CanvasTextBoxFontSizeTextBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void CanvasComboBoxFontSizeTextBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { _canvasTextBox.UpdateFontSize(TextFontSize); if (SelectedTextDrawable != null) @@ -185,7 +185,7 @@ private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArg // Updating toolbar _canvasTextBoxColorPicker.Color = SelectedTextDrawable.TextColor; - _canvasTextBoxFontSizeTextBox.Text = SelectedTextDrawable.FontSize.ToString(); + _canvasComboBoxFontSizeTextBox.Text = SelectedTextDrawable.FontSize.ToString(); _canvasTextBoxBoldButton.IsChecked = SelectedTextDrawable.IsBold; _canvasTextBoxItalicButton.IsChecked = SelectedTextDrawable.IsItalic; @@ -210,7 +210,7 @@ private void ClearTextBoxValue() _canvasTextBox.Clear(); } - private void CanvasTextBoxFontSizeTextBox_PreviewKeyDown(object sender, KeyRoutedEventArgs e) + private void CanvasComboBoxFontSizeTextBox_PreviewKeyDown(object sender, KeyRoutedEventArgs e) { if (_allowedCommands.Contains(e.Key.ToString())) { diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs index c2e3904fdb1..abdd3c099f0 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs @@ -21,7 +21,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls /// [TemplatePart(Name = CanvasTextBoxToolsName, Type = typeof(StackPanel))] [TemplatePart(Name = CanvasTextBoxColorPickerName, Type = typeof(Windows.UI.Xaml.Controls.ColorPicker))] - [TemplatePart(Name = CanvasTextBoxFontSizeTextBoxName, Type = typeof(TextBox))] + [TemplatePart(Name = CanvasComboBoxFontSizeTextBoxName, Type = typeof(TextBox))] [TemplatePart(Name = CanvasTextBoxItalicButtonName, Type = typeof(ToggleButton))] [TemplatePart(Name = CanvasTextBoxBoldButtonName, Type = typeof(ToggleButton))] [TemplatePart(Name = DrawingSurfaceRendererName, Type = typeof(InfiniteCanvasVirtualDrawingSurface))] @@ -45,7 +45,7 @@ public partial class InfiniteCanvas : Control private const string CanvasTextBoxToolsName = "CanvasTextBoxTools"; private const string CanvasTextBoxColorPickerName = "CanvasTextBoxColorPicker"; - private const string CanvasTextBoxFontSizeTextBoxName = "CanvasTextBoxFontSizeTextBox"; + private const string CanvasComboBoxFontSizeTextBoxName = "CanvasComboBoxFontSizeTextBox"; private const string CanvasTextBoxItalicButtonName = "CanvasTextBoxItalicButton"; private const string CanvasTextBoxBoldButtonName = "CanvasTextBoxBoldButton"; private const string DrawingSurfaceRendererName = "DrawingSurfaceRenderer"; @@ -71,7 +71,7 @@ public partial class InfiniteCanvas : Control private StackPanel _canvasTextBoxTools; private Windows.UI.Xaml.Controls.ColorPicker _canvasTextBoxColorPicker; - private ComboBox _canvasTextBoxFontSizeTextBox; + private ComboBox _canvasComboBoxFontSizeTextBox; private ToggleButton _canvasTextBoxItalicButton; private ToggleButton _canvasTextBoxBoldButton; private Button _undoButton; @@ -244,7 +244,7 @@ protected override void OnApplyTemplate() { _canvasTextBoxTools = (StackPanel)GetTemplateChild(CanvasTextBoxToolsName); this._canvasTextBoxColorPicker = (Windows.UI.Xaml.Controls.ColorPicker)GetTemplateChild(CanvasTextBoxColorPickerName); - _canvasTextBoxFontSizeTextBox = (ComboBox)GetTemplateChild(CanvasTextBoxFontSizeTextBoxName); + _canvasComboBoxFontSizeTextBox = (ComboBox)GetTemplateChild(CanvasComboBoxFontSizeTextBoxName); _canvasTextBoxItalicButton = (ToggleButton)GetTemplateChild(CanvasTextBoxItalicButtonName); _canvasTextBoxBoldButton = (ToggleButton)GetTemplateChild(CanvasTextBoxBoldButtonName); _drawingSurfaceRenderer = (InfiniteCanvasVirtualDrawingSurface)GetTemplateChild(DrawingSurfaceRendererName); @@ -296,7 +296,7 @@ protected override void OnApplyTemplate() private void UnRegisterEvents() { - _canvasTextBoxFontSizeTextBox.SelectionChanged -= CanvasTextBoxFontSizeTextBox_SelectionChanged; + _canvasComboBoxFontSizeTextBox.SelectionChanged -= CanvasComboBoxFontSizeTextBox_SelectionChanged; _canvasTextBoxItalicButton.Click -= CanvasTextBoxItalicButton_Clicked; _canvasTextBoxBoldButton.Click -= CanvasTextBoxBoldButton_Clicked; _canvasTextBoxColorPicker.ColorChanged -= CanvasTextBoxColorPicker_ColorChanged; @@ -314,13 +314,13 @@ private void UnRegisterEvents() Unloaded -= InfiniteCanvas_Unloaded; Application.Current.LeavingBackground -= Current_LeavingBackground; _drawingSurfaceRenderer.CommandExecuted -= DrawingSurfaceRenderer_CommandExecuted; - _canvasTextBoxFontSizeTextBox.PreviewKeyDown -= CanvasTextBoxFontSizeTextBox_PreviewKeyDown; + _canvasComboBoxFontSizeTextBox.PreviewKeyDown -= CanvasComboBoxFontSizeTextBox_PreviewKeyDown; Loaded -= InfiniteCanvas_Loaded; } private void RegisterEvents() { - _canvasTextBoxFontSizeTextBox.SelectionChanged += CanvasTextBoxFontSizeTextBox_SelectionChanged; + _canvasComboBoxFontSizeTextBox.SelectionChanged += CanvasComboBoxFontSizeTextBox_SelectionChanged; _canvasTextBoxItalicButton.Click += CanvasTextBoxItalicButton_Clicked; _canvasTextBoxBoldButton.Click += CanvasTextBoxBoldButton_Clicked; _canvasTextBoxColorPicker.ColorChanged += CanvasTextBoxColorPicker_ColorChanged; @@ -338,7 +338,7 @@ private void RegisterEvents() Unloaded += InfiniteCanvas_Unloaded; Application.Current.LeavingBackground += Current_LeavingBackground; _drawingSurfaceRenderer.CommandExecuted += DrawingSurfaceRenderer_CommandExecuted; - _canvasTextBoxFontSizeTextBox.PreviewKeyDown += CanvasTextBoxFontSizeTextBox_PreviewKeyDown; + _canvasComboBoxFontSizeTextBox.PreviewKeyDown += CanvasComboBoxFontSizeTextBox_PreviewKeyDown; Loaded += InfiniteCanvas_Loaded; } diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index e0c546f8c43..4d1a869ef74 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -97,7 +97,7 @@ - From 8546875cd20f972fb035d9e3b4df8f1c699655bb Mon Sep 17 00:00:00 2001 From: Salman Muin Kayser Chishti <13schishti@gmail.com> Date: Thu, 9 Apr 2020 00:26:00 +0100 Subject: [PATCH 05/13] removed duplicate 48 size font --- .../InfiniteCanvas/InfiniteCanvas.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index 4d1a869ef74..52bc99e4abf 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -117,7 +117,6 @@ - From 40028a7183dc5ce1140492642808b7602b9e2c6d Mon Sep 17 00:00:00 2001 From: Salman Muin Kayser Chishti <13schishti@gmail.com> Date: Fri, 11 Sep 2020 13:44:14 +0100 Subject: [PATCH 06/13] Update Microsoft.Toolkit.Uwp.UI.Controls/InfiniteCanvas/InfiniteCanvas.xaml Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com> --- .../InfiniteCanvas/InfiniteCanvas.xaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index 52bc99e4abf..c74385f62ac 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -103,27 +103,19 @@ - + + - - - - - - - - - From 6218a967de0de9e4089b5a8e0c152a5ccbc5c4f2 Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Fri, 2 Apr 2021 14:52:02 -0400 Subject: [PATCH 07/13] CanvasComboBoxFontSizeTextBox add back in tooltip --- .../InfiniteCanvas/InfiniteCanvas.xaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index c74385f62ac..8e4ecad8b22 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -99,7 +99,12 @@ + Height="32" + SelectedIndex="9" + Margin="0,0,12,0" + VerticalAlignment="Center" + ToolTipService.ToolTip="Font Size" + > From f9837b5304808b27ebb5bcec917e5861a0e76025 Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Fri, 2 Apr 2021 15:46:34 -0400 Subject: [PATCH 08/13] WIP: make combobox editable --- .../InfiniteCanvas/InfiniteCanvas.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index 8e4ecad8b22..8530bff3be0 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -104,6 +104,7 @@ Margin="0,0,12,0" VerticalAlignment="Center" ToolTipService.ToolTip="Font Size" + IsEditable="True" > From 5b2434f38f5ba9b7dd4c60e66e06991664eef1d8 Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Fri, 9 Apr 2021 13:30:11 -0400 Subject: [PATCH 09/13] Font size align type with underlying win2d CanvasTestFormat int -> float Note: Control.FontSize is a double, perhaps win2d should allign with this and this should be changed to doulbe then. --- .../Commands/InfiniteCanvasCreateTextBoxCommand.cs | 2 +- .../InfiniteCanvasVirtualDrawingSurface.Commands.cs | 2 +- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Commands/InfiniteCanvasCreateTextBoxCommand.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Commands/InfiniteCanvasCreateTextBoxCommand.cs index cfd5d28629f..85db685d814 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Commands/InfiniteCanvasCreateTextBoxCommand.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Commands/InfiniteCanvasCreateTextBoxCommand.cs @@ -12,7 +12,7 @@ internal class InfiniteCanvasCreateTextBoxCommand : IInfiniteCanvasCommand private readonly List _drawableList; private readonly TextDrawable _drawable; - public InfiniteCanvasCreateTextBoxCommand(List drawableList, double x, double y, double width, double height, int textFontSize, string text, Color color, bool isBold, bool isItalic) + public InfiniteCanvasCreateTextBoxCommand(List drawableList, double x, double y, double width, double height, float textFontSize, string text, Color color, bool isBold, bool isItalic) { _drawable = new TextDrawable( x, diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Controls/InfiniteCanvasVirtualDrawingSurface.Commands.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Controls/InfiniteCanvasVirtualDrawingSurface.Commands.cs index 7350db53dbb..d2ef41bfab3 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Controls/InfiniteCanvasVirtualDrawingSurface.Commands.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/Controls/InfiniteCanvasVirtualDrawingSurface.Commands.cs @@ -79,7 +79,7 @@ internal void ExecuteUpdateTextBoxFontSize(float newValue) ExecuteCommand(command); } - internal void ExecuteCreateTextBox(double x, double y, double width, double height, int textFontSize, string text, Color color, bool isBold, bool isItalic) + internal void ExecuteCreateTextBox(double x, double y, double width, double height, float textFontSize, string text, Color color, bool isBold, bool isItalic) { var command = new InfiniteCanvasCreateTextBoxCommand(_drawableList, x, y, width, height, textFontSize, text, color, isBold, isItalic); ExecuteCommand(command); diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index 9b1d5ff3a89..32c03cfc8a9 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -35,16 +35,16 @@ public partial class InfiniteCanvas private TextDrawable SelectedTextDrawable => _drawingSurfaceRenderer.GetSelectedTextDrawable(); - private int _lastValidTextFontSizeValue = DefaultFontValue; + private float _lastValidTextFontSizeValue = DefaultFontValue; - private int TextFontSize + private float TextFontSize { get { if (!string.IsNullOrWhiteSpace(_canvasComboBoxFontSizeTextBox.SelectedValue.ToString()) && Regex.IsMatch(_canvasComboBoxFontSizeTextBox.Text, "^[0-9]*$")) { - var fontSize = int.Parse((_canvasComboBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); + var fontSize = float.Parse((_canvasComboBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); _lastValidTextFontSizeValue = fontSize; } From 9878a505b11ae5839cb7dd48f155315a0f0860ba Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Fri, 9 Apr 2021 13:31:56 -0400 Subject: [PATCH 10/13] Only update font size on select font or on enter for text input --- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 73 ++++++++++--------- .../InfiniteCanvas/InfiniteCanvas.cs | 4 +- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index 32c03cfc8a9..8dfc026758b 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -28,28 +28,20 @@ public partial class InfiniteCanvas "Right", "Up", "Left", - "Down" + "Down", + "Enter" }; private Point _lastInputPoint; private TextDrawable SelectedTextDrawable => _drawingSurfaceRenderer.GetSelectedTextDrawable(); - private float _lastValidTextFontSizeValue = DefaultFontValue; + private float _textFontSize = DefaultFontValue; - private float TextFontSize + private void SetFontSize(float newSize) { - get - { - if (!string.IsNullOrWhiteSpace(_canvasComboBoxFontSizeTextBox.SelectedValue.ToString()) && - Regex.IsMatch(_canvasComboBoxFontSizeTextBox.Text, "^[0-9]*$")) - { - var fontSize = float.Parse((_canvasComboBoxFontSizeTextBox.SelectedItem as ComboBoxItem).Content.ToString()); - _lastValidTextFontSizeValue = fontSize; - } - - return _lastValidTextFontSizeValue; - } + _textFontSize = newSize; + _canvasTextBox.UpdateFontSize(newSize); } private void InkScrollViewer_PreviewKeyDown(object sender, KeyRoutedEventArgs e) @@ -95,11 +87,26 @@ private void CanvasTextBoxItalicButton_Clicked(object sender, RoutedEventArgs e) private void CanvasComboBoxFontSizeTextBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - _canvasTextBox.UpdateFontSize(TextFontSize); - if (SelectedTextDrawable != null) + if (sender is ComboBox s + && s.SelectedItem is ComboBoxItem selectedItem + && selectedItem.Content is string selectedText + && float.TryParse(selectedText, out var sizeNumb)) { - _drawingSurfaceRenderer.ExecuteUpdateTextBoxFontSize(TextFontSize); - ReDrawCanvas(); + SetFontSize(sizeNumb); + + if (SelectedTextDrawable != null) + { + _drawingSurfaceRenderer.ExecuteUpdateTextBoxFontSize(sizeNumb); + ReDrawCanvas(); + } + } + } + + private void CanvasComboBoxFontSizeTextBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args) + { + if (float.TryParse(args.Text, out var size)) + { + SetFontSize(size); } } @@ -147,20 +154,22 @@ private void CanvasTextBox_TextChanged(object sender, string text) ReDrawCanvas(); return; } + else + { + _drawingSurfaceRenderer.ExecuteCreateTextBox( + _lastInputPoint.X, + _lastInputPoint.Y, + _canvasTextBox.GetEditZoneWidth(), + _canvasTextBox.GetEditZoneHeight(), + _textFontSize, + text, + _canvasTextBoxColorPicker.Color, + _canvasTextBoxBoldButton.IsChecked ?? false, + _canvasTextBoxItalicButton.IsChecked ?? false); - _drawingSurfaceRenderer.ExecuteCreateTextBox( - _lastInputPoint.X, - _lastInputPoint.Y, - _canvasTextBox.GetEditZoneWidth(), - _canvasTextBox.GetEditZoneHeight(), - TextFontSize, - text, - _canvasTextBoxColorPicker.Color, - _canvasTextBoxBoldButton.IsChecked ?? false, - _canvasTextBoxItalicButton.IsChecked ?? false); - - ReDrawCanvas(); - _drawingSurfaceRenderer.UpdateSelectedTextDrawable(); + ReDrawCanvas(); + _drawingSurfaceRenderer.UpdateSelectedTextDrawable(); + } } private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArgs e) @@ -179,7 +188,6 @@ private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArg Canvas.SetLeft(_canvasTextBox, SelectedTextDrawable.Bounds.X); Canvas.SetTop(_canvasTextBox, SelectedTextDrawable.Bounds.Y); - _canvasTextBox.UpdateFontSize(SelectedTextDrawable.FontSize); _canvasTextBox.UpdateFontStyle(SelectedTextDrawable.IsItalic); _canvasTextBox.UpdateFontWeight(SelectedTextDrawable.IsBold); @@ -192,7 +200,6 @@ private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArg return; } - _canvasTextBox.UpdateFontSize(TextFontSize); _canvasTextBox.UpdateFontStyle(_canvasTextBoxItalicButton.IsChecked ?? false); _canvasTextBox.UpdateFontWeight(_canvasTextBoxBoldButton.IsChecked ?? false); diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs index abdd3c099f0..d5bef7834f4 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.cs @@ -315,6 +315,7 @@ private void UnRegisterEvents() Application.Current.LeavingBackground -= Current_LeavingBackground; _drawingSurfaceRenderer.CommandExecuted -= DrawingSurfaceRenderer_CommandExecuted; _canvasComboBoxFontSizeTextBox.PreviewKeyDown -= CanvasComboBoxFontSizeTextBox_PreviewKeyDown; + _canvasComboBoxFontSizeTextBox.TextSubmitted -= CanvasComboBoxFontSizeTextBox_TextSubmitted; Loaded -= InfiniteCanvas_Loaded; } @@ -339,6 +340,7 @@ private void RegisterEvents() Application.Current.LeavingBackground += Current_LeavingBackground; _drawingSurfaceRenderer.CommandExecuted += DrawingSurfaceRenderer_CommandExecuted; _canvasComboBoxFontSizeTextBox.PreviewKeyDown += CanvasComboBoxFontSizeTextBox_PreviewKeyDown; + _canvasComboBoxFontSizeTextBox.TextSubmitted += CanvasComboBoxFontSizeTextBox_TextSubmitted; Loaded += InfiniteCanvas_Loaded; } @@ -366,7 +368,7 @@ private void ConfigureControls() SetCanvasWidthHeight(); - _canvasTextBox.UpdateFontSize(TextFontSize); + SetFontSize(_textFontSize); } private void SetZoomFactor() From 90e648c7dfbf29ca2c49d0a08fba898124447634 Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Fri, 9 Apr 2021 13:35:59 -0400 Subject: [PATCH 11/13] Allow FontSize comboox expand for larger number --- .../InfiniteCanvas/InfiniteCanvas.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml index 8530bff3be0..91214027b8f 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.xaml @@ -98,7 +98,7 @@ Date: Fri, 9 Apr 2021 14:05:00 -0400 Subject: [PATCH 12/13] No need to update font textbox text --- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index 8dfc026758b..bdfdcb25434 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -193,7 +193,6 @@ private void InkScrollViewer_PointerPressed(object sender, PointerRoutedEventArg // Updating toolbar _canvasTextBoxColorPicker.Color = SelectedTextDrawable.TextColor; - _canvasComboBoxFontSizeTextBox.Text = SelectedTextDrawable.FontSize.ToString(); _canvasTextBoxBoldButton.IsChecked = SelectedTextDrawable.IsBold; _canvasTextBoxItalicButton.IsChecked = SelectedTextDrawable.IsItalic; From 196dad90f8206b6508c8ccf1445e783ec192eac1 Mon Sep 17 00:00:00 2001 From: Rosario Pulella Date: Tue, 13 Apr 2021 16:15:38 -0400 Subject: [PATCH 13/13] Update fontsize of drawing surface on textsubmitted --- .../InfiniteCanvas/InfiniteCanvas.TextBox.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs index bdfdcb25434..6839d59e1be 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Media/InfiniteCanvas/InfiniteCanvas.TextBox.cs @@ -107,6 +107,12 @@ private void CanvasComboBoxFontSizeTextBox_TextSubmitted(ComboBox sender, ComboB if (float.TryParse(args.Text, out var size)) { SetFontSize(size); + + if (SelectedTextDrawable != null) + { + _drawingSurfaceRenderer.ExecuteUpdateTextBoxFontSize(size); + ReDrawCanvas(); + } } }