From e8fcb72fc21b30bde63e215f14efb7179ba0d8f1 Mon Sep 17 00:00:00 2001 From: heartacker Date: Fri, 22 Mar 2024 21:51:24 +0800 Subject: [PATCH 1/5] 1. fix OnFormatChange 2. support bin 3. update hex input logic --- .../NumericUpDown/NumericUpDownBase.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs index 33f496b..ac846cb 100644 --- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs +++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs @@ -176,7 +176,7 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl { if (IsInitialized) { - SyncTextAndValue(false, null); + SyncTextAndValue(false, null, true);//sync text update while OnFormatChange } } @@ -343,7 +343,11 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo if ((numberStyles & NumberStyles.AllowHexSpecifier) != 0) { - if (text.StartsWith("0X") || text.StartsWith("0x")) // support 0x hex while user input + if (text.StartsWith("0x") || text.StartsWith("0X")) // support 0x hex while user input + { + text = text.Substring(2); + } + else if (text.StartsWith("h'") || text.StartsWith("H'")) // support verilog hex while user input { text = text.Substring(2); } @@ -351,10 +355,21 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo { text = text.Substring(1); } - else if (text.StartsWith("h'") || text.StartsWith("H'")) // support hex while user input + } + else if (((int)numberStyles &/* NumberStyles.AllowBinarySpecifier */ 1027) != 0) + { + if (text.StartsWith("0b") || text.StartsWith("0B")) // support 0b bin while user input { text = text.Substring(2); } + else if (text.StartsWith("b'") || text.StartsWith("B'")) // support verilog bin while user input + { + text = text.Substring(2); + } + else if (text.StartsWith("b") || text.StartsWith("B")) // support bin while user input + { + text = text.Substring(1); + } } return text; From b576c0ce8162a11b4585496c30d2d78ef71a3fd1 Mon Sep 17 00:00:00 2001 From: heartacker Date: Fri, 22 Mar 2024 21:51:24 +0800 Subject: [PATCH 2/5] =?UTF-8?q?dotnet=208,=E4=BB=A5=E4=B8=8A=E6=89=8D?= =?UTF-8?q?=E6=9C=89=20=E8=BF=99=E4=B8=AAbin=20=E7=9A=84=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=20https://learn.microsoft.com/zh-cn/dotnet/api/system.globaliz?= =?UTF-8?q?ation.numberstyles=3Fview=3Dnet-8.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs | 7 ++++++- src/Ursa/Ursa.csproj | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs index ac846cb..598324f 100644 --- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs +++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs @@ -356,7 +356,12 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo text = text.Substring(1); } } - else if (((int)numberStyles &/* NumberStyles.AllowBinarySpecifier */ 1027) != 0) + else +#if NET8_0_OR_GREATER + if ((numberStyles & NumberStyles.AllowBinarySpecifier) != 0) +#else + if (((int)numberStyles &/* NumberStyles.AllowBinarySpecifier */ 1027) != 0) +#endif { if (text.StartsWith("0b") || text.StartsWith("0B")) // support 0b bin while user input { diff --git a/src/Ursa/Ursa.csproj b/src/Ursa/Ursa.csproj index 448ddec..1b93c54 100644 --- a/src/Ursa/Ursa.csproj +++ b/src/Ursa/Ursa.csproj @@ -3,7 +3,7 @@ - netstandard2.0 + netstandard2.0;NET8 enable enable latest From be3c76c266bc56318858571a2769b958dd7b8691 Mon Sep 17 00:00:00 2001 From: heartacker Date: Sun, 24 Mar 2024 15:48:33 +0800 Subject: [PATCH 3/5] POLISH net8 --- src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs | 7 ++----- src/Ursa/Ursa.csproj | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs index 598324f..40df9e3 100644 --- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs +++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs @@ -356,12 +356,8 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo text = text.Substring(1); } } - else #if NET8_0_OR_GREATER - if ((numberStyles & NumberStyles.AllowBinarySpecifier) != 0) -#else - if (((int)numberStyles &/* NumberStyles.AllowBinarySpecifier */ 1027) != 0) -#endif + else if ((numberStyles & NumberStyles.AllowBinarySpecifier) != 0) { if (text.StartsWith("0b") || text.StartsWith("0B")) // support 0b bin while user input { @@ -377,6 +373,7 @@ public abstract class NumericUpDownBase : NumericUpDown where T : struct, ICo } } +#endif return text; } diff --git a/src/Ursa/Ursa.csproj b/src/Ursa/Ursa.csproj index 1b93c54..c60174b 100644 --- a/src/Ursa/Ursa.csproj +++ b/src/Ursa/Ursa.csproj @@ -3,7 +3,7 @@ - netstandard2.0;NET8 + netstandard2.0;net8 enable enable latest From d6c0162253cd789baf0f25f38b9dc780cb3e0ecc Mon Sep 17 00:00:00 2001 From: heartacker Date: Sun, 24 Mar 2024 16:42:38 +0800 Subject: [PATCH 4/5] adjust demo --- demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml | 113 ++++++++++-------- .../ViewModels/NumericUpDownDemoViewModel.cs | 17 +++ 2 files changed, 78 insertions(+), 52 deletions(-) diff --git a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml index 77b0def..3ed9f60 100644 --- a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml +++ b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml @@ -6,10 +6,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:u="https://irihi.tech/ursa" xmlns:vm="using:Ursa.Demo.ViewModels" - x:DataType="vm:NumericUpDownDemoViewModel" - x:CompileBindings="True" d:DesignHeight="450" d:DesignWidth="800" + x:CompileBindings="True" + x:DataType="vm:NumericUpDownDemoViewModel" mc:Ignorable="d"> @@ -20,33 +20,35 @@ - - - - - - - + + + + + + + - - - + \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs index 9cf7651..c543bea 100644 --- a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs @@ -11,6 +11,10 @@ namespace Ursa.Demo.ViewModels; public partial class NumericUpDownDemoViewModel : ObservableObject { + + private double _oldWidth=300; + [ObservableProperty] private bool _AutoWidth = true; + [ObservableProperty] private double _Width = Double.NaN; [ObservableProperty] private uint _Value; [ObservableProperty] private string _FontFamily = "Consolas"; [ObservableProperty] private bool _AllowDrag = false; @@ -42,6 +46,19 @@ public partial class NumericUpDownDemoViewModel : ObservableObject } + partial void OnAutoWidthChanged(bool value) + { + if (value) + { + _oldWidth = Width; + Width = double.NaN; + } + else + { + Width = _oldWidth; + } + } + partial void OnValueChanging(uint oldValue, uint newValue) { Console.WriteLine(oldValue); From 278247ab7f786199cec0ed61e17e2b2769e43b1c Mon Sep 17 00:00:00 2001 From: heartacker Date: Sun, 24 Mar 2024 17:02:02 +0800 Subject: [PATCH 5/5] adjust demo --- demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml | 4 +++- demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml index 3ed9f60..5f7355d 100644 --- a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml +++ b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml @@ -26,7 +26,7 @@ +