From 34ca98eedebb8d50fc8758b6734615d515d0e0da Mon Sep 17 00:00:00 2001 From: rabbitism Date: Mon, 22 Jul 2024 15:32:05 +0800 Subject: [PATCH 1/3] feat: try to fix trimming issue. --- .../Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj | 6 +++++- demo/Ursa.Demo/Roots.xml | 1 - demo/Ursa.Demo/Ursa.Demo.csproj | 3 ++- .../Ursa.PrismDialogDemo.csproj | 2 +- .../Ursa.PrismExtension.csproj | 2 +- .../Controls/DateRangePicker.axaml | 2 +- .../Controls/NumericUpDown.axaml | 6 +++--- src/Ursa.Themes.Semi/Controls/TimePicker.axaml | 2 +- .../Controls/TimeRangePicker.axaml | 3 ++- .../Controls/TreeComboBox.axaml | 2 +- src/Ursa.Themes.Semi/Index.axaml | 4 ++-- src/Ursa.Themes.Semi/Index.axaml.cs | 18 +++++++++--------- src/Ursa.Themes.Semi/Locale/en-us.axaml | 1 + src/Ursa.Themes.Semi/Locale/en-us.axaml.cs | 8 ++++++++ src/Ursa.Themes.Semi/Locale/zh-cn.axaml | 1 + src/Ursa.Themes.Semi/Locale/zh-cn.axaml.cs | 8 ++++++++ src/Ursa/Controls/EnumSelector/EnumSelector.cs | 2 +- .../NumberDisplayer/NumberDisplayerBase.cs | 2 +- .../VerificationCode/VerificationCode.cs | 6 +++--- 19 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 src/Ursa.Themes.Semi/Locale/en-us.axaml.cs create mode 100644 src/Ursa.Themes.Semi/Locale/zh-cn.axaml.cs diff --git a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj index 6566753..ca92927 100644 --- a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj +++ b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj @@ -6,12 +6,16 @@ net8.0 enable true - false + true app.manifest + + + + diff --git a/demo/Ursa.Demo/Roots.xml b/demo/Ursa.Demo/Roots.xml index 43bb5f4..393d98f 100644 --- a/demo/Ursa.Demo/Roots.xml +++ b/demo/Ursa.Demo/Roots.xml @@ -1,5 +1,4 @@  - diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj index e95fe55..b537deb 100644 --- a/demo/Ursa.Demo/Ursa.Demo.csproj +++ b/demo/Ursa.Demo/Ursa.Demo.csproj @@ -12,6 +12,7 @@ + @@ -19,7 +20,7 @@ - + diff --git a/demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.csproj b/demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.csproj index d5c5446..5c4eaec 100644 --- a/demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.csproj +++ b/demo/Ursa.PrismDialogDemo/Ursa.PrismDialogDemo.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Ursa.PrismExtension/Ursa.PrismExtension.csproj b/src/Ursa.PrismExtension/Ursa.PrismExtension.csproj index 52fc627..071d1bc 100644 --- a/src/Ursa.PrismExtension/Ursa.PrismExtension.csproj +++ b/src/Ursa.PrismExtension/Ursa.PrismExtension.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net8.0 0.3.0-beta20240226 enable IRIHI Technology Co., Ltd. diff --git a/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml b/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml index 72cc4c9..1ec994c 100644 --- a/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml +++ b/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml @@ -59,7 +59,7 @@ Name="ClearButton" Grid.Column="3" Padding="8,0" - Command="{Binding $parent[contracts:IClearControl].Clear}" + Command="{Binding $parent[u:DateRangePicker].Clear}" Content="{DynamicResource IconButtonClearData}" Focusable="False" IsVisible="False" diff --git a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml index 1efd0a2..31824c8 100644 --- a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml +++ b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml @@ -25,8 +25,8 @@ - - + + @@ -44,7 +44,7 @@ diff --git a/src/Ursa.Themes.Semi/Index.axaml b/src/Ursa.Themes.Semi/Index.axaml index 92b8e18..f22145c 100644 --- a/src/Ursa.Themes.Semi/Index.axaml +++ b/src/Ursa.Themes.Semi/Index.axaml @@ -2,8 +2,8 @@ - - + + diff --git a/src/Ursa.Themes.Semi/Index.axaml.cs b/src/Ursa.Themes.Semi/Index.axaml.cs index eec6fa7..9151917 100644 --- a/src/Ursa.Themes.Semi/Index.axaml.cs +++ b/src/Ursa.Themes.Semi/Index.axaml.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.Styling; +using Ursa.Themes.Semi.Locale; namespace Ursa.Themes.Semi; @@ -10,14 +11,14 @@ namespace Ursa.Themes.Semi; /// public class SemiTheme: Styles { - private static readonly Lazy> _localeToResource = new Lazy>( - () => new Dictionary + private static readonly Lazy> _localeToResource = new Lazy>( + () => new Dictionary { - { new CultureInfo("zh-CN"), "avares://Ursa.Themes.Semi/Locale/zh-CN.axaml" }, - { new CultureInfo("en-US"), "avares://Ursa.Themes.Semi/Locale/en-US.axaml" }, + { new CultureInfo("zh-CN"), new zh_cn() }, + { new CultureInfo("en-US"), new en_us() }, }); - private static readonly string _defaultResource = "avares://Ursa.Themes.Semi/Locale/zh-CN.axaml"; + private static readonly ResourceDictionary _defaultResource = new zh_cn(); private readonly IServiceProvider? sp; public SemiTheme(IServiceProvider? provider = null) @@ -36,9 +37,8 @@ public class SemiTheme: Styles { _locale = value; var resource = TryGetLocaleResource(value); - var d = AvaloniaXamlLoader.Load(sp, new Uri(resource)) as ResourceDictionary; - if (d is null) return; - foreach (var kv in d) + if (resource is null) return; + foreach (var kv in resource) { this.Resources.Add(kv); } @@ -51,7 +51,7 @@ public class SemiTheme: Styles } } - private static string TryGetLocaleResource(CultureInfo? locale) + private static ResourceDictionary? TryGetLocaleResource(CultureInfo? locale) { if (Equals(locale, CultureInfo.InvariantCulture)) { diff --git a/src/Ursa.Themes.Semi/Locale/en-us.axaml b/src/Ursa.Themes.Semi/Locale/en-us.axaml index 5f2389b..feb80a4 100644 --- a/src/Ursa.Themes.Semi/Locale/en-us.axaml +++ b/src/Ursa.Themes.Semi/Locale/en-us.axaml @@ -1,4 +1,5 @@  Bring to Front diff --git a/src/Ursa.Themes.Semi/Locale/en-us.axaml.cs b/src/Ursa.Themes.Semi/Locale/en-us.axaml.cs new file mode 100644 index 0000000..896620e --- /dev/null +++ b/src/Ursa.Themes.Semi/Locale/en-us.axaml.cs @@ -0,0 +1,8 @@ +using Avalonia.Controls; + +namespace Ursa.Themes.Semi.Locale; + +public class en_us: ResourceDictionary +{ + +} \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Locale/zh-cn.axaml b/src/Ursa.Themes.Semi/Locale/zh-cn.axaml index 94d2f9e..bd068cd 100644 --- a/src/Ursa.Themes.Semi/Locale/zh-cn.axaml +++ b/src/Ursa.Themes.Semi/Locale/zh-cn.axaml @@ -1,4 +1,5 @@  置于顶层 diff --git a/src/Ursa.Themes.Semi/Locale/zh-cn.axaml.cs b/src/Ursa.Themes.Semi/Locale/zh-cn.axaml.cs new file mode 100644 index 0000000..7d5b9fc --- /dev/null +++ b/src/Ursa.Themes.Semi/Locale/zh-cn.axaml.cs @@ -0,0 +1,8 @@ +using Avalonia.Controls; + +namespace Ursa.Themes.Semi.Locale; + +public class zh_cn: ResourceDictionary +{ + +} \ No newline at end of file diff --git a/src/Ursa/Controls/EnumSelector/EnumSelector.cs b/src/Ursa/Controls/EnumSelector/EnumSelector.cs index 6c48970..2fb8733 100644 --- a/src/Ursa/Controls/EnumSelector/EnumSelector.cs +++ b/src/Ursa/Controls/EnumSelector/EnumSelector.cs @@ -64,7 +64,7 @@ public class EnumSelector: TemplatedControl nameof(Values), o => o.Values); private IList? _values; - internal IList? Values + public IList? Values { get => _values; private set => SetAndRaise(ValuesProperty, ref _values, value); diff --git a/src/Ursa/Controls/NumberDisplayer/NumberDisplayerBase.cs b/src/Ursa/Controls/NumberDisplayer/NumberDisplayerBase.cs index 25e817d..b8b174b 100644 --- a/src/Ursa/Controls/NumberDisplayer/NumberDisplayerBase.cs +++ b/src/Ursa/Controls/NumberDisplayer/NumberDisplayerBase.cs @@ -12,7 +12,7 @@ public abstract class NumberDisplayerBase : TemplatedControl nameof(InternalText), o => o.InternalText, (o, v) => o.InternalText = v); private string _internalText; - internal string InternalText + public string InternalText { get => _internalText; set => SetAndRaise(InternalTextProperty, ref _internalText, value); diff --git a/src/Ursa/Controls/VerificationCode/VerificationCode.cs b/src/Ursa/Controls/VerificationCode/VerificationCode.cs index 0a82576..3fcfa46 100644 --- a/src/Ursa/Controls/VerificationCode/VerificationCode.cs +++ b/src/Ursa/Controls/VerificationCode/VerificationCode.cs @@ -59,13 +59,13 @@ public class VerificationCode: TemplatedControl } public static readonly DirectProperty> DigitsProperty = AvaloniaProperty.RegisterDirect>( - nameof(Digits), o => o.Digits, (o, v) => o.Digits = v); + nameof(Digits), o => o.Digits); private IList _digits = []; - internal IList Digits + public IList Digits { get => _digits; - set => SetAndRaise(DigitsProperty, ref _digits, value); + private set => SetAndRaise(DigitsProperty, ref _digits, value); } public static readonly RoutedEvent CompleteEvent = From eb797a944040c3b7fbf0dabedf102b66c39f2e05 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Mon, 22 Jul 2024 15:59:54 +0800 Subject: [PATCH 2/3] feat: add compile binding. --- demo/Ursa.Demo/Ursa.Demo.csproj | 1 - .../Controls/DateRangePicker.axaml | 11 +++++----- src/Ursa.Themes.Semi/Controls/Divider.axaml | 21 ++++++++++++++----- .../Controls/MessageBox.axaml | 2 +- .../Controls/RangeSlider.axaml | 8 +++---- src/Ursa.Themes.Semi/Controls/TagInput.axaml | 2 +- .../ControlClassesInput.cs | 2 +- src/Ursa/Controls/NavMenu/NavMenuItem.cs | 2 +- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj index b537deb..15eefb0 100644 --- a/demo/Ursa.Demo/Ursa.Demo.csproj +++ b/demo/Ursa.Demo/Ursa.Demo.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml b/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml index 1ec994c..74fcf4e 100644 --- a/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml +++ b/src/Ursa.Themes.Semi/Controls/DateRangePicker.axaml @@ -2,7 +2,8 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:contracts="https://irihi.tech/shared" - xmlns:u="https://irihi.tech/ursa"> + xmlns:u="https://irihi.tech/ursa" + x:CompileBindings="True"> @@ -68,9 +69,9 @@ Name="{x:Static u:DateRangePicker.PART_Button}" Grid.Column="3" Padding="8,0" - IsVisible="{Binding !#ClearButton.IsVisible}" Content="{DynamicResource CalendarDatePickerIconGlyph}" Focusable="False" + IsVisible="{Binding !#ClearButton.IsVisible}" Theme="{DynamicResource InnerIconButton}" /> @@ -144,7 +145,7 @@ diff --git a/src/Ursa.Themes.Semi/Controls/Divider.axaml b/src/Ursa.Themes.Semi/Controls/Divider.axaml index 9b4af1c..2469b3b 100644 --- a/src/Ursa.Themes.Semi/Controls/Divider.axaml +++ b/src/Ursa.Themes.Semi/Controls/Divider.axaml @@ -30,7 +30,6 @@ - @@ -48,7 +47,10 @@ Height="{TemplateBinding Height}" ColumnDefinitions="Auto,Auto,*"> - + @@ -62,7 +64,10 @@ Height="{TemplateBinding Height}" ColumnDefinitions="*,Auto,Auto"> - + @@ -76,7 +81,10 @@ Height="{TemplateBinding Height}" ColumnDefinitions="*,Auto,*"> - + @@ -90,7 +98,10 @@ Height="{TemplateBinding Height}" ColumnDefinitions="*,Auto,*"> - + diff --git a/src/Ursa.Themes.Semi/Controls/MessageBox.axaml b/src/Ursa.Themes.Semi/Controls/MessageBox.axaml index ad58ead..ae2e07a 100644 --- a/src/Ursa.Themes.Semi/Controls/MessageBox.axaml +++ b/src/Ursa.Themes.Semi/Controls/MessageBox.axaml @@ -248,7 +248,7 @@ - + diff --git a/src/Ursa/Controls/ControlClassesInput/ControlClassesInput.cs b/src/Ursa/Controls/ControlClassesInput/ControlClassesInput.cs index 78cf60d..a9251d9 100644 --- a/src/Ursa/Controls/ControlClassesInput/ControlClassesInput.cs +++ b/src/Ursa/Controls/ControlClassesInput/ControlClassesInput.cs @@ -39,7 +39,7 @@ public class ControlClassesInput: TemplatedControl internal static readonly DirectProperty> TargetClassesProperty = AvaloniaProperty.RegisterDirect>( nameof(TargetClasses), o => o.TargetClasses, (o, v) => o.TargetClasses = v); - internal ObservableCollection TargetClasses + public ObservableCollection TargetClasses { get => _targetClasses; set => SetAndRaise(TargetClassesProperty, ref _targetClasses, value); diff --git a/src/Ursa/Controls/NavMenu/NavMenuItem.cs b/src/Ursa/Controls/NavMenu/NavMenuItem.cs index eed50bf..fc39aa7 100644 --- a/src/Ursa/Controls/NavMenu/NavMenuItem.cs +++ b/src/Ursa/Controls/NavMenu/NavMenuItem.cs @@ -124,7 +124,7 @@ public class NavMenuItem: HeaderedItemsControl internal static readonly DirectProperty LevelProperty = AvaloniaProperty.RegisterDirect( nameof(Level), o => o.Level, (o, v) => o.Level = v); private int _level; - internal int Level + public int Level { get => _level; set => SetAndRaise(LevelProperty, ref _level, value); From 25d6a00be1e1a7b95276667a1516e0e890285ae8 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Mon, 22 Jul 2024 16:17:50 +0800 Subject: [PATCH 3/3] feat: add compile binding to theme. --- .../Ursa.Demo.Browser.csproj | 2 ++ demo/Ursa.Demo/Pages/AvatarDemo.axaml | 2 ++ demo/Ursa.Demo/Pages/BannerDemo.axaml | 1 + demo/Ursa.Demo/Pages/IntroductionDemo.axaml | 1 + demo/Ursa.Demo/Pages/PaginationDemo.axaml | 1 + demo/Ursa.Demo/Pages/TimelineDemo.axaml | 26 +++++++++---------- demo/Ursa.Demo/Ursa.Demo.csproj | 2 +- src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj | 1 + 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj b/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj index a1b75b7..5f6658e 100644 --- a/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj +++ b/demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj @@ -5,7 +5,9 @@ + diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 1a07543..861960f 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -4,6 +4,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:u="https://irihi.tech/ursa" xmlns:vm="clr-namespace:Ursa.Demo.ViewModels" + x:CompileBindings="True" + x:DataType="vm:AvatarDemoViewModel" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Ursa.Demo.Pages.AvatarDemo"> diff --git a/demo/Ursa.Demo/Pages/BannerDemo.axaml b/demo/Ursa.Demo/Pages/BannerDemo.axaml index d7a275e..91c8f89 100644 --- a/demo/Ursa.Demo/Pages/BannerDemo.axaml +++ b/demo/Ursa.Demo/Pages/BannerDemo.axaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:pages="clr-namespace:Ursa.Demo.Pages" xmlns:u="https://irihi.tech/ursa" + x:DataType="pages:BannerDemoViewModel" mc:Ignorable="d"> diff --git a/demo/Ursa.Demo/Pages/IntroductionDemo.axaml b/demo/Ursa.Demo/Pages/IntroductionDemo.axaml index 3e4c490..ba2bbbf 100644 --- a/demo/Ursa.Demo/Pages/IntroductionDemo.axaml +++ b/demo/Ursa.Demo/Pages/IntroductionDemo.axaml @@ -7,6 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:u="https://irihi.tech/ursa" xmlns:vm="using:Ursa.Demo.ViewModels" + x:DataType="vm:IntroductionDemoViewModel" d:DesignHeight="800" d:DesignWidth="1600" mc:Ignorable="d"> diff --git a/demo/Ursa.Demo/Pages/PaginationDemo.axaml b/demo/Ursa.Demo/Pages/PaginationDemo.axaml index 77b537e..a90dfbe 100644 --- a/demo/Ursa.Demo/Pages/PaginationDemo.axaml +++ b/demo/Ursa.Demo/Pages/PaginationDemo.axaml @@ -8,6 +8,7 @@ xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels" d:DesignHeight="450" d:DesignWidth="800" + x:DataType="viewModels:PaginationDemoViewModel" mc:Ignorable="d"> diff --git a/demo/Ursa.Demo/Pages/TimelineDemo.axaml b/demo/Ursa.Demo/Pages/TimelineDemo.axaml index 262ac3e..21e4620 100644 --- a/demo/Ursa.Demo/Pages/TimelineDemo.axaml +++ b/demo/Ursa.Demo/Pages/TimelineDemo.axaml @@ -9,7 +9,7 @@ xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels" d:DesignHeight="450" d:DesignWidth="800" - x:CompileBindings="True" + x:CompileBindings="False" x:DataType="viewModels:TimelineDemoViewModel" mc:Ignorable="d"> @@ -27,33 +27,33 @@ + TimeMemberBinding="{Binding Time}" > + TimeMemberBinding="{Binding Time}" > + TimeMemberBinding="{Binding Time}" > net8.0 enable latest - false + true diff --git a/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj b/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj index 3b663c6..c950a66 100644 --- a/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj +++ b/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj @@ -13,6 +13,7 @@ irihi.png MIT https://github.com/irihitech/Ursa.Avalonia + true