feat: try to fix trimming issue.

This commit is contained in:
rabbitism
2024-07-22 15:32:05 +08:00
parent 96ec5b65de
commit 34ca98eede
19 changed files with 51 additions and 28 deletions

View File

@@ -6,12 +6,16 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault> <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<TrimmerRootAssembly Include="Ursa.Demo" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)"/> <PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)"/>

View File

@@ -1,5 +1,4 @@
<linker> <linker>
<!-- Can be removed if CompiledBinding and no reflection are used --> <!-- Can be removed if CompiledBinding and no reflection are used -->
<assembly fullname="Ursa.Demo" preserve="All" /> <assembly fullname="Ursa.Demo" preserve="All" />
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
</linker> </linker>

View File

@@ -12,6 +12,7 @@
<ItemGroup> <ItemGroup>
<TrimmerRootDescriptor Include="Roots.xml" /> <TrimmerRootDescriptor Include="Roots.xml" />
<TrimmerRootAssembly Include="Ursa.Thems.Semi" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -19,7 +20,7 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageReference Include="Semi.Avalonia" Version="11.1.0-rc2" /> <PackageReference Include="Semi.Avalonia" Version="11.1.0-rc2.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,7 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)"/> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)"/>
<PackageReference Include="Prism.DryIoc.Avalonia" Version="8.1.97.11072" /> <PackageReference Include="Prism.DryIoc.Avalonia" Version="8.1.97.11072" />
<PackageReference Include="Semi.Avalonia" Version="11.1.0-rc2" /> <PackageReference Include="Semi.Avalonia" Version="11.1.0-rc2.1" />
</ItemGroup> </ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Version>0.3.0-beta20240226</Version> <Version>0.3.0-beta20240226</Version>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Authors>IRIHI Technology Co., Ltd.</Authors> <Authors>IRIHI Technology Co., Ltd.</Authors>

View File

@@ -59,7 +59,7 @@
Name="ClearButton" Name="ClearButton"
Grid.Column="3" Grid.Column="3"
Padding="8,0" Padding="8,0"
Command="{Binding $parent[contracts:IClearControl].Clear}" Command="{Binding $parent[u:DateRangePicker].Clear}"
Content="{DynamicResource IconButtonClearData}" Content="{DynamicResource IconButtonClearData}"
Focusable="False" Focusable="False"
IsVisible="False" IsVisible="False"

View File

@@ -25,8 +25,8 @@
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="{x:Type u:NumericUpDown}" TargetType="{x:Type u:NumericUpDown}"> <ControlTheme x:Key="{x:Type u:NumericUpDown}" TargetType="{x:Type u:NumericUpDown}">
<Setter Property="NumericUpDown.VerticalContentAlignment" Value="Center" /> <Setter Property="CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" />
<Setter Property="NumericUpDown.CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" /> <Setter Property="MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}"></Setter>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="u:NumericUpDown"> <ControlTemplate TargetType="u:NumericUpDown">
<DataValidationErrors> <DataValidationErrors>
@@ -44,7 +44,7 @@
<TextBox <TextBox
Name="PART_TextBox" Name="PART_TextBox"
Height="{TemplateBinding Height}" Height="{TemplateBinding Height}"
MinHeight="{DynamicResource NumericUpDownWrapperDefaultHeight}" MinHeight="{TemplateBinding MinHeight}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
AcceptsReturn="False" AcceptsReturn="False"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"

View File

@@ -140,7 +140,7 @@
Name="ClearButton" Name="ClearButton"
Grid.Column="1" Grid.Column="1"
Padding="0,0,8,0" Padding="0,0,8,0"
Command="{Binding $parent[iri:IClearControl].Clear}" Command="{Binding $parent[u:TimePicker].Clear}"
Content="{DynamicResource IconButtonClearData}" Content="{DynamicResource IconButtonClearData}"
Focusable="False" Focusable="False"
IsVisible="False" IsVisible="False"

View File

@@ -59,7 +59,8 @@
Name="ClearButton" Name="ClearButton"
Grid.Column="3" Grid.Column="3"
Padding="8,0" Padding="8,0"
Command="{Binding $parent[iri:IClearControl].Clear}" Command="{Binding $parent[u:TimeRangePicker
].Clear}"
Content="{DynamicResource IconButtonClearData}" Content="{DynamicResource IconButtonClearData}"
Focusable="False" Focusable="False"
IsVisible="False" IsVisible="False"

View File

@@ -69,7 +69,7 @@
<Button <Button
Name="PART_ClearButton" Name="PART_ClearButton"
Grid.Column="2" Grid.Column="2"
Command="{Binding $parent[iri:IClearControl].Clear}" Command="{Binding $parent[u:TreeComboBox].Clear}"
IsVisible="False" IsVisible="False"
Theme="{DynamicResource InnerIconButton}" Theme="{DynamicResource InnerIconButton}"
Content="{DynamicResource IconButtonClearData}" /> Content="{DynamicResource IconButtonClearData}" />

View File

