misc: version, trim, web demo.
This commit is contained in:
parent
2b37df580f
commit
d759570259
19
.github/workflows/deploy.yml
vendored
19
.github/workflows/deploy.yml
vendored
@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
PROJECT_PATH: demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
|
PROJECT_PATH: demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
|
||||||
OUTPUT_PATH: demo/Semi.Avalonia.Demo.Web/bin/Release/net7.0/browser-wasm/AppBundle
|
OUTPUT_PATH: demo/Semi.Avalonia.Demo.Web/bin/Release/net8.0-browser/publish/wwwroot
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "action/deploy" ]
|
branches: [ "action/deploy" ]
|
||||||
@ -16,19 +16,16 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.1
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Setup .NET 7
|
- name: Setup .NET 8
|
||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: 7.0.405
|
dotnet-version: 8.0.x
|
||||||
|
|
||||||
- name: Install wasm-tools
|
- name: Install wasm-tools
|
||||||
run: dotnet workload install wasm-tools wasm-tools-net7
|
run: dotnet workload install wasm-tools
|
||||||
|
|
||||||
- name: Install DotNetCompress
|
|
||||||
run: dotnet tool install --global DotNetCompress --version 3.0.0 --no-cache
|
|
||||||
|
|
||||||
- name: Publish .NET Project
|
- name: Publish .NET Project
|
||||||
run: dotnet publish $PROJECT_PATH -c Release -o release --nologo
|
run: dotnet publish $PROJECT_PATH -c Release --nologo
|
||||||
|
|
||||||
- name: Change base-tag in index.html
|
- name: Change base-tag in index.html
|
||||||
run: sed -i 's/<base href="\/" \/>/<base href="\/Semi.Avalonia\/" \/>/g' $OUTPUT_PATH/index.html
|
run: sed -i 's/<base href="\/" \/>/<base href="\/Semi.Avalonia\/" \/>/g' $OUTPUT_PATH/index.html
|
||||||
@ -36,12 +33,6 @@ jobs:
|
|||||||
- name: copy index.html to 404.html
|
- name: copy index.html to 404.html
|
||||||
run: cp $OUTPUT_PATH/index.html $OUTPUT_PATH/404.html
|
run: cp $OUTPUT_PATH/index.html $OUTPUT_PATH/404.html
|
||||||
|
|
||||||
- name: Compress Output using Brotli
|
|
||||||
run: DotNetCompress -d $OUTPUT_PATH -p "*.dll" "*.js" "*.wasm" --format br --threads 4
|
|
||||||
|
|
||||||
- name: Compress Output using GZip
|
|
||||||
run: DotNetCompress -d $OUTPUT_PATH -p "*.dll" "*.js" "*.wasm" --format gz --threads 4
|
|
||||||
|
|
||||||
- name: Add .nojekyll file
|
- name: Add .nojekyll file
|
||||||
run: touch $OUTPUT_PATH/.nojekyll
|
run: touch $OUTPUT_PATH/.nojekyll
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ jobs:
|
|||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet publish ./demo/Semi.Avalonia.Demo.Android -c Release -f net7.0-android --no-restore
|
run: dotnet publish ./demo/Semi.Avalonia.Demo.Android -c Release -f net8.0-android --no-restore
|
||||||
|
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.3.1
|
uses: actions/upload-artifact@v4.3.1
|
@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="SC-Single" type="DotNetFolderPublish" factoryName="Publish to folder">
|
<configuration default="false" name="SC-Single" type="DotNetFolderPublish" factoryName="Publish to folder">
|
||||||
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="win-x64" self_contained="true" target_folder="$PROJECT_DIR$/demo/Semi.Avalonia.Demo.Desktop/bin/Release/net7.0/win-x64/publish" target_framework="net7.0" uuid_high="3088527218258560748" uuid_low="-8649338673481336678" />
|
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="win-x64" self_contained="true" target_folder="$PROJECT_DIR$/demo/Semi.Avalonia.Demo.Desktop/bin/Release/net8.0/win-x64/publish" target_framework="net8.0" uuid_high="3088527218258560748" uuid_low="-8649338673481336678" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0-android</TargetFramework>
|
<TargetFramework>net8.0-android</TargetFramework>
|
||||||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
|
||||||
<ApplicationId>com.irihitech.Semi.Avalonia</ApplicationId>
|
<ApplicationId>com.irihitech.Semi.Avalonia</ApplicationId>
|
||||||
<ApplicationVersion>1</ApplicationVersion>
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
@ -15,11 +15,11 @@
|
|||||||
<Import Project="../Directory.Build.props" />
|
<Import Project="../Directory.Build.props" />
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
|
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
|
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
3
demo/Semi.Avalonia.Demo.Desktop/Roots.xml
Normal file
3
demo/Semi.Avalonia.Demo.Desktop/Roots.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<linker>
|
||||||
|
<assembly fullname="Semi.Avalonia.Demo" preserve="All"/>
|
||||||
|
</linker>
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<!-- Uncomment below to enable Native AOT compilation-->
|
<!-- Uncomment below to enable Native AOT compilation-->
|
||||||
@ -11,12 +11,17 @@
|
|||||||
-->
|
-->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||||
|
<IsTrimmable>true</IsTrimmable>
|
||||||
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<RdXmlFile Include="rd.xml" />
|
<TrimmerRootDescriptor Include="Roots.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Directives>
|
|
||||||
<!--
|
|
||||||
This file is part of RdXmlLibrary project.
|
|
||||||
Visit https://github.com/kant2002/rdxmllibrary for latest version.
|
|
||||||
If you have modifications specific to this Nuget package,
|
|
||||||
please contribute back.
|
|
||||||
-->
|
|
||||||
<Application>
|
|
||||||
<Assembly Name="Avalonia.Markup.Xaml" Dynamic="Required All"/>
|
|
||||||
<Assembly Name="Semi.Avalonia" Dynamic="Required All"/>
|
|
||||||
<Assembly Name="Semi.Avalonia.DataGrid" Dynamic="Required All"/>
|
|
||||||
<Assembly Name="Semi.Avalonia.ColorPicker" Dynamic="Required All"/>
|
|
||||||
<Assembly Name="Semi.Avalonia.Demo" Dynamic="Required All"/>
|
|
||||||
</Application>
|
|
||||||
</Directives>
|
|
16
demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
Normal file
16
demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Demo.Web;
|
||||||
|
|
||||||
|
public static class AvaloniaAppBuilderExtensions
|
||||||
|
{
|
||||||
|
private static string DefaultFontFamily => "avares://Semi.Avalonia.Demo.Web/Assets#Source Han Sans CN";
|
||||||
|
|
||||||
|
public static AppBuilder WithSourceHanSansCNFont(this AppBuilder builder) =>
|
||||||
|
builder.With(new FontManagerOptions
|
||||||
|
{
|
||||||
|
DefaultFamilyName = DefaultFontFamily,
|
||||||
|
FontFallbacks = new[] { new FontFallback { FontFamily = new FontFamily(DefaultFontFamily) } }
|
||||||
|
});
|
||||||
|
}
|
@ -7,9 +7,10 @@ using Avalonia.Browser;
|
|||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Web;
|
namespace Semi.Avalonia.Demo.Web;
|
||||||
|
|
||||||
internal partial class Program
|
internal sealed partial class Program
|
||||||
{
|
{
|
||||||
private static async Task Main(string[] args) => await BuildAvaloniaApp()
|
private static Task Main(string[] args) => BuildAvaloniaApp()
|
||||||
|
.WithSourceHanSansCNFont()
|
||||||
.StartBrowserAppAsync("out");
|
.StartBrowserAppAsync("out");
|
||||||
|
|
||||||
public static AppBuilder BuildAvaloniaApp()
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
|
|
||||||
<WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
|
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0-browser</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WasmExtraFilesToDeploy Include="AppBundle\**" />
|
<AvaloniaResource Include="Assets\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
|
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj" />
|
<ProjectReference Include="..\Semi.Avalonia.Demo\Semi.Avalonia.Demo.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -7,8 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
<link rel="modulepreload" href="./main.js" />
|
<link rel="modulepreload" href="./main.js" />
|
||||||
<link rel="modulepreload" href="./dotnet.js" />
|
<link rel="modulepreload" href="./_framework/dotnet.js" />
|
||||||
<link rel="modulepreload" href="./avalonia.js" />
|
<link rel="modulepreload" href="./_framework/avalonia.js" />
|
||||||
<link rel="stylesheet" href="./app.css" />
|
<link rel="stylesheet" href="./app.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { dotnet } from './dotnet.js'
|
import { dotnet } from './_framework/dotnet.js'
|
||||||
|
|
||||||
const is_browser = typeof window != "undefined";
|
const is_browser = typeof window != "undefined";
|
||||||
if (!is_browser) throw new Error(`Expected to be running in a browser`);
|
if (!is_browser) throw new Error(`Expected to be running in a browser`);
|
||||||
@ -10,4 +10,4 @@ const dotnetRuntime = await dotnet
|
|||||||
|
|
||||||
const config = dotnetRuntime.getConfig();
|
const config = dotnetRuntime.getConfig();
|
||||||
|
|
||||||
await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search]);
|
await dotnetRuntime.runMain(config.mainAssemblyName, [window.location.search]);
|
@ -1,5 +0,0 @@
|
|||||||
<linker>
|
|
||||||
<!-- Can be removed if CompiledBinding and no reflection are used -->
|
|
||||||
<assembly fullname="Semi.Avalonia.Demo" preserve="All" />
|
|
||||||
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
|
|
||||||
</linker>
|
|
@ -4,10 +4,9 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
<TrimmerRootDescriptor Include="Roots.xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -19,8 +18,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia.ColorPicker\Semi.Avalonia.ColorPicker.csproj" />
|
<ProjectReference Include="..\..\src\Semi.Avalonia.ColorPicker\Semi.Avalonia.ColorPicker.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia.DataGrid\Semi.Avalonia.DataGrid.csproj" />
|
<ProjectReference Include="..\..\src\Semi.Avalonia.DataGrid\Semi.Avalonia.DataGrid.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia\Semi.Avalonia.csproj" />
|
<ProjectReference Include="..\..\src\Semi.Avalonia\Semi.Avalonia.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -47,8 +47,8 @@ public class PaletteDemoViewModel: ObservableObject
|
|||||||
|
|
||||||
public PaletteDemoViewModel()
|
public PaletteDemoViewModel()
|
||||||
{
|
{
|
||||||
_lightResourceDictionary = AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Light/Palette.axaml")) as ResourceDictionary;
|
_lightResourceDictionary = new Light.Palette();
|
||||||
_darkResourceDictionary = AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Dark/Palette.axaml")) as ResourceDictionary;
|
_darkResourceDictionary = new Dark.Palette();
|
||||||
WeakReferenceMessenger.Default.Register<PaletteDemoViewModel, ColorItemViewModel>(this, OnClickColorItem);
|
WeakReferenceMessenger.Default.Register<PaletteDemoViewModel, ColorItemViewModel>(this, OnClickColorItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "7.0.0",
|
"version": "8.0.0",
|
||||||
"rollForward": "latestMajor",
|
"rollForward": "latestMajor",
|
||||||
"allowPrerelease": true
|
"allowPrerelease": true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net8.0;netstandard2.0</TargetFrameworks>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Version>11.0.7.4</Version>
|
<Version>11.0.7.4</Version>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.ColorPicker/Light.axaml" />
|
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.ColorPicker/Light.axaml" />
|
||||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.ColorPicker/Dark.axaml" />
|
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.ColorPicker/Dark.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml" />
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||||
|
<IsAotCompatible>true</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||||
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)"/>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.DataGrid/Light.axaml" />
|
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.DataGrid/Light.axaml" />
|
||||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.DataGrid/Dark.axaml" />
|
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.DataGrid/Dark.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia.DataGrid/DataGrid.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia.DataGrid/DataGrid.axaml" />
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<Import Project="../Package.props"/>
|
<Import Project="../Package.props"/>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Title>Semi.Avalonia.DataGrid</Title>
|
<Title>Semi.Avalonia.DataGrid</Title>
|
||||||
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||||
|
<IsAotCompatible>true</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)"/>
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
<AvaloniaVersion>11.0.0</AvaloniaVersion>
|
<AvaloniaVersion>11.0.0</AvaloniaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||||
|
<IsAotCompatible>true</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia.Controls.TreeDataGrid" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia.Controls.TreeDataGrid" Version="$(AvaloniaVersion)"/>
|
||||||
<None Include="irihi.png" Pack="true" PackagePath=""/>
|
<None Include="irihi.png" Pack="true" PackagePath=""/>
|
||||||
|
8
src/Semi.Avalonia/Locale/en-us.axaml.cs
Normal file
8
src/Semi.Avalonia/Locale/en-us.axaml.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Locale;
|
||||||
|
|
||||||
|
public class en_us: ResourceDictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
8
src/Semi.Avalonia/Locale/zh-cn.axaml.cs
Normal file
8
src/Semi.Avalonia/Locale/zh-cn.axaml.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Locale;
|
||||||
|
|
||||||
|
public class zh_cn: ResourceDictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -7,6 +7,10 @@
|
|||||||
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
<PackageReleaseNotes>Update to 11.0.7</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||||
|
<IsAotCompatible>true</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary x:Class="Semi.Avalonia.Dark.Palette" xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<!-- Color Resources -->
|
<!-- Color Resources -->
|
||||||
<Color x:Key="SemiRed0Color">#6C090B</Color>
|
<Color x:Key="SemiRed0Color">#6C090B</Color>
|
||||||
<Color x:Key="SemiRed1Color">#901110</Color>
|
<Color x:Key="SemiRed1Color">#901110</Color>
|
||||||
|
9
src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs
Normal file
9
src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Dark;
|
||||||
|
|
||||||
|
public class Palette: ResourceDictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -2,8 +2,8 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary x:Class="Semi.Avalonia.Light.Palette" xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<!-- Color Resources -->
|
<!-- Color Resources -->
|
||||||
<Color x:Key="SemiRed0Color">#FEF2ED</Color>
|
<Color x:Key="SemiRed0Color">#FEF2ED</Color>
|
||||||
<Color x:Key="SemiRed1Color">#FEDDD2</Color>
|
<Color x:Key="SemiRed1Color">#FEDDD2</Color>
|
||||||
|
9
src/Semi.Avalonia/Themes/Light/Palette.axaml.cs
Normal file
9
src/Semi.Avalonia/Themes/Light/Palette.axaml.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Light;
|
||||||
|
|
||||||
|
public class Palette: ResourceDictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -2,8 +2,8 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
||||||
|
@ -4,15 +4,16 @@ using System.Globalization;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
|
using Semi.Avalonia.Locale;
|
||||||
|
|
||||||
namespace Semi.Avalonia;
|
namespace Semi.Avalonia;
|
||||||
|
|
||||||
public class SemiTheme: Styles
|
public class SemiTheme: Styles
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<CultureInfo, string> _localeToResource = new()
|
private static readonly Dictionary<CultureInfo, ResourceDictionary> _localeToResource = new()
|
||||||
{
|
{
|
||||||
{ new CultureInfo("zh-CN"), "avares://Semi.Avalonia/Locale/zh-CN.axaml" },
|
{ new CultureInfo("zh-cn"), new zh_cn() },
|
||||||
{ new CultureInfo("en-US"), "avares://Semi.Avalonia/Locale/en-US.axaml" },
|
{ new CultureInfo("en-us"), new en_us() },
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly IServiceProvider? sp;
|
private readonly IServiceProvider? sp;
|
||||||
@ -30,26 +31,24 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string TryGetLocaleResource(CultureInfo? locale)
|
private static ResourceDictionary? TryGetLocaleResource(CultureInfo? locale)
|
||||||
{
|
{
|
||||||
if (locale is null)
|
if (locale is null)
|
||||||
{
|
{
|
||||||
return _localeToResource[new CultureInfo("zh-CN")];
|
return _localeToResource[new CultureInfo("zh-cn")];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_localeToResource.TryGetValue(locale, out var resource))
|
if (_localeToResource.TryGetValue(locale, out var resource))
|
||||||
{
|
{
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
return _localeToResource[new CultureInfo("zh-CN")];
|
return _localeToResource[new CultureInfo("zh-cn")];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user