Refactor AbstractLanguageProvider

This commit is contained in:
qinware
2025-08-06 17:30:21 +08:00
parent 729c512e6c
commit 4dabb53ed8
33 changed files with 33 additions and 139 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<NoWarn>$(NoWarn);CS7035</NoWarn>
<AvaloniaVersion>11.3.2</AvaloniaVersion>
<AvaloniaVersion>11.3.3</AvaloniaVersion>
<AtomUIVersion>0.1.0</AtomUIVersion>
<AtomUINativeVersion>0.1.1</AtomUINativeVersion>
</PropertyGroup>
@@ -1,16 +0,0 @@
using System.Collections.Generic;
using AtomUI.Theme;
namespace AtomUI.Theme
{
internal class LanguageProviderPool
{
internal static IList<AbstractLanguageProvider> GetLanguageProviders()
{
List<AbstractLanguageProvider> languageProviders = new List<AbstractLanguageProvider>();
languageProviders.Add(new AtomUI.Controls.DataGridLocalization.en_US());
languageProviders.Add(new AtomUI.Controls.DataGridLocalization.zh_CN());
return languageProviders;
}
}
}
@@ -1,14 +0,0 @@
using AtomUI.Theme;
namespace AtomUI.Controls.DataGridLocalization
{
public static class DataGridLangResourceKey
{
public static readonly LanguageResourceKey AscendTooltip = new LanguageResourceKey("DataGrid.AscendTooltip", "AtomUI.Lang");
public static readonly LanguageResourceKey CancelConfirmText = new LanguageResourceKey("DataGrid.CancelConfirmText", "AtomUI.Lang");
public static readonly LanguageResourceKey CancelTooltip = new LanguageResourceKey("DataGrid.CancelTooltip", "AtomUI.Lang");
public static readonly LanguageResourceKey DeleteConfirmText = new LanguageResourceKey("DataGrid.DeleteConfirmText", "AtomUI.Lang");
public static readonly LanguageResourceKey DescendTooltip = new LanguageResourceKey("DataGrid.DescendTooltip", "AtomUI.Lang");
public static readonly LanguageResourceKey SelectAllFilterItems = new LanguageResourceKey("DataGrid.SelectAllFilterItems", "AtomUI.Lang");
}
}
@@ -1,15 +0,0 @@
using System.Collections.Generic;
using AtomUI.Theme;
namespace AtomUI.Theme
{
internal class ControlTokenTypePool
{
internal static IList<Type> GetTokenTypes()
{
List<Type> tokenTypes = new List<Type>();
tokenTypes.Add(typeof(AtomUI.Controls.DataGridToken));
return tokenTypes;
}
}
}
@@ -1,83 +0,0 @@
using AtomUI.Theme.TokenSystem;
namespace AtomUI.Theme.Styling
{
public static class DataGridTokenKey
{
public static readonly TokenResourceKey BodySortBg = new TokenResourceKey("DataGrid.BodySortBg");
public static readonly TokenResourceKey BorderColor = new TokenResourceKey("DataGrid.BorderColor");
public static readonly TokenResourceKey CellFontSize = new TokenResourceKey("DataGrid.CellFontSize");
public static readonly TokenResourceKey CellFontSizeMD = new TokenResourceKey("DataGrid.CellFontSizeMD");
public static readonly TokenResourceKey CellFontSizeSM = new TokenResourceKey("DataGrid.CellFontSizeSM");
public static readonly TokenResourceKey CellPadding = new TokenResourceKey("DataGrid.CellPadding");
public static readonly TokenResourceKey CellPaddingMD = new TokenResourceKey("DataGrid.CellPaddingMD");
public static readonly TokenResourceKey CellPaddingSM = new TokenResourceKey("DataGrid.CellPaddingSM");
public static readonly TokenResourceKey ColumnReorderActiveBg = new TokenResourceKey("DataGrid.ColumnReorderActiveBg");
public static readonly TokenResourceKey ExpandIconBg = new TokenResourceKey("DataGrid.ExpandIconBg");
public static readonly TokenResourceKey ExpandIconHalfInner = new TokenResourceKey("DataGrid.ExpandIconHalfInner");
public static readonly TokenResourceKey ExpandIconMargin = new TokenResourceKey("DataGrid.ExpandIconMargin");
public static readonly TokenResourceKey ExpandIconScale = new TokenResourceKey("DataGrid.ExpandIconScale");
public static readonly TokenResourceKey ExpandIconSize = new TokenResourceKey("DataGrid.ExpandIconSize");
public static readonly TokenResourceKey FilterDropdownBg = new TokenResourceKey("DataGrid.FilterDropdownBg");
public static readonly TokenResourceKey FilterDropdownMenuBg = new TokenResourceKey("DataGrid.FilterDropdownMenuBg");
public static readonly TokenResourceKey FilterIndicatorPadding = new TokenResourceKey("DataGrid.FilterIndicatorPadding");
public static readonly TokenResourceKey FixedHeaderSortActiveBg = new TokenResourceKey("DataGrid.FixedHeaderSortActiveBg");
public static readonly TokenResourceKey FooterBg = new TokenResourceKey("DataGrid.FooterBg");
public static readonly TokenResourceKey FooterColor = new TokenResourceKey("DataGrid.FooterColor");
public static readonly TokenResourceKey HeaderBg = new TokenResourceKey("DataGrid.HeaderBg");
public static readonly TokenResourceKey HeaderBorderRadius = new TokenResourceKey("DataGrid.HeaderBorderRadius");
public static readonly TokenResourceKey HeaderColor = new TokenResourceKey("DataGrid.HeaderColor");
public static readonly TokenResourceKey HeaderFilterHoverBg = new TokenResourceKey("DataGrid.HeaderFilterHoverBg");
public static readonly TokenResourceKey HeaderIconColor = new TokenResourceKey("DataGrid.HeaderIconColor");
public static readonly TokenResourceKey HeaderIconHoverColor = new TokenResourceKey("DataGrid.HeaderIconHoverColor");
public static readonly TokenResourceKey HeaderSortActiveBg = new TokenResourceKey("DataGrid.HeaderSortActiveBg");
public static readonly TokenResourceKey HeaderSortHoverBg = new TokenResourceKey("DataGrid.HeaderSortHoverBg");
public static readonly TokenResourceKey HeaderSplitColor = new TokenResourceKey("DataGrid.HeaderSplitColor");
public static readonly TokenResourceKey LeftFrozenShadows = new TokenResourceKey("DataGrid.LeftFrozenShadows");
public static readonly TokenResourceKey PaginationMargin = new TokenResourceKey("DataGrid.PaginationMargin");
public static readonly TokenResourceKey RightFrozenShadows = new TokenResourceKey("DataGrid.RightFrozenShadows");
public static readonly TokenResourceKey RowExpandedBg = new TokenResourceKey("DataGrid.RowExpandedBg");
public static readonly TokenResourceKey RowHoverBg = new TokenResourceKey("DataGrid.RowHoverBg");
public static readonly TokenResourceKey RowReorderIndicatorSize = new TokenResourceKey("DataGrid.RowReorderIndicatorSize");
public static readonly TokenResourceKey RowSelectedBg = new TokenResourceKey("DataGrid.RowSelectedBg");
public static readonly TokenResourceKey RowSelectedHoverBg = new TokenResourceKey("DataGrid.RowSelectedHoverBg");
public static readonly TokenResourceKey SelectionColumnWidth = new TokenResourceKey("DataGrid.SelectionColumnWidth");
public static readonly TokenResourceKey SortIconSize = new TokenResourceKey("DataGrid.SortIconSize");
public static readonly TokenResourceKey SortIndicatorLayoutMargin = new TokenResourceKey("DataGrid.SortIndicatorLayoutMargin");
public static readonly TokenResourceKey TableBg = new TokenResourceKey("DataGrid.TableBg");
public static readonly TokenResourceKey TableBodySortBg = new TokenResourceKey("DataGrid.TableBodySortBg");
public static readonly TokenResourceKey TableBorderColor = new TokenResourceKey("DataGrid.TableBorderColor");
public static readonly TokenResourceKey TableExpandColumnWidth = new TokenResourceKey("DataGrid.TableExpandColumnWidth");
public static readonly TokenResourceKey TableExpandedRowBg = new TokenResourceKey("DataGrid.TableExpandedRowBg");
public static readonly TokenResourceKey TableExpandIconBg = new TokenResourceKey("DataGrid.TableExpandIconBg");
public static readonly TokenResourceKey TableFilterButtonContainerMargin = new TokenResourceKey("DataGrid.TableFilterButtonContainerMargin");
public static readonly TokenResourceKey TableFilterButtonLayoutSeparatorMargin = new TokenResourceKey("DataGrid.TableFilterButtonLayoutSeparatorMargin");
public static readonly TokenResourceKey TableFilterButtonSpacing = new TokenResourceKey("DataGrid.TableFilterButtonSpacing");
public static readonly TokenResourceKey TableFilterDropdownBg = new TokenResourceKey("DataGrid.TableFilterDropdownBg");
public static readonly TokenResourceKey TableFilterDropdownHeight = new TokenResourceKey("DataGrid.TableFilterDropdownHeight");
public static readonly TokenResourceKey TableFilterDropdownPadding = new TokenResourceKey("DataGrid.TableFilterDropdownPadding");
public static readonly TokenResourceKey TableFilterDropdownSearchWidth = new TokenResourceKey("DataGrid.TableFilterDropdownSearchWidth");
public static readonly TokenResourceKey TableFilterDropdownWidth = new TokenResourceKey("DataGrid.TableFilterDropdownWidth");
public static readonly TokenResourceKey TableFixedHeaderSortActiveBg = new TokenResourceKey("DataGrid.TableFixedHeaderSortActiveBg");
public static readonly TokenResourceKey TableFontSize = new TokenResourceKey("DataGrid.TableFontSize");
public static readonly TokenResourceKey TableFontSizeMiddle = new TokenResourceKey("DataGrid.TableFontSizeMiddle");
public static readonly TokenResourceKey TableFontSizeSmall = new TokenResourceKey("DataGrid.TableFontSizeSmall");
public static readonly TokenResourceKey TableFooterBg = new TokenResourceKey("DataGrid.TableFooterBg");
public static readonly TokenResourceKey TableFooterTextColor = new TokenResourceKey("DataGrid.TableFooterTextColor");
public static readonly TokenResourceKey TableHeaderBg = new TokenResourceKey("DataGrid.TableHeaderBg");
public static readonly TokenResourceKey TableHeaderCellSplitColor = new TokenResourceKey("DataGrid.TableHeaderCellSplitColor");
public static readonly TokenResourceKey TableHeaderFilterActiveBg = new TokenResourceKey("DataGrid.TableHeaderFilterActiveBg");
public static readonly TokenResourceKey TableHeaderSortBg = new TokenResourceKey("DataGrid.TableHeaderSortBg");
public static readonly TokenResourceKey TableHeaderSortHoverBg = new TokenResourceKey("DataGrid.TableHeaderSortHoverBg");
public static readonly TokenResourceKey TableHeaderTextColor = new TokenResourceKey("DataGrid.TableHeaderTextColor");
public static readonly TokenResourceKey TablePadding = new TokenResourceKey("DataGrid.TablePadding");
public static readonly TokenResourceKey TablePaddingMiddle = new TokenResourceKey("DataGrid.TablePaddingMiddle");
public static readonly TokenResourceKey TablePaddingSmall = new TokenResourceKey("DataGrid.TablePaddingSmall");
public static readonly TokenResourceKey TableRadius = new TokenResourceKey("DataGrid.TableRadius");
public static readonly TokenResourceKey TableRowHoverBg = new TokenResourceKey("DataGrid.TableRowHoverBg");
public static readonly TokenResourceKey TableSelectedRowBg = new TokenResourceKey("DataGrid.TableSelectedRowBg");
public static readonly TokenResourceKey TableSelectedRowHoverBg = new TokenResourceKey("DataGrid.TableSelectedRowHoverBg");
public static readonly TokenResourceKey TableSelectionColumnWidth = new TokenResourceKey("DataGrid.TableSelectionColumnWidth");
public static readonly TokenResourceKey TableTopLeftColumnCornerRadius = new TokenResourceKey("DataGrid.TableTopLeftColumnCornerRadius");
}
}
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.DataGridLocalization;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.DataGridLocalization;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
namespace AtomUI.Controls;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.DatePickerLang;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.DatePickerLang;
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using AtomUI.Theme;
using AtomUI.Theme.Language;
namespace AtomUI.Theme
namespace AtomUI.Theme.Language
{
internal class LanguageProviderPool
{
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
namespace AtomUI.Controls.DatePickerLang
{
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
// ReSharper disable once CheckNamespace
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
// ReSharper disable once CheckNamespace
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.PaginationLang;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.PaginationLang;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.PopupConfirmLang;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
namespace AtomUI.Controls.PopupConfirmLang;
@@ -1,6 +1,7 @@
using AtomUI.Controls.Utils;
using AtomUI.MotionScene;
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Theme.Data;
using AtomUI.Theme.Styling;
using Avalonia;
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
// ReSharper disable once CheckNamespace
@@ -1,4 +1,5 @@
using AtomUI.Theme;
using AtomUI.Theme.Language;
using AtomUI.Utils;
// ReSharper disable once CheckNamespace
@@ -39,6 +39,7 @@ public class LangResourceKeyClassSourceWriter
private void SetupUsingInfos()
{
_usingInfos.Add("AtomUI.Theme");
_usingInfos.Add("AtomUI.Theme.Language");
}
public void Write()
@@ -24,6 +24,7 @@ public class LanguageProviderPoolClassSourceWriter
{
_usingInfos.Add("System.Collections.Generic");
_usingInfos.Add("AtomUI.Theme");
_usingInfos.Add("AtomUI.Theme.Language");
}
public void Write()
@@ -51,7 +52,7 @@ public class LanguageProviderPoolClassSourceWriter
compilationUnit = compilationUnit.AddUsings(usingSyntaxList.ToArray());
// 添加命名空间
var namespaceSyntax = SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName("AtomUI.Theme"));
var namespaceSyntax = SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName("AtomUI.Theme.Language"));
var languageProviderPoolClassDecl = SyntaxFactory.ClassDeclaration("LanguageProviderPool")
.AddModifiers(SyntaxFactory.Token(SyntaxKind.InternalKeyword))
+1 -1
View File
@@ -2,7 +2,7 @@
public static class TargetMarkConstants
{
public const string LanguageProviderAttribute = "AtomUI.Theme.LanguageProviderAttribute";
public const string LanguageProviderAttribute = "AtomUI.Theme.Language.LanguageProviderAttribute";
public const string GlobalDesignTokenAttribute = "AtomUI.Theme.TokenSystem.GlobalDesignTokenAttribute";
public const string ControlDesignTokenAttribute = "AtomUI.Theme.TokenSystem.ControlDesignTokenAttribute";
public const string ControlThemeProviderAttribute = "AtomUI.Theme.Styling.ControlThemeProviderAttribute";
@@ -1,4 +1,5 @@
using System.Reflection;
using AtomUI.Theme.Language;
using Avalonia.Controls;
namespace AtomUI.Theme;
@@ -1,4 +1,5 @@
using Avalonia;
using AtomUI.Theme.Language;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Styling;
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using AtomUI.Theme;
using AtomUI.Theme.Language;
namespace AtomUI.Theme
namespace AtomUI.Theme.Language
{
internal class LanguageProviderPool
{
@@ -1 +1,2 @@
using AtomUI.Theme;
using AtomUI.Theme;
using AtomUI.Theme.Language;
@@ -1,6 +1,6 @@
using Avalonia.Controls;
namespace AtomUI.Theme;
namespace AtomUI.Theme.Language;
public interface ILanguageProvider
{
@@ -1,4 +1,4 @@
namespace AtomUI.Theme;
namespace AtomUI.Theme.Language;
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class LanguageProviderAttribute : Attribute
@@ -1,4 +1,4 @@
namespace AtomUI.Theme;
namespace AtomUI.Theme.Language;
public readonly struct LanguageResourceKey : IEquatable<LanguageResourceKey>
{
-1
View File
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using System.Text;
using AtomUI.Theme.Styling;
using AtomUI.Theme.TokenSystem;
using Avalonia;
+1
View File
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Globalization;
using AtomUI.Theme.Language;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Platform;