@@ -2,8 +2,8 @@
<Styles.Resources> <Styles.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.ThemeDictionaries> <ResourceDictionary.ThemeDictionaries>
<MergeResourceInclude x:Key="Dark" Source="./Themes/Dark/_index.axaml" /> <ResourceInclude x:Key="Dark" Source="./Themes/Dark/_index.axaml" />
<MergeResourceInclude x:Key="Light" Source="./Themes/Light/_index.axaml" /> <ResourceInclude x:Key="Light" Source="./Themes/Light/_index.axaml" />
</ResourceDictionary.ThemeDictionaries> </ResourceDictionary.ThemeDictionaries>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="../Controls/_index.axaml" /> <ResourceInclude Source="../Controls/_index.axaml" />

View File

@@ -2,6 +2,7 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Styling; using Avalonia.Styling;
using Ursa.Themes.Semi.Locale;
namespace Ursa.Themes.Semi; namespace Ursa.Themes.Semi;
@@ -10,14 +11,14 @@ namespace Ursa.Themes.Semi;
/// </summary> /// </summary>
public class SemiTheme: Styles public class SemiTheme: Styles
{ {
private static readonly Lazy<Dictionary<CultureInfo, string>> _localeToResource = new Lazy<Dictionary<CultureInfo, string>>( private static readonly Lazy<Dictionary<CultureInfo, ResourceDictionary>> _localeToResource = new Lazy<Dictionary<CultureInfo, ResourceDictionary>>(
() => new Dictionary<CultureInfo, string> () => new Dictionary<CultureInfo, ResourceDictionary>
{ {
{ new CultureInfo("zh-CN"), "avares://Ursa.Themes.Semi/Locale/zh-CN.axaml" }, { new CultureInfo("zh-CN"), new zh_cn() },
{ new CultureInfo("en-US"), "avares://Ursa.Themes.Semi/Locale/en-US.axaml" }, { 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; private readonly IServiceProvider? sp;
public SemiTheme(IServiceProvider? provider = null) public SemiTheme(IServiceProvider? provider = null)
@@ -36,9 +37,8 @@ public class SemiTheme: Styles
{ {
_locale = value; _locale = value;
var resource = TryGetLocaleResource(value); var resource = TryGetLocaleResource(value);
var d = AvaloniaXamlLoader.Load(sp, new Uri(resource)) as ResourceDictionary; if (resource is null) return;
if (d is null) return; foreach (var kv in resource)
foreach (var kv in d)
{ {
this.Resources.Add(kv); 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)) if (Equals(locale, CultureInfo.InvariantCulture))
{ {

View File

@@ -1,4 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
x:Class="Ursa.Themes.Semi.Locale.en_us"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here --> <!-- Add Resources Here -->
<x:String x:Key="STRING_MENU_BRING_TO_FRONT">Bring to Front</x:String> <x:String x:Key="STRING_MENU_BRING_TO_FRONT">Bring to Front</x:String>

View File

@@ -0,0 +1,8 @@
using Avalonia.Controls;
namespace Ursa.Themes.Semi.Locale;
public class en_us: ResourceDictionary
{
}

View File

@@ -1,4 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
x:Class="Ursa.Themes.Semi.Locale.zh_cn"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here --> <!-- Add Resources Here -->
<x:String x:Key="STRING_MENU_BRING_TO_FRONT">置于顶层</x:String> <x:String x:Key="STRING_MENU_BRING_TO_FRONT">置于顶层</x:String>

View File

@@ -0,0 +1,8 @@
using Avalonia.Controls;
namespace Ursa.Themes.Semi.Locale;
public class zh_cn: ResourceDictionary
{
}

View File

@@ -64,7 +64,7 @@ public class EnumSelector: TemplatedControl
nameof(Values), o => o.Values); nameof(Values), o => o.Values);
private IList<EnumItemTuple>? _values; private IList<EnumItemTuple>? _values;
internal IList<EnumItemTuple>? Values public IList<EnumItemTuple>? Values
{ {
get => _values; get => _values;
private set => SetAndRaise(ValuesProperty, ref _values, value); private set => SetAndRaise(ValuesProperty, ref _values, value);

View File

@@ -12,7 +12,7 @@ public abstract class NumberDisplayerBase : TemplatedControl
nameof(InternalText), o => o.InternalText, (o, v) => o.InternalText = v); nameof(InternalText), o => o.InternalText, (o, v) => o.InternalText = v);
private string _internalText; private string _internalText;
internal string InternalText public string InternalText
{ {
get => _internalText; get => _internalText;
set => SetAndRaise(InternalTextProperty, ref _internalText, value); set => SetAndRaise(InternalTextProperty, ref _internalText, value);

View File

@@ -59,13 +59,13 @@ public class VerificationCode: TemplatedControl
} }
public static readonly DirectProperty<VerificationCode, IList<string>> DigitsProperty = AvaloniaProperty.RegisterDirect<VerificationCode, IList<string>>( public static readonly DirectProperty<VerificationCode, IList<string>> DigitsProperty = AvaloniaProperty.RegisterDirect<VerificationCode, IList<string>>(
nameof(Digits), o => o.Digits, (o, v) => o.Digits = v); nameof(Digits), o => o.Digits);
private IList<string> _digits = []; private IList<string> _digits = [];
internal IList<string> Digits public IList<string> Digits
{ {
get => _digits; get => _digits;
set => SetAndRaise(DigitsProperty, ref _digits, value); private set => SetAndRaise(DigitsProperty, ref _digits, value);
} }
public static readonly RoutedEvent<VerificationCodeCompleteEventArgs> CompleteEvent = public static readonly RoutedEvent<VerificationCodeCompleteEventArgs> CompleteEvent =