From d75957025901e4510ca6177434fb8453f7f33bda Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Fri, 19 Jul 2024 10:44:09 +0800
Subject: [PATCH] misc: version, trim, web demo.
---
.github/workflows/deploy.yml | 19 +++++-------------
.github/workflows/{Pack.yml => pack.yml} | 2 +-
.run/SC-Single.run.xml | 2 +-
.../Semi.Avalonia.Demo.Android.csproj | 8 ++++----
demo/Semi.Avalonia.Demo.Desktop/Roots.xml | 3 +++
.../Semi.Avalonia.Demo.Desktop.csproj | 11 +++++++---
demo/Semi.Avalonia.Demo.Desktop/rd.xml | 16 ---------------
.../AvaloniaAppBuilderExtensions.cs | 16 +++++++++++++++
demo/Semi.Avalonia.Demo.Web/Program.cs | 5 +++--
.../Semi.Avalonia.Demo.Web.csproj | 12 +++++------
.../{AppBundle => wwwroot}/Logo.svg | 0
.../{AppBundle => wwwroot}/app.css | 0
.../{AppBundle => wwwroot}/favicon.ico | Bin
.../{AppBundle => wwwroot}/index.html | 4 ++--
.../{AppBundle => wwwroot}/main.js | 4 ++--
demo/Semi.Avalonia.Demo/Roots.xml | 5 -----
.../Semi.Avalonia.Demo.csproj | 9 ++++-----
.../ViewModels/PaletteDemoViewModel.cs | 4 ++--
global.json | 2 +-
src/Package.props | 2 +-
src/Semi.Avalonia.ColorPicker/Index.axaml | 4 ++--
.../Semi.Avalonia.ColorPicker.csproj | 4 ++++
src/Semi.Avalonia.DataGrid/Index.axaml | 4 ++--
.../Semi.Avalonia.DataGrid.csproj | 6 +++++-
.../Semi.Avalonia.TreeDataGrid.csproj | 4 ++++
src/Semi.Avalonia/Locale/en-us.axaml.cs | 8 ++++++++
src/Semi.Avalonia/Locale/zh-cn.axaml.cs | 8 ++++++++
src/Semi.Avalonia/Semi.Avalonia.csproj | 4 ++++
src/Semi.Avalonia/Themes/Dark/Palette.axaml | 2 +-
.../Themes/Dark/Palette.axaml.cs | 9 +++++++++
src/Semi.Avalonia/Themes/Index.axaml | 4 ++--
src/Semi.Avalonia/Themes/Light/Palette.axaml | 2 +-
.../Themes/Light/Palette.axaml.cs | 9 +++++++++
src/Semi.Avalonia/Themes/SemiTheme.axaml | 4 ++--
src/Semi.Avalonia/Themes/SemiTheme.axaml.cs | 19 +++++++++---------
35 files changed, 128 insertions(+), 87 deletions(-)
rename .github/workflows/{Pack.yml => pack.yml} (97%)
create mode 100644 demo/Semi.Avalonia.Demo.Desktop/Roots.xml
delete mode 100644 demo/Semi.Avalonia.Demo.Desktop/rd.xml
create mode 100644 demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
rename demo/Semi.Avalonia.Demo.Web/{AppBundle => wwwroot}/Logo.svg (100%)
rename demo/Semi.Avalonia.Demo.Web/{AppBundle => wwwroot}/app.css (100%)
rename demo/Semi.Avalonia.Demo.Web/{AppBundle => wwwroot}/favicon.ico (100%)
rename demo/Semi.Avalonia.Demo.Web/{AppBundle => wwwroot}/index.html (86%)
rename demo/Semi.Avalonia.Demo.Web/{AppBundle => wwwroot}/main.js (69%)
delete mode 100644 demo/Semi.Avalonia.Demo/Roots.xml
create mode 100644 src/Semi.Avalonia/Locale/en-us.axaml.cs
create mode 100644 src/Semi.Avalonia/Locale/zh-cn.axaml.cs
create mode 100644 src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs
create mode 100644 src/Semi.Avalonia/Themes/Light/Palette.axaml.cs
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index ba56bfb..16165d3 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
env:
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:
push:
branches: [ "action/deploy" ]
@@ -16,19 +16,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4.1.1
- - name: Setup .NET 7
+ - name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 7.0.405
+ dotnet-version: 8.0.x
- name: Install wasm-tools
- run: dotnet workload install wasm-tools wasm-tools-net7
-
- - name: Install DotNetCompress
- run: dotnet tool install --global DotNetCompress --version 3.0.0 --no-cache
+ run: dotnet workload install wasm-tools
- 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
run: sed -i 's///g' $OUTPUT_PATH/index.html
@@ -36,12 +33,6 @@ jobs:
- name: copy index.html to 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
run: touch $OUTPUT_PATH/.nojekyll
diff --git a/.github/workflows/Pack.yml b/.github/workflows/pack.yml
similarity index 97%
rename from .github/workflows/Pack.yml
rename to .github/workflows/pack.yml
index 6987468..5f0a4b5 100644
--- a/.github/workflows/Pack.yml
+++ b/.github/workflows/pack.yml
@@ -49,7 +49,7 @@ jobs:
run: dotnet restore
- 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
uses: actions/upload-artifact@v4.3.1
diff --git a/.run/SC-Single.run.xml b/.run/SC-Single.run.xml
index 1629fa5..269629d 100644
--- a/.run/SC-Single.run.xml
+++ b/.run/SC-Single.run.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/demo/Semi.Avalonia.Demo.Android/Semi.Avalonia.Demo.Android.csproj b/demo/Semi.Avalonia.Demo.Android/Semi.Avalonia.Demo.Android.csproj
index 47a4269..1d0eada 100644
--- a/demo/Semi.Avalonia.Demo.Android/Semi.Avalonia.Demo.Android.csproj
+++ b/demo/Semi.Avalonia.Demo.Android/Semi.Avalonia.Demo.Android.csproj
@@ -1,7 +1,7 @@
Exe
- net7.0-android
+ net8.0-android
21
com.irihitech.Semi.Avalonia
1
@@ -15,11 +15,11 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/demo/Semi.Avalonia.Demo.Desktop/Roots.xml b/demo/Semi.Avalonia.Demo.Desktop/Roots.xml
new file mode 100644
index 0000000..7e2f055
--- /dev/null
+++ b/demo/Semi.Avalonia.Demo.Desktop/Roots.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj b/demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
index 4e0ff0e..d5a8648 100644
--- a/demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
+++ b/demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
@@ -1,7 +1,7 @@
WinExe
- net7.0
+ net8.0
enable
true
@@ -11,12 +11,17 @@
-->
+
+ true
+ true
+
+
app.manifest
-
+
-
+
diff --git a/demo/Semi.Avalonia.Demo.Desktop/rd.xml b/demo/Semi.Avalonia.Demo.Desktop/rd.xml
deleted file mode 100644
index 0133190..0000000
--- a/demo/Semi.Avalonia.Demo.Desktop/rd.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs b/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
new file mode 100644
index 0000000..2d5a50f
--- /dev/null
+++ b/demo/Semi.Avalonia.Demo.Web/AvaloniaAppBuilderExtensions.cs
@@ -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) } }
+ });
+}
\ No newline at end of file
diff --git a/demo/Semi.Avalonia.Demo.Web/Program.cs b/demo/Semi.Avalonia.Demo.Web/Program.cs
index 17e83a9..62d4e94 100644
--- a/demo/Semi.Avalonia.Demo.Web/Program.cs
+++ b/demo/Semi.Avalonia.Demo.Web/Program.cs
@@ -7,9 +7,10 @@ using Avalonia.Browser;
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");
public static AppBuilder BuildAvaloniaApp()
diff --git a/demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj b/demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
index b169194..a97b8ce 100644
--- a/demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
+++ b/demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
@@ -1,20 +1,18 @@
-
+
- net7.0
- browser-wasm
- AppBundle\main.js
Exe
+ net8.0-browser
-
+
-
+
-
+
diff --git a/demo/Semi.Avalonia.Demo.Web/AppBundle/Logo.svg b/demo/Semi.Avalonia.Demo.Web/wwwroot/Logo.svg
similarity index 100%
rename from demo/Semi.Avalonia.Demo.Web/AppBundle/Logo.svg
rename to demo/Semi.Avalonia.Demo.Web/wwwroot/Logo.svg
diff --git a/demo/Semi.Avalonia.Demo.Web/AppBundle/app.css b/demo/Semi.Avalonia.Demo.Web/wwwroot/app.css
similarity index 100%
rename from demo/Semi.Avalonia.Demo.Web/AppBundle/app.css
rename to demo/Semi.Avalonia.Demo.Web/wwwroot/app.css
diff --git a/demo/Semi.Avalonia.Demo.Web/AppBundle/favicon.ico b/demo/Semi.Avalonia.Demo.Web/wwwroot/favicon.ico
similarity index 100%
rename from demo/Semi.Avalonia.Demo.Web/AppBundle/favicon.ico
rename to demo/Semi.Avalonia.Demo.Web/wwwroot/favicon.ico
diff --git a/demo/Semi.Avalonia.Demo.Web/AppBundle/index.html b/demo/Semi.Avalonia.Demo.Web/wwwroot/index.html
similarity index 86%
rename from demo/Semi.Avalonia.Demo.Web/AppBundle/index.html
rename to demo/Semi.Avalonia.Demo.Web/wwwroot/index.html
index 703ee35..8b9f68f 100644
--- a/demo/Semi.Avalonia.Demo.Web/AppBundle/index.html
+++ b/demo/Semi.Avalonia.Demo.Web/wwwroot/index.html
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/demo/Semi.Avalonia.Demo.Web/AppBundle/main.js b/demo/Semi.Avalonia.Demo.Web/wwwroot/main.js
similarity index 69%
rename from demo/Semi.Avalonia.Demo.Web/AppBundle/main.js
rename to demo/Semi.Avalonia.Demo.Web/wwwroot/main.js
index 0dbe2e4..a9de29f 100644
--- a/demo/Semi.Avalonia.Demo.Web/AppBundle/main.js
+++ b/demo/Semi.Avalonia.Demo.Web/wwwroot/main.js
@@ -1,4 +1,4 @@
-import { dotnet } from './dotnet.js'
+import { dotnet } from './_framework/dotnet.js'
const is_browser = typeof window != "undefined";
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();
-await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search]);
\ No newline at end of file
+await dotnetRuntime.runMain(config.mainAssemblyName, [window.location.search]);
diff --git a/demo/Semi.Avalonia.Demo/Roots.xml b/demo/Semi.Avalonia.Demo/Roots.xml
deleted file mode 100644
index 22c01ba..0000000
--- a/demo/Semi.Avalonia.Demo/Roots.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj
index 8b1e2c3..27d6b44 100644
--- a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj
+++ b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj
@@ -4,10 +4,9 @@
enable
latest
-
+
-
@@ -19,8 +18,8 @@
-
-
-
+
+
+
diff --git a/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs b/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs
index f772889..1646be8 100644
--- a/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs
+++ b/demo/Semi.Avalonia.Demo/ViewModels/PaletteDemoViewModel.cs
@@ -47,8 +47,8 @@ public class PaletteDemoViewModel: ObservableObject
public PaletteDemoViewModel()
{
- _lightResourceDictionary = AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Light/Palette.axaml")) as ResourceDictionary;
- _darkResourceDictionary = AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Dark/Palette.axaml")) as ResourceDictionary;
+ _lightResourceDictionary = new Light.Palette();
+ _darkResourceDictionary = new Dark.Palette();
WeakReferenceMessenger.Default.Register(this, OnClickColorItem);
}
diff --git a/global.json b/global.json
index 7cd6a1f..dad2db5 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "7.0.0",
+ "version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
diff --git a/src/Package.props b/src/Package.props
index 66cac71..faeae7d 100644
--- a/src/Package.props
+++ b/src/Package.props
@@ -1,6 +1,6 @@
- net6.0;netstandard2.0
+ net6.0;net8.0;netstandard2.0
enable
latest
11.0.7.4
diff --git a/src/Semi.Avalonia.ColorPicker/Index.axaml b/src/Semi.Avalonia.ColorPicker/Index.axaml
index 2af9525..32b0f04 100644
--- a/src/Semi.Avalonia.ColorPicker/Index.axaml
+++ b/src/Semi.Avalonia.ColorPicker/Index.axaml
@@ -2,8 +2,8 @@
-
-
+
+
diff --git a/src/Semi.Avalonia.ColorPicker/Semi.Avalonia.ColorPicker.csproj b/src/Semi.Avalonia.ColorPicker/Semi.Avalonia.ColorPicker.csproj
index b99b666..4464c41 100644
--- a/src/Semi.Avalonia.ColorPicker/Semi.Avalonia.ColorPicker.csproj
+++ b/src/Semi.Avalonia.ColorPicker/Semi.Avalonia.ColorPicker.csproj
@@ -7,6 +7,10 @@
Update to 11.0.7
+
+ true
+
+
diff --git a/src/Semi.Avalonia.DataGrid/Index.axaml b/src/Semi.Avalonia.DataGrid/Index.axaml
index 29ddeaa..4d798eb 100644
--- a/src/Semi.Avalonia.DataGrid/Index.axaml
+++ b/src/Semi.Avalonia.DataGrid/Index.axaml
@@ -2,8 +2,8 @@
-
-
+
+
diff --git a/src/Semi.Avalonia.DataGrid/Semi.Avalonia.DataGrid.csproj b/src/Semi.Avalonia.DataGrid/Semi.Avalonia.DataGrid.csproj
index c468a73..378f48d 100644
--- a/src/Semi.Avalonia.DataGrid/Semi.Avalonia.DataGrid.csproj
+++ b/src/Semi.Avalonia.DataGrid/Semi.Avalonia.DataGrid.csproj
@@ -1,12 +1,16 @@
-
+
Semi.Avalonia.DataGrid
Update to 11.0.7
+
+ true
+
+
diff --git a/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj b/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj
index 76f6dc4..7bc1a05 100644
--- a/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj
+++ b/src/Semi.Avalonia.TreeDataGrid/Semi.Avalonia.TreeDataGrid.csproj
@@ -14,6 +14,10 @@
11.0.0
+
+ true
+
+
diff --git a/src/Semi.Avalonia/Locale/en-us.axaml.cs b/src/Semi.Avalonia/Locale/en-us.axaml.cs
new file mode 100644
index 0000000..f9a9730
--- /dev/null
+++ b/src/Semi.Avalonia/Locale/en-us.axaml.cs
@@ -0,0 +1,8 @@
+using Avalonia.Controls;
+
+namespace Semi.Avalonia.Locale;
+
+public class en_us: ResourceDictionary
+{
+
+}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Locale/zh-cn.axaml.cs b/src/Semi.Avalonia/Locale/zh-cn.axaml.cs
new file mode 100644
index 0000000..530a7de
--- /dev/null
+++ b/src/Semi.Avalonia/Locale/zh-cn.axaml.cs
@@ -0,0 +1,8 @@
+using Avalonia.Controls;
+
+namespace Semi.Avalonia.Locale;
+
+public class zh_cn: ResourceDictionary
+{
+
+}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Semi.Avalonia.csproj b/src/Semi.Avalonia/Semi.Avalonia.csproj
index a03e35d..a3c0d21 100644
--- a/src/Semi.Avalonia/Semi.Avalonia.csproj
+++ b/src/Semi.Avalonia/Semi.Avalonia.csproj
@@ -7,6 +7,10 @@
Update to 11.0.7
+
+ true
+
+
diff --git a/src/Semi.Avalonia/Themes/Dark/Palette.axaml b/src/Semi.Avalonia/Themes/Dark/Palette.axaml
index 7203fa0..3bdef13 100644
--- a/src/Semi.Avalonia/Themes/Dark/Palette.axaml
+++ b/src/Semi.Avalonia/Themes/Dark/Palette.axaml
@@ -1,4 +1,4 @@
-
+
#6C090B
#901110
diff --git a/src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs b/src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs
new file mode 100644
index 0000000..196931f
--- /dev/null
+++ b/src/Semi.Avalonia/Themes/Dark/Palette.axaml.cs
@@ -0,0 +1,9 @@
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace Semi.Avalonia.Dark;
+
+public class Palette: ResourceDictionary
+{
+
+}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Themes/Index.axaml b/src/Semi.Avalonia/Themes/Index.axaml
index 701f381..2c354e6 100644
--- a/src/Semi.Avalonia/Themes/Index.axaml
+++ b/src/Semi.Avalonia/Themes/Index.axaml
@@ -2,8 +2,8 @@
-
-
+
+
diff --git a/src/Semi.Avalonia/Themes/Light/Palette.axaml b/src/Semi.Avalonia/Themes/Light/Palette.axaml
index 8ca4cf8..a4f8376 100644
--- a/src/Semi.Avalonia/Themes/Light/Palette.axaml
+++ b/src/Semi.Avalonia/Themes/Light/Palette.axaml
@@ -1,4 +1,4 @@
-
+
#FEF2ED
#FEDDD2
diff --git a/src/Semi.Avalonia/Themes/Light/Palette.axaml.cs b/src/Semi.Avalonia/Themes/Light/Palette.axaml.cs
new file mode 100644
index 0000000..e391acb
--- /dev/null
+++ b/src/Semi.Avalonia/Themes/Light/Palette.axaml.cs
@@ -0,0 +1,9 @@
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace Semi.Avalonia.Light;
+
+public class Palette: ResourceDictionary
+{
+
+}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Themes/SemiTheme.axaml b/src/Semi.Avalonia/Themes/SemiTheme.axaml
index 1b36b00..d078e7f 100644
--- a/src/Semi.Avalonia/Themes/SemiTheme.axaml
+++ b/src/Semi.Avalonia/Themes/SemiTheme.axaml
@@ -2,8 +2,8 @@
-
-
+
+
diff --git a/src/Semi.Avalonia/Themes/SemiTheme.axaml.cs b/src/Semi.Avalonia/Themes/SemiTheme.axaml.cs
index a2646cf..88268f3 100644
--- a/src/Semi.Avalonia/Themes/SemiTheme.axaml.cs
+++ b/src/Semi.Avalonia/Themes/SemiTheme.axaml.cs
@@ -4,15 +4,16 @@ using System.Globalization;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
+using Semi.Avalonia.Locale;
namespace Semi.Avalonia;
public class SemiTheme: Styles
{
- private static readonly Dictionary _localeToResource = new()
+ private static readonly Dictionary _localeToResource = new()
{
- { new CultureInfo("zh-CN"), "avares://Semi.Avalonia/Locale/zh-CN.axaml" },
- { new CultureInfo("en-US"), "avares://Semi.Avalonia/Locale/en-US.axaml" },
+ { new CultureInfo("zh-cn"), new zh_cn() },
+ { new CultureInfo("en-us"), new en_us() },
};
private readonly IServiceProvider? sp;
@@ -30,26 +31,24 @@ 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);
}
}
}
- private static string TryGetLocaleResource(CultureInfo? locale)
+ private static ResourceDictionary? TryGetLocaleResource(CultureInfo? locale)
{
if (locale is null)
{
- return _localeToResource[new CultureInfo("zh-CN")];
+ return _localeToResource[new CultureInfo("zh-cn")];
}
-
if (_localeToResource.TryGetValue(locale, out var resource))
{
return resource;
}
- return _localeToResource[new CultureInfo("zh-CN")];
+ return _localeToResource[new CultureInfo("zh-cn")];
}
}
\ No newline at end of file