mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-10 03:06:35 +08:00
Adjust Resource Structure (#771)
* chore: update GitHub Actions to use latest versions of actions. * feat: update theme resource structure and remove Schemes. * refactor: simplify locale resource handling and remove redundant code. * feat: add Light theme resource to ColorPicker and DataGrid semi themes. * feat: replace SetResources with BulkSetResources.
This commit is contained in:
4
.github/workflows/deploy.yml
vendored
4
.github/workflows/deploy.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v5
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
run: touch $OUTPUT_PATH/.nojekyll
|
||||
|
||||
- name: Commit wwwroot to GitHub Pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: gh-pages
|
||||
|
||||
4
.github/workflows/pack-nightly.yml
vendored
4
.github/workflows/pack-nightly.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Get Version
|
||||
run: |
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.IRIHI_NUGET_API_KEY }} --source irihi.tech --skip-duplicate
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: nugets
|
||||
path: nugets
|
||||
|
||||
4
.github/workflows/pack.yml
vendored
4
.github/workflows/pack.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Pack Semi.Avalonia
|
||||
if: ${{ inputs.Semi_Avalonia }}
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: nugets
|
||||
path: nugets
|
||||
|
||||
36
.github/workflows/publish.yml
vendored
36
.github/workflows/publish.yml
vendored
@@ -75,11 +75,11 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish win-x64
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.win-x64
|
||||
path: |
|
||||
@@ -91,13 +91,13 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Enable Native AOT in .csproj
|
||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||
- name: Publish win-x64 AOT
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.win-x64.NativeAOT
|
||||
path: |
|
||||
@@ -109,11 +109,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish linux-x64
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.linux-x64
|
||||
path: |
|
||||
@@ -125,13 +125,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Enable Native AOT in .csproj
|
||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||
- name: Publish linux-x64 AOT
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.linux-x64.NativeAOT
|
||||
path: |
|
||||
@@ -143,11 +143,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish linux-x64 DRM
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Drm.linux-x64
|
||||
path: |
|
||||
@@ -159,13 +159,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Enable Native AOT in .csproj
|
||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj
|
||||
- name: Publish linux-x64 AOT
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Drm.linux-x64.NativeAOT
|
||||
path: |
|
||||
@@ -177,11 +177,11 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish osx-arm64
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.osx-arm64
|
||||
path: |
|
||||
@@ -193,13 +193,13 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Enable Native AOT in .csproj
|
||||
run: sed -i '' 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||
- name: Publish osx-arm64 AOT
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Semi.Avalonia.Demo.Desktop.osx-arm64.NativeAOT
|
||||
path: |
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
- name: Install Android workload
|
||||
run: dotnet workload install android
|
||||
- name: Restore Dependencies
|
||||
@@ -219,7 +219,7 @@ jobs:
|
||||
- name: Publish Android
|
||||
run: dotnet publish demo/Semi.Avalonia.Demo.Android -c Release -f net10.0-android --no-restore -o publish /p:RuntimeIdentifier=android-arm64
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: android-arm64
|
||||
path: publish/*Signed.apk
|
||||
|
||||
4
.github/workflows/release-tag.yml
vendored
4
.github/workflows/release-tag.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
||||
needs: [ nuget,publish ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4.3.0
|
||||
- uses: actions/download-artifact@v8
|
||||
|
||||
- name: Display structure of downloaded files
|
||||
run: ls -R
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
run: ls -R
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
uses: softprops/action-gh-release@v3
|
||||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
||||
with:
|
||||
generate_release_notes: true
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<PackageReference Include="Avalonia"/>
|
||||
<PackageReference Include="Avalonia.Controls.ColorPicker"/>
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid"/>
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<!--Condition below is needed to remove AvaloniaUI.DiagnosticsSupport package from build output in Release configuration.-->
|
||||
<PackageReference Include="AvaloniaUI.DiagnosticsSupport">
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
||||
<ResourceInclude x:Key="Light" Source="Light.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
||||
<ResourceInclude x:Key="Light" Source="Light.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -4,17 +4,18 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceInclude x:Key="Default" Source="/Schemes/LightScheme.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="/Schemes/DarkScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Schemes/AquaticScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Schemes/DesertScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Schemes/DuskScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Schemes/NightSkyScheme.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Light" Source="/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="/Themes/Dark/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Controls/_index.axaml" />
|
||||
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
||||
<ResourceInclude Source="/Tokens/Variables.axaml" />
|
||||
<ResourceInclude Source="/Tokens/_index.axaml" />
|
||||
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
||||
<semi:Icons />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
[assembly: XmlnsPrefix("https://irihi.tech/semi", "semi")]
|
||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")]
|
||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")]
|
||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")]
|
||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Tokens")]
|
||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Tokens.Palette")]
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/HighContrast/Aquatic.axaml" />
|
||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/Palette/Dark.axaml" />
|
||||
<ResourceInclude Source="/Themes/Dark/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/HighContrast/Desert.axaml" />
|
||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/HighContrast/Dusk.axaml" />
|
||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/Palette/Light.axaml" />
|
||||
<ResourceInclude Source="/Themes/Light/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Tokens/HighContrast/NightSky.axaml" />
|
||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -5,19 +5,20 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceInclude x:Key="Default" Source="/Schemes/LightScheme.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="/Schemes/DarkScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Schemes/AquaticScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Schemes/DesertScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Schemes/DuskScheme.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Schemes/NightSkyScheme.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Light" Source="/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="/Themes/Dark/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Themes/HighContrast/_index.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="/Controls/_index.axaml" />
|
||||
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
||||
<ResourceInclude Source="/Tokens/Variables.axaml" />
|
||||
<ResourceInclude Source="/Tokens/_index.axaml" />
|
||||
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
||||
<ResourceInclude Source="/Icons/_index.axaml" />
|
||||
<semi:Icons />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Styles.Resources>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Styling;
|
||||
using Irihi.Avalonia.Shared.Helpers;
|
||||
using Semi.Avalonia.Locale;
|
||||
|
||||
namespace Semi.Avalonia;
|
||||
@@ -36,43 +37,27 @@ public class SemiTheme : Styles
|
||||
|
||||
private static readonly ResourceDictionary DefaultResource = new zh_cn();
|
||||
|
||||
private CultureInfo? _locale;
|
||||
|
||||
public CultureInfo? Locale
|
||||
{
|
||||
get => _locale;
|
||||
get;
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TryGetLocaleResource(value, out var resource) && resource is not null)
|
||||
{
|
||||
_locale = value;
|
||||
if (Resources is ResourceDictionary rd)
|
||||
{
|
||||
rd.SetItems(resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in resource) Resources[kv.Key] = kv.Value;
|
||||
}
|
||||
field = value;
|
||||
Resources.BulkSetResources(resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
_locale = new CultureInfo("zh-CN");
|
||||
if (Resources is ResourceDictionary rd)
|
||||
{
|
||||
rd.SetItems(DefaultResource);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in DefaultResource) Resources[kv.Key] = kv.Value;
|
||||
}
|
||||
field = new CultureInfo("zh-CN");
|
||||
Resources.BulkSetResources(DefaultResource);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_locale = CultureInfo.InvariantCulture;
|
||||
field = CultureInfo.InvariantCulture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,28 +90,13 @@ public class SemiTheme : Styles
|
||||
{
|
||||
if (culture is null) return;
|
||||
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
||||
|
||||
if (application.Resources is ResourceDictionary rd)
|
||||
{
|
||||
rd.SetItems(resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in resources) application.Resources[kv.Key] = kv.Value;
|
||||
}
|
||||
application.Resources.BulkSetResources(resources);
|
||||
}
|
||||
|
||||
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture)
|
||||
{
|
||||
if (culture is null) return;
|
||||
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
||||
if (element.Resources is ResourceDictionary rd)
|
||||
{
|
||||
rd.SetItems(resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in resources) element.Resources[kv.Key] = kv.Value;
|
||||
}
|
||||
element.Resources.BulkSetResources(resources);
|
||||
}
|
||||
}
|
||||
16
src/Semi.Avalonia/Tokens/_index.axaml
Normal file
16
src/Semi.Avalonia/Tokens/_index.axaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:semi="https://irihi.tech/semi">
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<semi:Light x:Key="Default" />
|
||||
<semi:Light x:Key="Light" />
|
||||
<semi:Dark x:Key="Dark" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="HighContrast/Aquatic.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="HighContrast/Desert.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="HighContrast/Dusk.axaml" />
|
||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="HighContrast/NightSky.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<semi:Variables />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user