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>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<TrimmerRootAssembly Include="Ursa.Demo" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)"/>

View File

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

View File

@@ -12,6 +12,7 @@
<ItemGroup>
<TrimmerRootDescriptor Include="Roots.xml" />
<TrimmerRootAssembly Include="Ursa.Thems.Semi" />
</ItemGroup>
<ItemGroup>
@@ -19,7 +20,7 @@
<!--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 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>

View File

@@ -16,7 +16,7 @@
<!--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 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>

View File

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

View File

@@ -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"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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;
/// </summary>
public class SemiTheme: Styles
{
private static readonly Lazy<Dictionary<CultureInfo, string>> _localeToResource = new Lazy<Dictionary<CultureInfo, string>>(
() => new Dictionary<CultureInfo, string>
private static readonly Lazy<Dictionary<CultureInfo, ResourceDictionary>> _localeToResource = new Lazy<Dictionary<CultureInfo, ResourceDictionary>>(
() => new Dictionary<CultureInfo, ResourceDictionary>
{
{ 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))
{

View File

@@ -1,4 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
x:Class="Ursa.Themes.Semi.Locale.en_us"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<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"
x:Class="Ursa.Themes.Semi.Locale.zh_cn"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<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);
private IList<EnumItemTuple>? _values;
internal IList<EnumItemTuple>? Values
public IList<EnumItemTuple>? Values
{
get => _values;
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);
private string _internalText;
internal string InternalText
public string InternalText
{
get => _internalText;
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>>(
nameof(Digits), o => o.Digits, (o, v) => o.Digits = v);
nameof(Digits), o => o.Digits);
private IList<string> _digits = [];
internal IList<string> Digits
public IList<string> Digits
{
get => _digits;
set => SetAndRaise(DigitsProperty, ref _digits, value);
private set => SetAndRaise(DigitsProperty, ref _digits, value);
}
public static readonly RoutedEvent<VerificationCodeCompleteEventArgs> CompleteEvent =