From a32ec4716e5dcca7fdbfc0ec45c6471cd4075c7c Mon Sep 17 00:00:00 2001 From: polarboy Date: Thu, 18 Jul 2024 11:37:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=20TokenResourceKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AtomUI.Controls/Alert/AlertTheme.cs | 74 +-- .../Buttons/BaseButtonTheme.cs | 24 +- src/AtomUI.Controls/Buttons/Button.cs | 2 +- .../Buttons/DefaultButtonTheme.cs | 48 +- src/AtomUI.Controls/Buttons/IconButton.cs | 2 +- .../Buttons/LinkButtonTheme.cs | 18 +- .../Buttons/PrimaryButtonTheme.cs | 46 +- .../Buttons/TextButtonTheme.cs | 16 +- src/AtomUI.Controls/CheckBox/CheckBox.cs | 2 +- src/AtomUI.Controls/CheckBox/CheckBoxTheme.cs | 16 +- .../EmptyIndicator/EmptyIndicatorTheme.cs | 10 +- src/AtomUI.Controls/Flyouts/Flyout.cs | 6 +- src/AtomUI.Controls/Flyouts/FlyoutHost.cs | 8 +- .../TokenResourceConst.g.cs | 344 +++++++------- .../MarqueeLabel/MarqueeLabel.cs | 2 +- .../OptionButtonBox/OptionButton.cs | 105 ++--- .../OptionButtonBox/OptionButtonGroup.cs | 33 +- src/AtomUI.Controls/Popup/Popup.cs | 4 +- .../ProgressBar/AbstractCircleProgress.cs | 12 +- .../ProgressBar/AbstractLineProgress.cs | 44 +- .../ProgressBar/AbstractProgressBar.cs | 23 +- .../ProgressBar/ProgressBar.cs | 4 +- .../RadioButton/RadioButton.cs | 2 +- .../RadioButton/RadioButtonTheme.cs | 8 +- .../Segmented/SegmentedItem.cs | 2 +- .../Segmented/SegmentedItemBox.cs | 43 +- .../Segmented/SegmentedItemTheme.cs | 17 +- .../Segmented/SegmentedProperties.cs | 8 +- .../Separator/SeparatorTheme.cs | 12 +- src/AtomUI.Controls/Switch/SwitchKnob.cs | 11 +- src/AtomUI.Controls/Switch/ToggleSwitch.cs | 47 +- src/AtomUI.Controls/Tooltip/ToolTip.cs | 9 + src/AtomUI.Controls/Tooltip/ToolTipTheme.cs | 8 - src/AtomUI.Controls/Window/CaptionButton.cs | 3 - .../TokenInfo/ResourceKeyClassSourceWriter.cs | 27 +- .../Utils => AtomUI/Data}/BindUtils.cs | 53 ++- src/AtomUI/Data/ControlTokenBinder.cs | 120 ----- src/AtomUI/Data/GlobalTokenBinder.cs | 134 ------ src/AtomUI/Data/ThemeResourceUtils.cs | 86 ---- .../TokenResourceConst.g.cs | 434 +++++++++--------- .../{StyleUtils.cs => ControlStateUtils.cs} | 2 +- src/AtomUI/Styling/StyleExtensions.cs | 22 + .../TokenSystem/AbstractControlDesignToken.cs | 4 +- src/AtomUI/TokenSystem/AbstractDesignToken.cs | 2 +- src/AtomUI/TokenSystem/TokenResourceKey.cs | 61 +++ src/AtomUI/Utils/AnimationUtils.cs | 4 +- 46 files changed, 865 insertions(+), 1097 deletions(-) rename src/{AtomUI.Base/Utils => AtomUI/Data}/BindUtils.cs (55%) delete mode 100644 src/AtomUI/Data/ControlTokenBinder.cs delete mode 100644 src/AtomUI/Data/GlobalTokenBinder.cs delete mode 100644 src/AtomUI/Data/ThemeResourceUtils.cs rename src/AtomUI/Styling/{StyleUtils.cs => ControlStateUtils.cs} (92%) create mode 100644 src/AtomUI/Styling/StyleExtensions.cs create mode 100644 src/AtomUI/TokenSystem/TokenResourceKey.cs diff --git a/src/AtomUI.Controls/Alert/AlertTheme.cs b/src/AtomUI.Controls/Alert/AlertTheme.cs index c31394277..0adf3d020 100644 --- a/src/AtomUI.Controls/Alert/AlertTheme.cs +++ b/src/AtomUI.Controls/Alert/AlertTheme.cs @@ -39,38 +39,38 @@ internal class AlertTheme : ControlTheme private void BuildAlertTypeStyle() { - Add(new Setter(Alert.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadiusLG))); + this.Add(Alert.CornerRadiusProperty, GlobalResourceKey.BorderRadiusLG); var successStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Success)); - successStyle.Setters.Add(new Setter(Alert.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorSuccessBg))); - successStyle.Setters.Add(new Setter(Alert.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorSuccessBorder))); + successStyle.Add(Alert.BackgroundProperty, GlobalResourceKey.ColorSuccessBg); + successStyle.Add(Alert.BorderBrushProperty, GlobalResourceKey.ColorSuccessBorder); Add(successStyle); var infoStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Info)); - infoStyle.Setters.Add(new Setter(Alert.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorInfoBg))); - infoStyle.Setters.Add(new Setter(Alert.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorInfoBorder))); + infoStyle.Add(Alert.BackgroundProperty, GlobalResourceKey.ColorInfoBg); + infoStyle.Add(Alert.BorderBrushProperty, GlobalResourceKey.ColorInfoBorder); Add(infoStyle); var warningStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Warning)); - warningStyle.Setters.Add(new Setter(Alert.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorWarningBg))); - warningStyle.Setters.Add(new Setter(Alert.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorWarningBorder))); + warningStyle.Add(Alert.BackgroundProperty, GlobalResourceKey.ColorWarningBg); + warningStyle.Add(Alert.BorderBrushProperty, GlobalResourceKey.ColorWarningBorder); Add(warningStyle); var errorStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Error)); - errorStyle.Setters.Add(new Setter(Alert.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBg))); - errorStyle.Setters.Add(new Setter(Alert.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorder))); + errorStyle.Add(Alert.BackgroundProperty, GlobalResourceKey.ColorErrorBg); + errorStyle.Add(Alert.BorderBrushProperty, GlobalResourceKey.ColorErrorBorder); Add(errorStyle); // 根据是否显示 Description 设置 Padding { // 为空 var paddingStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.DescriptionProperty, null)); - paddingStyle.Setters.Add(new Setter(TemplatedControl.PaddingProperty, new DynamicResourceExtension(AlertResourceKey.DefaultPadding))); + paddingStyle.Add(TemplatedControl.PaddingProperty, AlertResourceKey.DefaultPadding); Add(paddingStyle); } { // 不为空 var paddingStyle = new Style(selector => selector.Nesting().Not(x=> x.PropertyEquals(Alert.DescriptionProperty, null))); - paddingStyle.Setters.Add(new Setter(TemplatedControl.PaddingProperty, new DynamicResourceExtension(AlertResourceKey.WithDescriptionPadding))); + paddingStyle.Add(TemplatedControl.PaddingProperty, AlertResourceKey.WithDescriptionPadding); Add(paddingStyle); } } @@ -84,16 +84,16 @@ internal class AlertTheme : ControlTheme // Description 不为空 var descriptionStyle = new Style(selector => selector.Nesting().Not(x=> x.PropertyEquals(Alert.DescriptionProperty, null))); var commonLabelStyle = new Style(selector => commonLabelSelector); - commonLabelStyle.Setters.Add(new Setter(TemplatedControl.FontSizeProperty, new DynamicResourceExtension(GlobalResourceKey.FontSizeLG))); - commonLabelStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top)); + commonLabelStyle.Add(TemplatedControl.FontSizeProperty, GlobalResourceKey.FontSizeLG); + commonLabelStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top); descriptionStyle.Add(commonLabelStyle); Add(descriptionStyle); } { var descriptionStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.DescriptionProperty, null)); var commonLabelStyle = new Style(selector => commonLabelSelector); - commonLabelStyle.Setters.Add(new Setter(TemplatedControl.FontSizeProperty, new DynamicResourceExtension(GlobalResourceKey.FontSize))); - commonLabelStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Stretch)); + commonLabelStyle.Add(TemplatedControl.FontSizeProperty, GlobalResourceKey.FontSize); + commonLabelStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Stretch); descriptionStyle.Add(commonLabelStyle); Add(descriptionStyle); } @@ -102,7 +102,7 @@ internal class AlertTheme : ControlTheme { var wrapperStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.IsMessageMarqueEnabledProperty, true)); var normalLabelStyle = new Style(selector => normalLabel); - normalLabelStyle.Setters.Add(new Setter(Label.IsVisibleProperty, false)); + normalLabelStyle.Add(Label.IsVisibleProperty, false); wrapperStyle.Add(normalLabelStyle); Add(wrapperStyle); } @@ -116,7 +116,7 @@ internal class AlertTheme : ControlTheme // 为空 var descriptionStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.DescriptionProperty, null)); var closeBtnStyle = new Style(selector=> closeBtnSelector); - closeBtnStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Center)); + closeBtnStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Center); descriptionStyle.Add(closeBtnStyle); Add(descriptionStyle); } @@ -124,7 +124,7 @@ internal class AlertTheme : ControlTheme // 不为空 var descriptionStyle = new Style(selector => selector.Nesting().Not(x=> x.PropertyEquals(Alert.DescriptionProperty, null))); var closeBtnStyle = new Style(selector=> closeBtnSelector); - closeBtnStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top)); + closeBtnStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top); descriptionStyle.Add(closeBtnStyle); Add(descriptionStyle); } @@ -136,35 +136,35 @@ internal class AlertTheme : ControlTheme { var successStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Success)); var infoIconStyle = new Style(selector => infoIconSelector); - infoIconStyle.Setters.Add(new Setter(PathIcon.KindProperty, "CheckCircleFilled")); - infoIconStyle.Setters.Add(new Setter(PathIcon.NormalFillBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorSuccess))); + infoIconStyle.Add(PathIcon.KindProperty, "CheckCircleFilled"); + infoIconStyle.Add(PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorSuccess); successStyle.Add(infoIconStyle); Add(successStyle); } - + { var infoStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Info)); var infoIconStyle = new Style(selector => infoIconSelector); - infoIconStyle.Setters.Add(new Setter(PathIcon.KindProperty, "InfoCircleFilled")); - infoIconStyle.Setters.Add(new Setter(PathIcon.NormalFillBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + infoIconStyle.Add(PathIcon.KindProperty, "InfoCircleFilled"); + infoIconStyle.Add(PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorPrimary); infoStyle.Add(infoIconStyle); Add(infoStyle); } - + { var warningStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Warning)); var infoIconStyle = new Style(selector => infoIconSelector); - infoIconStyle.Setters.Add(new Setter(PathIcon.KindProperty, "ExclamationCircleFilled")); - infoIconStyle.Setters.Add(new Setter(PathIcon.NormalFillBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorWarning))); + infoIconStyle.Add(PathIcon.KindProperty, "ExclamationCircleFilled"); + infoIconStyle.Add(PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorWarning); warningStyle.Add(infoIconStyle); Add(warningStyle); } - + { var errorStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.TypeProperty, AlertType.Error)); var infoIconStyle = new Style(selector => infoIconSelector); - infoIconStyle.Setters.Add(new Setter(PathIcon.KindProperty, "CloseCircleFilled")); - infoIconStyle.Setters.Add(new Setter(PathIcon.NormalFillBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + infoIconStyle.Add(PathIcon.KindProperty, "CloseCircleFilled"); + infoIconStyle.Add(PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorError); errorStyle.Add(infoIconStyle); Add(errorStyle); } @@ -174,10 +174,10 @@ internal class AlertTheme : ControlTheme // 为空 var wrapperStyle = new Style(selector => selector.Nesting().PropertyEquals(Alert.DescriptionProperty, null)); var infoIconStyle = new Style(selector=> infoIconSelector); - infoIconStyle.Setters.Add(new Setter(Layoutable.WidthProperty, new DynamicResourceExtension(AlertResourceKey.IconSize))); - infoIconStyle.Setters.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(AlertResourceKey.IconSize))); - infoIconStyle.Setters.Add(new Setter(Layoutable.MarginProperty, new DynamicResourceExtension(AlertResourceKey.IconDefaultMargin))); - infoIconStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Center)); + infoIconStyle.Add(Layoutable.WidthProperty, AlertResourceKey.IconSize); + infoIconStyle.Add(Layoutable.HeightProperty, AlertResourceKey.IconSize); + infoIconStyle.Add(Layoutable.MarginProperty, AlertResourceKey.IconDefaultMargin); + infoIconStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Center); wrapperStyle.Add(infoIconStyle); Add(wrapperStyle); } @@ -185,10 +185,10 @@ internal class AlertTheme : ControlTheme // 不为空 var wrapperStyle = new Style(selector => selector.Nesting().Not(x=> x.PropertyEquals(Alert.DescriptionProperty, null))); var infoIconStyle = new Style(selector=> infoIconSelector); - infoIconStyle.Setters.Add(new Setter(Layoutable.WidthProperty, new DynamicResourceExtension(AlertResourceKey.WithDescriptionIconSize))); - infoIconStyle.Setters.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(AlertResourceKey.WithDescriptionIconSize))); - infoIconStyle.Setters.Add(new Setter(Layoutable.MarginProperty, new DynamicResourceExtension(AlertResourceKey.IconWithDescriptionMargin))); - infoIconStyle.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top)); + infoIconStyle.Add(Layoutable.WidthProperty, AlertResourceKey.WithDescriptionIconSize); + infoIconStyle.Add(Layoutable.HeightProperty, AlertResourceKey.WithDescriptionIconSize); + infoIconStyle.Add(Layoutable.MarginProperty, AlertResourceKey.IconWithDescriptionMargin); + infoIconStyle.Add(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Top); wrapperStyle.Add(infoIconStyle); Add(wrapperStyle); } diff --git a/src/AtomUI.Controls/Buttons/BaseButtonTheme.cs b/src/AtomUI.Controls/Buttons/BaseButtonTheme.cs index d8f60976f..df06a92a4 100644 --- a/src/AtomUI.Controls/Buttons/BaseButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/BaseButtonTheme.cs @@ -60,24 +60,24 @@ internal abstract class BaseButtonTheme : ControlTheme private void BuildSizeStyle() { var largeSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.SizeTypeProperty, SizeType.Large)); - largeSizeStyle.Setters.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeightLG))); - largeSizeStyle.Setters.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSizeLG))); - largeSizeStyle.Setters.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.PaddingLG))); - largeSizeStyle.Setters.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadiusLG))); + largeSizeStyle.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeightLG))); + largeSizeStyle.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSizeLG))); + largeSizeStyle.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.PaddingLG))); + largeSizeStyle.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadiusLG))); Add(largeSizeStyle); var middleSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.SizeTypeProperty, SizeType.Middle)); - middleSizeStyle.Setters.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeight))); - middleSizeStyle.Setters.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSize))); - middleSizeStyle.Setters.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.Padding))); - middleSizeStyle.Setters.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadius))); + middleSizeStyle.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeight))); + middleSizeStyle.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSize))); + middleSizeStyle.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.Padding))); + middleSizeStyle.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadius))); Add(middleSizeStyle); var smallSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.SizeTypeProperty, SizeType.Small)); - smallSizeStyle.Setters.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeightSM))); - smallSizeStyle.Setters.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSizeSM))); - smallSizeStyle.Setters.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.PaddingSM))); - smallSizeStyle.Setters.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadiusSM))); + smallSizeStyle.Add(new Setter(Button.ControlHeightTokenProperty, new DynamicResourceExtension(GlobalResourceKey.ControlHeightSM))); + smallSizeStyle.Add(new Setter(Button.FontSizeProperty, new DynamicResourceExtension(ButtonResourceKey.ContentFontSizeSM))); + smallSizeStyle.Add(new Setter(Button.PaddingProperty, new DynamicResourceExtension(ButtonResourceKey.PaddingSM))); + smallSizeStyle.Add(new Setter(Button.CornerRadiusProperty, new DynamicResourceExtension(GlobalResourceKey.BorderRadiusSM))); Add(smallSizeStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/Buttons/Button.cs b/src/AtomUI.Controls/Buttons/Button.cs index 58c130463..b9581c992 100644 --- a/src/AtomUI.Controls/Buttons/Button.cs +++ b/src/AtomUI.Controls/Buttons/Button.cs @@ -252,7 +252,7 @@ public partial class Button : AvaloniaButton, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { diff --git a/src/AtomUI.Controls/Buttons/DefaultButtonTheme.cs b/src/AtomUI.Controls/Buttons/DefaultButtonTheme.cs index 758ba09cc..068cf4e1a 100644 --- a/src/AtomUI.Controls/Buttons/DefaultButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/DefaultButtonTheme.cs @@ -30,43 +30,43 @@ internal class DefaultButtonTheme : BaseButtonTheme { var enabledStyle = new Style(selector => selector.Nesting()); // 正常状态 - enabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBg))); - enabledStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBorderColor))); - enabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultColor))); + enabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBg))); + enabledStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBorderColor))); + enabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultColor))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultHoverBorderColor))); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultHoverColor))); + hoverStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultHoverBorderColor))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultHoverColor))); enabledStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultActiveBorderColor))); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultActiveColor))); + pressedStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultActiveBorderColor))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultActiveColor))); enabledStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); - dangerStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); // 危险状态 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); + hoverStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); dangerStyle.Add(hoverStyle); } // 危险状态按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); dangerStyle.Add(pressedStyle); } enabledStyle.Add(dangerStyle); @@ -80,29 +80,29 @@ internal class DefaultButtonTheme : BaseButtonTheme { var ghostStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsGhostProperty, true)); // 正常状态 - ghostStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextLightSolid))); - ghostStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextLightSolid))); - ghostStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); + ghostStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextLightSolid))); + ghostStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextLightSolid))); + ghostStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); - hoverStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + hoverStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); ghostStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); - pressedStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); + pressedStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); ghostStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); + dangerStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); ghostStyle.Add(dangerStyle); Add(ghostStyle); @@ -111,9 +111,9 @@ internal class DefaultButtonTheme : BaseButtonTheme private void BuildDisabledStyle() { var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled)); - disabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); - disabledStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.BorderColorDisabled))); - disabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainerDisabled))); + disabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + disabledStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.BorderColorDisabled))); + disabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainerDisabled))); Add(disabledStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/Buttons/IconButton.cs b/src/AtomUI.Controls/Buttons/IconButton.cs index ceaf4ba4f..3248e4e1a 100644 --- a/src/AtomUI.Controls/Buttons/IconButton.cs +++ b/src/AtomUI.Controls/Buttons/IconButton.cs @@ -72,7 +72,7 @@ public class IconButton : AvaloniaButton, ICustomHitTest private void CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { diff --git a/src/AtomUI.Controls/Buttons/LinkButtonTheme.cs b/src/AtomUI.Controls/Buttons/LinkButtonTheme.cs index 39f5f2d68..44eb1732d 100644 --- a/src/AtomUI.Controls/Buttons/LinkButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/LinkButtonTheme.cs @@ -29,37 +29,37 @@ internal class LinkButtonTheme : BaseButtonTheme { var enabledStyle = new Style(selector => selector.Nesting()); // 正常状态 - enabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBg))); - enabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLink))); + enabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultBg))); + enabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLink))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLinkHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLinkHover))); enabledStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLinkActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorLinkActive))); enabledStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); // 危险状态 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorHover))); dangerStyle.Add(hoverStyle); } // 危险状态按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); dangerStyle.Add(pressedStyle); } enabledStyle.Add(dangerStyle); @@ -73,7 +73,7 @@ internal class LinkButtonTheme : BaseButtonTheme { var ghostStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsGhostProperty, true)); // 正常状态 - ghostStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); + ghostStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); Add(ghostStyle); } @@ -81,7 +81,7 @@ internal class LinkButtonTheme : BaseButtonTheme private void BuildDisabledStyle() { var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled)); - disabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + disabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); Add(disabledStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/Buttons/PrimaryButtonTheme.cs b/src/AtomUI.Controls/Buttons/PrimaryButtonTheme.cs index 13e679f7f..d7aca100c 100644 --- a/src/AtomUI.Controls/Buttons/PrimaryButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/PrimaryButtonTheme.cs @@ -33,38 +33,38 @@ internal class PrimaryButtonTheme : BaseButtonTheme var enabledStyle = new Style(selector => selector.Nesting()); // 正常状态 - enabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.PrimaryColor))); - enabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + enabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.PrimaryColor))); + enabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + hoverStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); enabledStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); + pressedStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); enabledStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); // 危险状态 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorHover))); + hoverStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorHover))); dangerStyle.Add(hoverStyle); } // 危险状态按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); dangerStyle.Add(pressedStyle); } enabledStyle.Add(dangerStyle); @@ -76,46 +76,46 @@ internal class PrimaryButtonTheme : BaseButtonTheme private void BuildEnabledGhostStyle() { var ghostStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsGhostProperty, true)); - ghostStyle.Setters.Add(new Setter(Button.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); + ghostStyle.Add(new Setter(Button.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); // 正常状态 - ghostStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); - ghostStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + ghostStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + ghostStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); - hoverStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + hoverStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); ghostStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); - pressedStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); + pressedStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryActive))); ghostStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); - dangerStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); // 危险按钮状态 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); - hoverStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); + hoverStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); + hoverStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBorderHover))); dangerStyle.Add(hoverStyle); } // 危险状态按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); - pressedStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); + pressedStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorActive))); dangerStyle.Add(pressedStyle); } @@ -126,9 +126,9 @@ internal class PrimaryButtonTheme : BaseButtonTheme private void BuildDisabledStyle() { var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled)); - disabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); - disabledStyle.Setters.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.BorderColorDisabled))); - disabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainerDisabled))); + disabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + disabledStyle.Add(new Setter(Button.BorderBrushProperty, new DynamicResourceExtension(ButtonResourceKey.BorderColorDisabled))); + disabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainerDisabled))); Add(disabledStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/Buttons/TextButtonTheme.cs b/src/AtomUI.Controls/Buttons/TextButtonTheme.cs index d7cb25224..f962e1c08 100644 --- a/src/AtomUI.Controls/Buttons/TextButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/TextButtonTheme.cs @@ -30,37 +30,37 @@ internal class TextButtonTheme : BaseButtonTheme { var enabledStyle = new Style(selector => selector.Nesting()); // 正常状态 - enabledStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); - enabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultColor))); + enabledStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTransparent))); + enabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(ButtonResourceKey.DefaultColor))); // 正常 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.TextHoverBg))); + hoverStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(ButtonResourceKey.TextHoverBg))); enabledStyle.Add(hoverStyle); } // 正常按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgTextActive))); + pressedStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgTextActive))); enabledStyle.Add(pressedStyle); } // 危险按钮状态 var dangerStyle = new Style(selector => selector.Nesting().PropertyEquals(Button.IsDangerProperty, true)); - dangerStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); + dangerStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorError))); // 危险状态 hover { var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBgHover))); + hoverStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBgHover))); dangerStyle.Add(hoverStyle); } // 危险状态按下 { var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver).Class(StdPseudoClass.Pressed)); - pressedStyle.Setters.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBgActive))); + pressedStyle.Add(new Setter(Button.BackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorErrorBgActive))); dangerStyle.Add(pressedStyle); } enabledStyle.Add(dangerStyle); @@ -71,7 +71,7 @@ internal class TextButtonTheme : BaseButtonTheme private void BuildDisabledStyle() { var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled)); - disabledStyle.Setters.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + disabledStyle.Add(new Setter(Button.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); Add(disabledStyle); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/CheckBox/CheckBox.cs b/src/AtomUI.Controls/CheckBox/CheckBox.cs index 500dce94c..27afcd1ae 100644 --- a/src/AtomUI.Controls/CheckBox/CheckBox.cs +++ b/src/AtomUI.Controls/CheckBox/CheckBox.cs @@ -147,7 +147,7 @@ public partial class CheckBox : AvaloniaCheckBox, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); switch (IsChecked) { case true: _styleState |= ControlStyleState.On; diff --git a/src/AtomUI.Controls/CheckBox/CheckBoxTheme.cs b/src/AtomUI.Controls/CheckBox/CheckBoxTheme.cs index 6a03586d8..6c63c3cef 100644 --- a/src/AtomUI.Controls/CheckBox/CheckBoxTheme.cs +++ b/src/AtomUI.Controls/CheckBox/CheckBoxTheme.cs @@ -31,11 +31,11 @@ internal class CheckBoxTheme : ControlTheme disableStyle.Add(new Setter(CheckBox.ForegroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); var checkedStyle = new Style(selector => selector.Nesting().PropertyEquals(CheckBox.IsCheckedProperty, true)); - checkedStyle.Setters.Add(new Setter(CheckBox.IndicatorCheckedMarkBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + checkedStyle.Add(new Setter(CheckBox.IndicatorCheckedMarkBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); disableStyle.Add(checkedStyle); var indeterminateStyle = new Style(selector => selector.Nesting().PropertyEquals(CheckBox.IsCheckedProperty, null)); - indeterminateStyle.Setters.Add(new Setter(CheckBox.IndicatorTristateMarkBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); + indeterminateStyle.Add(new Setter(CheckBox.IndicatorTristateMarkBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorTextDisabled))); disableStyle.Add(indeterminateStyle); Add(disableStyle); } @@ -50,24 +50,24 @@ internal class CheckBoxTheme : ControlTheme // 选中 var checkedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Checked)); - checkedStyle.Setters.Add(new Setter(CheckBox.IndicatorBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); - checkedStyle.Setters.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + checkedStyle.Add(new Setter(CheckBox.IndicatorBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + checkedStyle.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); // 选中 hover var checkedHoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - checkedHoverStyle.Setters.Add(new Setter(CheckBox.IndicatorBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); - checkedHoverStyle.Setters.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + checkedHoverStyle.Add(new Setter(CheckBox.IndicatorBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + checkedHoverStyle.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); checkedStyle.Add(checkedHoverStyle); enabledStyle.Add(checkedStyle); // 没选中 var unCheckedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - unCheckedStyle.Setters.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + unCheckedStyle.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); enabledStyle.Add(unCheckedStyle); // 中间状态 var indeterminateStyle = new Style(selector => selector.Nesting().Class($"{StdPseudoClass.Indeterminate}{StdPseudoClass.PointerOver}")); - indeterminateStyle.Setters.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); + indeterminateStyle.Add(new Setter(CheckBox.IndicatorBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimaryHover))); enabledStyle.Add(indeterminateStyle); Add(enabledStyle); diff --git a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs index 35c601e07..cf146b3d1 100644 --- a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs +++ b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs @@ -56,11 +56,11 @@ internal class EmptyIndicatorTheme : ControlTheme // 设置本身样式 var sizeSmallAndMiddleStyle = new Style(selector => Selectors.Or(selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Middle), selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Small))); - sizeSmallAndMiddleStyle.Setters.Add(new Setter(EmptyIndicator.DescriptionMarginProperty, new DynamicResourceExtension(GlobalResourceKey.MarginXS))); + sizeSmallAndMiddleStyle.Add(new Setter(EmptyIndicator.DescriptionMarginProperty, new DynamicResourceExtension(GlobalResourceKey.MarginXS))); Add(sizeSmallAndMiddleStyle); var sizeLargeStyle = new Style(selector => selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Large)); - sizeLargeStyle.Setters.Add(new Setter(EmptyIndicator.DescriptionMarginProperty, new DynamicResourceExtension(GlobalResourceKey.MarginSM))); + sizeLargeStyle.Add(new Setter(EmptyIndicator.DescriptionMarginProperty, new DynamicResourceExtension(GlobalResourceKey.MarginSM))); Add(sizeLargeStyle); BuildSvgStyle(); @@ -72,7 +72,7 @@ internal class EmptyIndicatorTheme : ControlTheme { var largeSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Large)); var svgStyle = new Style(selector => svgSelector); - svgStyle.Setters.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeight))); + svgStyle.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeight))); largeSizeStyle.Add(svgStyle); Add(largeSizeStyle); } @@ -80,7 +80,7 @@ internal class EmptyIndicatorTheme : ControlTheme { var middleSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Middle)); var svgStyle = new Style(selector => svgSelector); - svgStyle.Setters.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeightMD))); + svgStyle.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeightMD))); middleSizeStyle.Add(svgStyle); Add(middleSizeStyle); } @@ -88,7 +88,7 @@ internal class EmptyIndicatorTheme : ControlTheme { var smallSizeStyle = new Style(selector => selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Small)); var svgStyle = new Style(selector => svgSelector); - svgStyle.Setters.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeightSM))); + svgStyle.Add(new Setter(Layoutable.HeightProperty, new DynamicResourceExtension(EmptyIndicatorResourceKey.EmptyImgHeightSM))); smallSizeStyle.Add(svgStyle); Add(smallSizeStyle); } diff --git a/src/AtomUI.Controls/Flyouts/Flyout.cs b/src/AtomUI.Controls/Flyouts/Flyout.cs index 298d091b4..269a4fea0 100644 --- a/src/AtomUI.Controls/Flyouts/Flyout.cs +++ b/src/AtomUI.Controls/Flyouts/Flyout.cs @@ -112,7 +112,6 @@ public class Flyout : PopupFlyoutBase private CompositeDisposable? _compositeDisposable; private bool _animating = false; - private GlobalTokenBinder _globalTokenBinder; // 当鼠标移走了,但是打开动画还没完成,我们需要记录下来这个信号 internal bool RequestCloseWhereAnimationCompleted { get; set; } = false; @@ -125,9 +124,8 @@ public class Flyout : PopupFlyoutBase public Flyout() { - _globalTokenBinder = new GlobalTokenBinder(); - _globalTokenBinder.AddGlobalBinding(this, MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); - _globalTokenBinder.AddGlobalBinding(this, MaskShadowsProperty, GlobalResourceKey.BoxShadowsSecondary); + BindUtils.CreateGlobalTokenBinding(this, MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); + BindUtils.CreateGlobalTokenBinding(this, MaskShadowsProperty, GlobalResourceKey.BoxShadowsSecondary); } private void HandlePopupPropertyChanged(AvaloniaPropertyChangedEventArgs args) diff --git a/src/AtomUI.Controls/Flyouts/FlyoutHost.cs b/src/AtomUI.Controls/Flyouts/FlyoutHost.cs index cbc20d221..f5ea34bd2 100644 --- a/src/AtomUI.Controls/Flyouts/FlyoutHost.cs +++ b/src/AtomUI.Controls/Flyouts/FlyoutHost.cs @@ -147,7 +147,6 @@ public class FlyoutHost : Control private bool _initialized = false; private CompositeDisposable? _compositeDisposable; - private GlobalTokenBinder _globalTokenBinder; private DispatcherTimer? _mouseEnterDelayTimer; private DispatcherTimer? _mouseLeaveDelayTimer; @@ -155,11 +154,6 @@ public class FlyoutHost : Control { PlacementProperty.OverrideDefaultValue(PlacementMode.Top); } - - public FlyoutHost() - { - _globalTokenBinder = new GlobalTokenBinder(); - } protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { @@ -169,7 +163,7 @@ public class FlyoutHost : Control ((ISetLogicalParent)AnchorTarget).SetParent(this); VisualChildren.Add(AnchorTarget); } - _globalTokenBinder.AddGlobalBinding(this, MarginToAnchorProperty, GlobalResourceKey.MarginXXS); + BindUtils.CreateGlobalTokenBinding(this, MarginToAnchorProperty, GlobalResourceKey.MarginXXS); _initialized = true; } } diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs index d2221596b..aaa239038 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs @@ -1,244 +1,246 @@ -namespace AtomUI.Styling +using AtomUI.TokenSystem; + +namespace AtomUI.Styling { public static class AlertResourceKey { - public const string DefaultPadding = "Alert.DefaultPadding"; - public const string WithDescriptionPadding = "Alert.WithDescriptionPadding"; - public const string MessageWithDescriptionMargin = "Alert.MessageWithDescriptionMargin"; - public const string IconDefaultMargin = "Alert.IconDefaultMargin"; - public const string IconWithDescriptionMargin = "Alert.IconWithDescriptionMargin"; - public const string IconSize = "Alert.IconSize"; - public const string WithDescriptionIconSize = "Alert.WithDescriptionIconSize"; - public const string CloseIconSize = "Alert.CloseIconSize"; - public const string ExtraElementMargin = "Alert.ExtraElementMargin"; + public static readonly TokenResourceKey DefaultPadding = new TokenResourceKey("Alert.DefaultPadding"); + public static readonly TokenResourceKey WithDescriptionPadding = new TokenResourceKey("Alert.WithDescriptionPadding"); + public static readonly TokenResourceKey MessageWithDescriptionMargin = new TokenResourceKey("Alert.MessageWithDescriptionMargin"); + public static readonly TokenResourceKey IconDefaultMargin = new TokenResourceKey("Alert.IconDefaultMargin"); + public static readonly TokenResourceKey IconWithDescriptionMargin = new TokenResourceKey("Alert.IconWithDescriptionMargin"); + public static readonly TokenResourceKey IconSize = new TokenResourceKey("Alert.IconSize"); + public static readonly TokenResourceKey WithDescriptionIconSize = new TokenResourceKey("Alert.WithDescriptionIconSize"); + public static readonly TokenResourceKey CloseIconSize = new TokenResourceKey("Alert.CloseIconSize"); + public static readonly TokenResourceKey ExtraElementMargin = new TokenResourceKey("Alert.ExtraElementMargin"); } public static class ArrowDecoratedBoxResourceKey { - public const string ArrowSize = "ArrowDecoratedBox.ArrowSize"; + public static readonly TokenResourceKey ArrowSize = new TokenResourceKey("ArrowDecoratedBox.ArrowSize"); } public static class BadgeResourceKey { - public const string IndicatorHeight = "Badge.IndicatorHeight"; - public const string IndicatorHeightSM = "Badge.IndicatorHeightSM"; - public const string DotSize = "Badge.DotSize"; - public const string TextFontSize = "Badge.TextFontSize"; - public const string TextFontSizeSM = "Badge.TextFontSizeSM"; - public const string TextFontWeight = "Badge.TextFontWeight"; - public const string StatusSize = "Badge.StatusSize"; - public const string BadgeFontHeight = "Badge.BadgeFontHeight"; - public const string BadgeTextColor = "Badge.BadgeTextColor"; - public const string BadgeColor = "Badge.BadgeColor"; - public const string BadgeColorHover = "Badge.BadgeColorHover"; - public const string BadgeShadowSize = "Badge.BadgeShadowSize"; - public const string BadgeShadowColor = "Badge.BadgeShadowColor"; - public const string BadgeProcessingDuration = "Badge.BadgeProcessingDuration"; - public const string BadgeRibbonOffset = "Badge.BadgeRibbonOffset"; - public const string BadgeRibbonCornerTransform = "Badge.BadgeRibbonCornerTransform"; - public const string BadgeRibbonCornerDarkenAmount = "Badge.BadgeRibbonCornerDarkenAmount"; + public static readonly TokenResourceKey IndicatorHeight = new TokenResourceKey("Badge.IndicatorHeight"); + public static readonly TokenResourceKey IndicatorHeightSM = new TokenResourceKey("Badge.IndicatorHeightSM"); + public static readonly TokenResourceKey DotSize = new TokenResourceKey("Badge.DotSize"); + public static readonly TokenResourceKey TextFontSize = new TokenResourceKey("Badge.TextFontSize"); + public static readonly TokenResourceKey TextFontSizeSM = new TokenResourceKey("Badge.TextFontSizeSM"); + public static readonly TokenResourceKey TextFontWeight = new TokenResourceKey("Badge.TextFontWeight"); + public static readonly TokenResourceKey StatusSize = new TokenResourceKey("Badge.StatusSize"); + public static readonly TokenResourceKey BadgeFontHeight = new TokenResourceKey("Badge.BadgeFontHeight"); + public static readonly TokenResourceKey BadgeTextColor = new TokenResourceKey("Badge.BadgeTextColor"); + public static readonly TokenResourceKey BadgeColor = new TokenResourceKey("Badge.BadgeColor"); + public static readonly TokenResourceKey BadgeColorHover = new TokenResourceKey("Badge.BadgeColorHover"); + public static readonly TokenResourceKey BadgeShadowSize = new TokenResourceKey("Badge.BadgeShadowSize"); + public static readonly TokenResourceKey BadgeShadowColor = new TokenResourceKey("Badge.BadgeShadowColor"); + public static readonly TokenResourceKey BadgeProcessingDuration = new TokenResourceKey("Badge.BadgeProcessingDuration"); + public static readonly TokenResourceKey BadgeRibbonOffset = new TokenResourceKey("Badge.BadgeRibbonOffset"); + public static readonly TokenResourceKey BadgeRibbonCornerTransform = new TokenResourceKey("Badge.BadgeRibbonCornerTransform"); + public static readonly TokenResourceKey BadgeRibbonCornerDarkenAmount = new TokenResourceKey("Badge.BadgeRibbonCornerDarkenAmount"); } public static class ButtonResourceKey { - public const string FontWeight = "Button.FontWeight"; - public const string DefaultShadow = "Button.DefaultShadow"; - public const string PrimaryShadow = "Button.PrimaryShadow"; - public const string DangerShadow = "Button.DangerShadow"; - public const string PrimaryColor = "Button.PrimaryColor"; - public const string DefaultColor = "Button.DefaultColor"; - public const string DefaultBg = "Button.DefaultBg"; - public const string DefaultBorderColor = "Button.DefaultBorderColor"; - public const string DefaultBorderColorDisabled = "Button.DefaultBorderColorDisabled"; - public const string DangerColor = "Button.DangerColor"; - public const string DefaultHoverBg = "Button.DefaultHoverBg"; - public const string DefaultHoverColor = "Button.DefaultHoverColor"; - public const string DefaultHoverBorderColor = "Button.DefaultHoverBorderColor"; - public const string DefaultActiveBg = "Button.DefaultActiveBg"; - public const string DefaultActiveColor = "Button.DefaultActiveColor"; - public const string DefaultActiveBorderColor = "Button.DefaultActiveBorderColor"; - public const string BorderColorDisabled = "Button.BorderColorDisabled"; - public const string DefaultGhostColor = "Button.DefaultGhostColor"; - public const string GhostBg = "Button.GhostBg"; - public const string DefaultGhostBorderColor = "Button.DefaultGhostBorderColor"; - public const string Padding = "Button.Padding"; - public const string PaddingLG = "Button.PaddingLG"; - public const string PaddingSM = "Button.PaddingSM"; - public const string CirclePadding = "Button.CirclePadding"; - public const string OnlyIconSize = "Button.OnlyIconSize"; - public const string OnlyIconSizeLG = "Button.OnlyIconSizeLG"; - public const string OnlyIconSizeSM = "Button.OnlyIconSizeSM"; - public const string IconSize = "Button.IconSize"; - public const string IconSizeLG = "Button.IconSizeLG"; - public const string IconSizeSM = "Button.IconSizeSM"; - public const string GroupBorderColor = "Button.GroupBorderColor"; - public const string LinkHoverBg = "Button.LinkHoverBg"; - public const string TextHoverBg = "Button.TextHoverBg"; - public const string ContentFontSize = "Button.ContentFontSize"; - public const string ContentFontSizeLG = "Button.ContentFontSizeLG"; - public const string ContentFontSizeSM = "Button.ContentFontSizeSM"; - public const string ContentLineHeight = "Button.ContentLineHeight"; - public const string ContentLineHeightLG = "Button.ContentLineHeightLG"; - public const string ContentLineHeightSM = "Button.ContentLineHeightSM"; + public static readonly TokenResourceKey FontWeight = new TokenResourceKey("Button.FontWeight"); + public static readonly TokenResourceKey DefaultShadow = new TokenResourceKey("Button.DefaultShadow"); + public static readonly TokenResourceKey PrimaryShadow = new TokenResourceKey("Button.PrimaryShadow"); + public static readonly TokenResourceKey DangerShadow = new TokenResourceKey("Button.DangerShadow"); + public static readonly TokenResourceKey PrimaryColor = new TokenResourceKey("Button.PrimaryColor"); + public static readonly TokenResourceKey DefaultColor = new TokenResourceKey("Button.DefaultColor"); + public static readonly TokenResourceKey DefaultBg = new TokenResourceKey("Button.DefaultBg"); + public static readonly TokenResourceKey DefaultBorderColor = new TokenResourceKey("Button.DefaultBorderColor"); + public static readonly TokenResourceKey DefaultBorderColorDisabled = new TokenResourceKey("Button.DefaultBorderColorDisabled"); + public static readonly TokenResourceKey DangerColor = new TokenResourceKey("Button.DangerColor"); + public static readonly TokenResourceKey DefaultHoverBg = new TokenResourceKey("Button.DefaultHoverBg"); + public static readonly TokenResourceKey DefaultHoverColor = new TokenResourceKey("Button.DefaultHoverColor"); + public static readonly TokenResourceKey DefaultHoverBorderColor = new TokenResourceKey("Button.DefaultHoverBorderColor"); + public static readonly TokenResourceKey DefaultActiveBg = new TokenResourceKey("Button.DefaultActiveBg"); + public static readonly TokenResourceKey DefaultActiveColor = new TokenResourceKey("Button.DefaultActiveColor"); + public static readonly TokenResourceKey DefaultActiveBorderColor = new TokenResourceKey("Button.DefaultActiveBorderColor"); + public static readonly TokenResourceKey BorderColorDisabled = new TokenResourceKey("Button.BorderColorDisabled"); + public static readonly TokenResourceKey DefaultGhostColor = new TokenResourceKey("Button.DefaultGhostColor"); + public static readonly TokenResourceKey GhostBg = new TokenResourceKey("Button.GhostBg"); + public static readonly TokenResourceKey DefaultGhostBorderColor = new TokenResourceKey("Button.DefaultGhostBorderColor"); + public static readonly TokenResourceKey Padding = new TokenResourceKey("Button.Padding"); + public static readonly TokenResourceKey PaddingLG = new TokenResourceKey("Button.PaddingLG"); + public static readonly TokenResourceKey PaddingSM = new TokenResourceKey("Button.PaddingSM"); + public static readonly TokenResourceKey CirclePadding = new TokenResourceKey("Button.CirclePadding"); + public static readonly TokenResourceKey OnlyIconSize = new TokenResourceKey("Button.OnlyIconSize"); + public static readonly TokenResourceKey OnlyIconSizeLG = new TokenResourceKey("Button.OnlyIconSizeLG"); + public static readonly TokenResourceKey OnlyIconSizeSM = new TokenResourceKey("Button.OnlyIconSizeSM"); + public static readonly TokenResourceKey IconSize = new TokenResourceKey("Button.IconSize"); + public static readonly TokenResourceKey IconSizeLG = new TokenResourceKey("Button.IconSizeLG"); + public static readonly TokenResourceKey IconSizeSM = new TokenResourceKey("Button.IconSizeSM"); + public static readonly TokenResourceKey GroupBorderColor = new TokenResourceKey("Button.GroupBorderColor"); + public static readonly TokenResourceKey LinkHoverBg = new TokenResourceKey("Button.LinkHoverBg"); + public static readonly TokenResourceKey TextHoverBg = new TokenResourceKey("Button.TextHoverBg"); + public static readonly TokenResourceKey ContentFontSize = new TokenResourceKey("Button.ContentFontSize"); + public static readonly TokenResourceKey ContentFontSizeLG = new TokenResourceKey("Button.ContentFontSizeLG"); + public static readonly TokenResourceKey ContentFontSizeSM = new TokenResourceKey("Button.ContentFontSizeSM"); + public static readonly TokenResourceKey ContentLineHeight = new TokenResourceKey("Button.ContentLineHeight"); + public static readonly TokenResourceKey ContentLineHeightLG = new TokenResourceKey("Button.ContentLineHeightLG"); + public static readonly TokenResourceKey ContentLineHeightSM = new TokenResourceKey("Button.ContentLineHeightSM"); } public static class CheckBoxResourceKey { - public const string CheckIndicatorSize = "CheckBox.CheckIndicatorSize"; - public const string IndicatorTristateMarkSize = "CheckBox.IndicatorTristateMarkSize"; + public static readonly TokenResourceKey CheckIndicatorSize = new TokenResourceKey("CheckBox.CheckIndicatorSize"); + public static readonly TokenResourceKey IndicatorTristateMarkSize = new TokenResourceKey("CheckBox.IndicatorTristateMarkSize"); } public static class EmptyIndicatorResourceKey { - public const string EmptyImgHeight = "EmptyIndicator.EmptyImgHeight"; - public const string EmptyImgHeightSM = "EmptyIndicator.EmptyImgHeightSM"; - public const string EmptyImgHeightMD = "EmptyIndicator.EmptyImgHeightMD"; + public static readonly TokenResourceKey EmptyImgHeight = new TokenResourceKey("EmptyIndicator.EmptyImgHeight"); + public static readonly TokenResourceKey EmptyImgHeightSM = new TokenResourceKey("EmptyIndicator.EmptyImgHeightSM"); + public static readonly TokenResourceKey EmptyImgHeightMD = new TokenResourceKey("EmptyIndicator.EmptyImgHeightMD"); } public static class LoadingIndicatorResourceKey { - public const string DotSize = "LoadingIndicator.DotSize"; - public const string DotSizeSM = "LoadingIndicator.DotSizeSM"; - public const string DotSizeLG = "LoadingIndicator.DotSizeLG"; - public const string IndicatorDuration = "LoadingIndicator.IndicatorDuration"; + public static readonly TokenResourceKey DotSize = new TokenResourceKey("LoadingIndicator.DotSize"); + public static readonly TokenResourceKey DotSizeSM = new TokenResourceKey("LoadingIndicator.DotSizeSM"); + public static readonly TokenResourceKey DotSizeLG = new TokenResourceKey("LoadingIndicator.DotSizeLG"); + public static readonly TokenResourceKey IndicatorDuration = new TokenResourceKey("LoadingIndicator.IndicatorDuration"); } public static class MarqueeLabelResourceKey { - public const string CycleSpace = "MarqueeLabel.CycleSpace"; - public const string DefaultSpeed = "MarqueeLabel.DefaultSpeed"; + public static readonly TokenResourceKey CycleSpace = new TokenResourceKey("MarqueeLabel.CycleSpace"); + public static readonly TokenResourceKey DefaultSpeed = new TokenResourceKey("MarqueeLabel.DefaultSpeed"); } public static class OptionButtonResourceKey { - public const string ButtonBackground = "OptionButton.ButtonBackground"; - public const string ButtonCheckedBackground = "OptionButton.ButtonCheckedBackground"; - public const string ButtonColor = "OptionButton.ButtonColor"; - public const string ButtonPadding = "OptionButton.ButtonPadding"; - public const string ButtonCheckedBgDisabled = "OptionButton.ButtonCheckedBgDisabled"; - public const string ButtonCheckedColorDisabled = "OptionButton.ButtonCheckedColorDisabled"; - public const string ButtonSolidCheckedColor = "OptionButton.ButtonSolidCheckedColor"; - public const string ButtonSolidCheckedBackground = "OptionButton.ButtonSolidCheckedBackground"; - public const string ButtonSolidCheckedHoverBackground = "OptionButton.ButtonSolidCheckedHoverBackground"; - public const string ButtonSolidCheckedActiveBackground = "OptionButton.ButtonSolidCheckedActiveBackground"; - public const string ContentFontSize = "OptionButton.ContentFontSize"; - public const string ContentFontSizeLG = "OptionButton.ContentFontSizeLG"; - public const string ContentFontSizeSM = "OptionButton.ContentFontSizeSM"; - public const string ContentLineHeight = "OptionButton.ContentLineHeight"; - public const string ContentLineHeightLG = "OptionButton.ContentLineHeightLG"; - public const string ContentLineHeightSM = "OptionButton.ContentLineHeightSM"; - public const string Padding = "OptionButton.Padding"; - public const string PaddingLG = "OptionButton.PaddingLG"; - public const string PaddingSM = "OptionButton.PaddingSM"; + public static readonly TokenResourceKey ButtonBackground = new TokenResourceKey("OptionButton.ButtonBackground"); + public static readonly TokenResourceKey ButtonCheckedBackground = new TokenResourceKey("OptionButton.ButtonCheckedBackground"); + public static readonly TokenResourceKey ButtonColor = new TokenResourceKey("OptionButton.ButtonColor"); + public static readonly TokenResourceKey ButtonPadding = new TokenResourceKey("OptionButton.ButtonPadding"); + public static readonly TokenResourceKey ButtonCheckedBgDisabled = new TokenResourceKey("OptionButton.ButtonCheckedBgDisabled"); + public static readonly TokenResourceKey ButtonCheckedColorDisabled = new TokenResourceKey("OptionButton.ButtonCheckedColorDisabled"); + public static readonly TokenResourceKey ButtonSolidCheckedColor = new TokenResourceKey("OptionButton.ButtonSolidCheckedColor"); + public static readonly TokenResourceKey ButtonSolidCheckedBackground = new TokenResourceKey("OptionButton.ButtonSolidCheckedBackground"); + public static readonly TokenResourceKey ButtonSolidCheckedHoverBackground = new TokenResourceKey("OptionButton.ButtonSolidCheckedHoverBackground"); + public static readonly TokenResourceKey ButtonSolidCheckedActiveBackground = new TokenResourceKey("OptionButton.ButtonSolidCheckedActiveBackground"); + public static readonly TokenResourceKey ContentFontSize = new TokenResourceKey("OptionButton.ContentFontSize"); + public static readonly TokenResourceKey ContentFontSizeLG = new TokenResourceKey("OptionButton.ContentFontSizeLG"); + public static readonly TokenResourceKey ContentFontSizeSM = new TokenResourceKey("OptionButton.ContentFontSizeSM"); + public static readonly TokenResourceKey ContentLineHeight = new TokenResourceKey("OptionButton.ContentLineHeight"); + public static readonly TokenResourceKey ContentLineHeightLG = new TokenResourceKey("OptionButton.ContentLineHeightLG"); + public static readonly TokenResourceKey ContentLineHeightSM = new TokenResourceKey("OptionButton.ContentLineHeightSM"); + public static readonly TokenResourceKey Padding = new TokenResourceKey("OptionButton.Padding"); + public static readonly TokenResourceKey PaddingLG = new TokenResourceKey("OptionButton.PaddingLG"); + public static readonly TokenResourceKey PaddingSM = new TokenResourceKey("OptionButton.PaddingSM"); } public static class ProgressBarResourceKey { - public const string DefaultColor = "ProgressBar.DefaultColor"; - public const string RemainingColor = "ProgressBar.RemainingColor"; - public const string CircleTextColor = "ProgressBar.CircleTextColor"; - public const string LineBorderRadius = "ProgressBar.LineBorderRadius"; - public const string CircleMinimumTextFontSize = "ProgressBar.CircleMinimumTextFontSize"; - public const string CircleMinimumIconSize = "ProgressBar.CircleMinimumIconSize"; - public const string ProgressStepMinWidth = "ProgressBar.ProgressStepMinWidth"; - public const string ProgressStepMarginInlineEnd = "ProgressBar.ProgressStepMarginInlineEnd"; - public const string ProgressActiveMotionDuration = "ProgressBar.ProgressActiveMotionDuration"; - public const string LineExtraInfoMargin = "ProgressBar.LineExtraInfoMargin"; - public const string LineProgressPadding = "ProgressBar.LineProgressPadding"; - public const string LineInfoIconSize = "ProgressBar.LineInfoIconSize"; - public const string LineInfoIconSizeSM = "ProgressBar.LineInfoIconSizeSM"; + public static readonly TokenResourceKey DefaultColor = new TokenResourceKey("ProgressBar.DefaultColor"); + public static readonly TokenResourceKey RemainingColor = new TokenResourceKey("ProgressBar.RemainingColor"); + public static readonly TokenResourceKey CircleTextColor = new TokenResourceKey("ProgressBar.CircleTextColor"); + public static readonly TokenResourceKey LineBorderRadius = new TokenResourceKey("ProgressBar.LineBorderRadius"); + public static readonly TokenResourceKey CircleMinimumTextFontSize = new TokenResourceKey("ProgressBar.CircleMinimumTextFontSize"); + public static readonly TokenResourceKey CircleMinimumIconSize = new TokenResourceKey("ProgressBar.CircleMinimumIconSize"); + public static readonly TokenResourceKey ProgressStepMinWidth = new TokenResourceKey("ProgressBar.ProgressStepMinWidth"); + public static readonly TokenResourceKey ProgressStepMarginInlineEnd = new TokenResourceKey("ProgressBar.ProgressStepMarginInlineEnd"); + public static readonly TokenResourceKey ProgressActiveMotionDuration = new TokenResourceKey("ProgressBar.ProgressActiveMotionDuration"); + public static readonly TokenResourceKey LineExtraInfoMargin = new TokenResourceKey("ProgressBar.LineExtraInfoMargin"); + public static readonly TokenResourceKey LineProgressPadding = new TokenResourceKey("ProgressBar.LineProgressPadding"); + public static readonly TokenResourceKey LineInfoIconSize = new TokenResourceKey("ProgressBar.LineInfoIconSize"); + public static readonly TokenResourceKey LineInfoIconSizeSM = new TokenResourceKey("ProgressBar.LineInfoIconSizeSM"); } public static class RadioButtonResourceKey { - public const string RadioSize = "RadioButton.RadioSize"; - public const string DotSize = "RadioButton.DotSize"; - public const string DotColorDisabled = "RadioButton.DotColorDisabled"; - public const string RadioColor = "RadioButton.RadioColor"; - public const string RadioBgColor = "RadioButton.RadioBgColor"; - public const string DotPadding = "RadioButton.DotPadding"; + public static readonly TokenResourceKey RadioSize = new TokenResourceKey("RadioButton.RadioSize"); + public static readonly TokenResourceKey DotSize = new TokenResourceKey("RadioButton.DotSize"); + public static readonly TokenResourceKey DotColorDisabled = new TokenResourceKey("RadioButton.DotColorDisabled"); + public static readonly TokenResourceKey RadioColor = new TokenResourceKey("RadioButton.RadioColor"); + public static readonly TokenResourceKey RadioBgColor = new TokenResourceKey("RadioButton.RadioBgColor"); + public static readonly TokenResourceKey DotPadding = new TokenResourceKey("RadioButton.DotPadding"); } public static class SegmentedResourceKey { - public const string ItemColor = "Segmented.ItemColor"; - public const string ItemHoverColor = "Segmented.ItemHoverColor"; - public const string ItemHoverBg = "Segmented.ItemHoverBg"; - public const string ItemActiveBg = "Segmented.ItemActiveBg"; - public const string ItemSelectedBg = "Segmented.ItemSelectedBg"; - public const string ItemSelectedColor = "Segmented.ItemSelectedColor"; - public const string TrackPadding = "Segmented.TrackPadding"; - public const string TrackBg = "Segmented.TrackBg"; - public const string SegmentedItemPadding = "Segmented.SegmentedItemPadding"; - public const string SegmentedItemPaddingSM = "Segmented.SegmentedItemPaddingSM"; - public const string SegmentedTextLabelMargin = "Segmented.SegmentedTextLabelMargin"; + public static readonly TokenResourceKey ItemColor = new TokenResourceKey("Segmented.ItemColor"); + public static readonly TokenResourceKey ItemHoverColor = new TokenResourceKey("Segmented.ItemHoverColor"); + public static readonly TokenResourceKey ItemHoverBg = new TokenResourceKey("Segmented.ItemHoverBg"); + public static readonly TokenResourceKey ItemActiveBg = new TokenResourceKey("Segmented.ItemActiveBg"); + public static readonly TokenResourceKey ItemSelectedBg = new TokenResourceKey("Segmented.ItemSelectedBg"); + public static readonly TokenResourceKey ItemSelectedColor = new TokenResourceKey("Segmented.ItemSelectedColor"); + public static readonly TokenResourceKey TrackPadding = new TokenResourceKey("Segmented.TrackPadding"); + public static readonly TokenResourceKey TrackBg = new TokenResourceKey("Segmented.TrackBg"); + public static readonly TokenResourceKey SegmentedItemPadding = new TokenResourceKey("Segmented.SegmentedItemPadding"); + public static readonly TokenResourceKey SegmentedItemPaddingSM = new TokenResourceKey("Segmented.SegmentedItemPaddingSM"); + public static readonly TokenResourceKey SegmentedTextLabelMargin = new TokenResourceKey("Segmented.SegmentedTextLabelMargin"); } public static class SeparatorResourceKey { - public const string TextPaddingInline = "Separator.TextPaddingInline"; - public const string OrientationMarginPercent = "Separator.OrientationMarginPercent"; - public const string VerticalMarginInline = "Separator.VerticalMarginInline"; + public static readonly TokenResourceKey TextPaddingInline = new TokenResourceKey("Separator.TextPaddingInline"); + public static readonly TokenResourceKey OrientationMarginPercent = new TokenResourceKey("Separator.OrientationMarginPercent"); + public static readonly TokenResourceKey VerticalMarginInline = new TokenResourceKey("Separator.VerticalMarginInline"); } public static class ToggleSwitchResourceKey { - public const string TrackHeight = "ToggleSwitch.TrackHeight"; - public const string TrackHeightSM = "ToggleSwitch.TrackHeightSM"; - public const string TrackMinWidth = "ToggleSwitch.TrackMinWidth"; - public const string TrackMinWidthSM = "ToggleSwitch.TrackMinWidthSM"; - public const string TrackPadding = "ToggleSwitch.TrackPadding"; - public const string HandleBg = "ToggleSwitch.HandleBg"; - public const string HandleShadow = "ToggleSwitch.HandleShadow"; - public const string HandleSize = "ToggleSwitch.HandleSize"; - public const string HandleSizeSM = "ToggleSwitch.HandleSizeSM"; - public const string InnerMinMargin = "ToggleSwitch.InnerMinMargin"; - public const string InnerMaxMargin = "ToggleSwitch.InnerMaxMargin"; - public const string InnerMinMarginSM = "ToggleSwitch.InnerMinMarginSM"; - public const string InnerMaxMarginSM = "ToggleSwitch.InnerMaxMarginSM"; - public const string SwitchDuration = "ToggleSwitch.SwitchDuration"; - public const string SwitchColor = "ToggleSwitch.SwitchColor"; - public const string SwitchDisabledOpacity = "ToggleSwitch.SwitchDisabledOpacity"; - public const string SwitchLoadingIconSize = "ToggleSwitch.SwitchLoadingIconSize"; - public const string SwitchLoadingIconColor = "ToggleSwitch.SwitchLoadingIconColor"; - public const string ExtraInfoFontSize = "ToggleSwitch.ExtraInfoFontSize"; - public const string ExtraInfoFontSizeSM = "ToggleSwitch.ExtraInfoFontSizeSM"; + public static readonly TokenResourceKey TrackHeight = new TokenResourceKey("ToggleSwitch.TrackHeight"); + public static readonly TokenResourceKey TrackHeightSM = new TokenResourceKey("ToggleSwitch.TrackHeightSM"); + public static readonly TokenResourceKey TrackMinWidth = new TokenResourceKey("ToggleSwitch.TrackMinWidth"); + public static readonly TokenResourceKey TrackMinWidthSM = new TokenResourceKey("ToggleSwitch.TrackMinWidthSM"); + public static readonly TokenResourceKey TrackPadding = new TokenResourceKey("ToggleSwitch.TrackPadding"); + public static readonly TokenResourceKey HandleBg = new TokenResourceKey("ToggleSwitch.HandleBg"); + public static readonly TokenResourceKey HandleShadow = new TokenResourceKey("ToggleSwitch.HandleShadow"); + public static readonly TokenResourceKey HandleSize = new TokenResourceKey("ToggleSwitch.HandleSize"); + public static readonly TokenResourceKey HandleSizeSM = new TokenResourceKey("ToggleSwitch.HandleSizeSM"); + public static readonly TokenResourceKey InnerMinMargin = new TokenResourceKey("ToggleSwitch.InnerMinMargin"); + public static readonly TokenResourceKey InnerMaxMargin = new TokenResourceKey("ToggleSwitch.InnerMaxMargin"); + public static readonly TokenResourceKey InnerMinMarginSM = new TokenResourceKey("ToggleSwitch.InnerMinMarginSM"); + public static readonly TokenResourceKey InnerMaxMarginSM = new TokenResourceKey("ToggleSwitch.InnerMaxMarginSM"); + public static readonly TokenResourceKey SwitchDuration = new TokenResourceKey("ToggleSwitch.SwitchDuration"); + public static readonly TokenResourceKey SwitchColor = new TokenResourceKey("ToggleSwitch.SwitchColor"); + public static readonly TokenResourceKey SwitchDisabledOpacity = new TokenResourceKey("ToggleSwitch.SwitchDisabledOpacity"); + public static readonly TokenResourceKey SwitchLoadingIconSize = new TokenResourceKey("ToggleSwitch.SwitchLoadingIconSize"); + public static readonly TokenResourceKey SwitchLoadingIconColor = new TokenResourceKey("ToggleSwitch.SwitchLoadingIconColor"); + public static readonly TokenResourceKey ExtraInfoFontSize = new TokenResourceKey("ToggleSwitch.ExtraInfoFontSize"); + public static readonly TokenResourceKey ExtraInfoFontSizeSM = new TokenResourceKey("ToggleSwitch.ExtraInfoFontSizeSM"); } public static class TagResourceKey { - public const string DefaultBg = "Tag.DefaultBg"; - public const string DefaultColor = "Tag.DefaultColor"; - public const string TagFontSize = "Tag.TagFontSize"; - public const string TagLineHeight = "Tag.TagLineHeight"; - public const string TagIconSize = "Tag.TagIconSize"; - public const string TagCloseIconSize = "Tag.TagCloseIconSize"; - public const string TagPadding = "Tag.TagPadding"; - public const string TagBorderlessBg = "Tag.TagBorderlessBg"; + public static readonly TokenResourceKey DefaultBg = new TokenResourceKey("Tag.DefaultBg"); + public static readonly TokenResourceKey DefaultColor = new TokenResourceKey("Tag.DefaultColor"); + public static readonly TokenResourceKey TagFontSize = new TokenResourceKey("Tag.TagFontSize"); + public static readonly TokenResourceKey TagLineHeight = new TokenResourceKey("Tag.TagLineHeight"); + public static readonly TokenResourceKey TagIconSize = new TokenResourceKey("Tag.TagIconSize"); + public static readonly TokenResourceKey TagCloseIconSize = new TokenResourceKey("Tag.TagCloseIconSize"); + public static readonly TokenResourceKey TagPadding = new TokenResourceKey("Tag.TagPadding"); + public static readonly TokenResourceKey TagBorderlessBg = new TokenResourceKey("Tag.TagBorderlessBg"); } public static class ToolTipResourceKey { - public const string ToolTipMaxWidth = "ToolTip.ToolTipMaxWidth"; - public const string ToolTipColor = "ToolTip.ToolTipColor"; - public const string ToolTipBackground = "ToolTip.ToolTipBackground"; - public const string BorderRadiusOuter = "ToolTip.BorderRadiusOuter"; - public const string ToolTipPadding = "ToolTip.ToolTipPadding"; - public const string ToolTipArrowSize = "ToolTip.ToolTipArrowSize"; + public static readonly TokenResourceKey ToolTipMaxWidth = new TokenResourceKey("ToolTip.ToolTipMaxWidth"); + public static readonly TokenResourceKey ToolTipColor = new TokenResourceKey("ToolTip.ToolTipColor"); + public static readonly TokenResourceKey ToolTipBackground = new TokenResourceKey("ToolTip.ToolTipBackground"); + public static readonly TokenResourceKey BorderRadiusOuter = new TokenResourceKey("ToolTip.BorderRadiusOuter"); + public static readonly TokenResourceKey ToolTipPadding = new TokenResourceKey("ToolTip.ToolTipPadding"); + public static readonly TokenResourceKey ToolTipArrowSize = new TokenResourceKey("ToolTip.ToolTipArrowSize"); } public static class CaptionButtonResourceKey { - public const string HoverBackgroundColor = "CaptionButton.HoverBackgroundColor"; - public const string PressedBackgroundColor = "CaptionButton.PressedBackgroundColor"; - public const string CloseHoverBackgroundColor = "CaptionButton.CloseHoverBackgroundColor"; - public const string ClosePressedBackgroundColor = "CaptionButton.ClosePressedBackgroundColor"; - public const string ForegroundColor = "CaptionButton.ForegroundColor"; + public static readonly TokenResourceKey HoverBackgroundColor = new TokenResourceKey("CaptionButton.HoverBackgroundColor"); + public static readonly TokenResourceKey PressedBackgroundColor = new TokenResourceKey("CaptionButton.PressedBackgroundColor"); + public static readonly TokenResourceKey CloseHoverBackgroundColor = new TokenResourceKey("CaptionButton.CloseHoverBackgroundColor"); + public static readonly TokenResourceKey ClosePressedBackgroundColor = new TokenResourceKey("CaptionButton.ClosePressedBackgroundColor"); + public static readonly TokenResourceKey ForegroundColor = new TokenResourceKey("CaptionButton.ForegroundColor"); } public static class WindowResourceKey { - public const string DefaultBackground = "Window.DefaultBackground"; - public const string DefaultForeground = "Window.DefaultForeground"; + public static readonly TokenResourceKey DefaultBackground = new TokenResourceKey("Window.DefaultBackground"); + public static readonly TokenResourceKey DefaultForeground = new TokenResourceKey("Window.DefaultForeground"); } } \ No newline at end of file diff --git a/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs b/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs index ed7e1a0d1..1fffdc1f8 100644 --- a/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs +++ b/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs @@ -112,7 +112,7 @@ public partial class MarqueeLabel : TextBlock, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); } void IControlCustomStyle.ApplyFixedStyleConfig() diff --git a/src/AtomUI.Controls/OptionButtonBox/OptionButton.cs b/src/AtomUI.Controls/OptionButtonBox/OptionButton.cs index ebc9c97dd..9c0631793 100644 --- a/src/AtomUI.Controls/OptionButtonBox/OptionButton.cs +++ b/src/AtomUI.Controls/OptionButtonBox/OptionButton.cs @@ -50,7 +50,6 @@ public partial class OptionButton : AvaloniaRadioButton, private bool _initialized = false; private ControlStyleState _styleState; private IControlCustomStyle _customStyle; - private ControlTokenBinder _controlTokenBinder; private StackPanel? _stackPanel; private Label? _label; private CornerRadius? _originCornerRadius; @@ -123,7 +122,6 @@ public partial class OptionButton : AvaloniaRadioButton, public OptionButton() { - _controlTokenBinder = new ControlTokenBinder(this, OptionButtonToken.ID); _customStyle = this; } @@ -234,7 +232,7 @@ public partial class OptionButton : AvaloniaRadioButton, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { @@ -248,9 +246,9 @@ public partial class OptionButton : AvaloniaRadioButton, void IControlCustomStyle.ApplyFixedStyleConfig() { - _controlTokenBinder.AddControlBinding(MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); - _controlTokenBinder.AddControlBinding(ColorPrimaryHoverTokenProperty, GlobalResourceKey.ColorPrimaryHover); - _controlTokenBinder.AddControlBinding(ColorPrimaryActiveTokenProperty, GlobalResourceKey.ColorPrimaryActive); + BindUtils.CreateTokenBinding(this, MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); + BindUtils.CreateTokenBinding(this, ColorPrimaryHoverTokenProperty, GlobalResourceKey.ColorPrimaryHover); + BindUtils.CreateTokenBinding(this, ColorPrimaryActiveTokenProperty, GlobalResourceKey.ColorPrimaryActive); } void IControlCustomStyle.ApplyRenderScalingAwareStyleConfig() @@ -333,7 +331,6 @@ public partial class OptionButton : AvaloniaRadioButton, void IControlCustomStyle.ApplyVariableStyleConfig() { - _controlTokenBinder.ReleaseTriggerBindings(this); if (ButtonStyle == OptionButtonStyle.Outline) { ApplyOutlineStyle(); } else if (ButtonStyle == OptionButtonStyle.Solid) { @@ -344,20 +341,20 @@ public partial class OptionButton : AvaloniaRadioButton, void IControlCustomStyle.ApplySizeTypeStyleConfig() { if (SizeType == ButtonSizeType.Small) { - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeightSM); - _controlTokenBinder.AddControlBinding(FontSizeProperty, OptionButtonResourceKey.ContentFontSizeSM); - _controlTokenBinder.AddControlBinding(PaddingProperty, OptionButtonResourceKey.PaddingSM); - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeightSM); + BindUtils.CreateTokenBinding(this, FontSizeProperty, OptionButtonResourceKey.ContentFontSizeSM); + BindUtils.CreateTokenBinding(this, PaddingProperty, OptionButtonResourceKey.PaddingSM); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); } else if (SizeType == ButtonSizeType.Middle) { - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); - _controlTokenBinder.AddControlBinding(FontSizeProperty, OptionButtonResourceKey.ContentFontSize); - _controlTokenBinder.AddControlBinding(PaddingProperty, OptionButtonResourceKey.Padding); - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadius); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); + BindUtils.CreateTokenBinding(this, FontSizeProperty, OptionButtonResourceKey.ContentFontSize); + BindUtils.CreateTokenBinding(this, PaddingProperty, OptionButtonResourceKey.Padding); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadius); } else if (SizeType == ButtonSizeType.Large) { - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeightLG); - _controlTokenBinder.AddControlBinding(FontSizeProperty, OptionButtonResourceKey.ContentFontSizeLG); - _controlTokenBinder.AddControlBinding(PaddingProperty, OptionButtonResourceKey.PaddingLG); - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusLG); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeightLG); + BindUtils.CreateTokenBinding(this, FontSizeProperty, OptionButtonResourceKey.ContentFontSizeLG); + BindUtils.CreateTokenBinding(this, PaddingProperty, OptionButtonResourceKey.PaddingLG); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusLG); } _originCornerRadius = CornerRadius; @@ -368,41 +365,41 @@ public partial class OptionButton : AvaloniaRadioButton, { if (_styleState.HasFlag(ControlStyleState.Enabled)) { if (_styleState.HasFlag(ControlStyleState.Selected)) { - _controlTokenBinder.AddControlBinding(ForegroundProperty, OptionButtonResourceKey.ButtonSolidCheckedColor); - _controlTokenBinder.AddControlBinding(BackgroundProperty, OptionButtonResourceKey.ButtonSolidCheckedBackground); + BindUtils.CreateTokenBinding(this, ForegroundProperty, OptionButtonResourceKey.ButtonSolidCheckedColor); + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonSolidCheckedBackground); if (_styleState.HasFlag(ControlStyleState.Sunken)) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonSolidCheckedActiveBackground, BindingPriority.StyleTrigger); } else if (_styleState.HasFlag(ControlStyleState.MouseOver)) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonSolidCheckedHoverBackground, BindingPriority.StyleTrigger); } } else { - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorText); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorText); if (InOptionGroup) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, GlobalResourceKey.ColorTransparent); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorTransparent); } else { - _controlTokenBinder.AddControlBinding(BackgroundProperty, GlobalResourceKey.ColorBgContainer); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorBgContainer); } if (_styleState.HasFlag(ControlStyleState.Sunken)) { - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); } else if (_styleState.HasFlag(ControlStyleState.MouseOver)) { - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); } } } else { - _controlTokenBinder.AddControlBinding(BorderBrushProperty, GlobalResourceKey.ColorBorder); + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorBorder); if (_styleState.HasFlag(ControlStyleState.Selected)) { - _controlTokenBinder.AddControlBinding(ForegroundProperty, OptionButtonResourceKey.ButtonCheckedColorDisabled); - _controlTokenBinder.AddControlBinding(BackgroundProperty, OptionButtonResourceKey.ButtonCheckedBgDisabled); + BindUtils.CreateTokenBinding(this, ForegroundProperty, OptionButtonResourceKey.ButtonCheckedColorDisabled); + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonCheckedBgDisabled); } else { - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorTextDisabled); - _controlTokenBinder.AddControlBinding(BackgroundProperty, GlobalResourceKey.ColorBgContainerDisabled); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextDisabled); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorBgContainerDisabled); } } } @@ -412,55 +409,55 @@ public partial class OptionButton : AvaloniaRadioButton, if (_styleState.HasFlag(ControlStyleState.Enabled)) { if (_styleState.HasFlag(ControlStyleState.Selected)) { if (InOptionGroup) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, GlobalResourceKey.ColorTransparent); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorTransparent); } else { - _controlTokenBinder.AddControlBinding(BackgroundProperty, OptionButtonResourceKey.ButtonBackground); + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonBackground); } - _controlTokenBinder.AddControlBinding(BorderBrushProperty, GlobalResourceKey.ColorPrimary); - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorPrimary); + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimary); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimary); if (_styleState.HasFlag(ControlStyleState.Sunken)) { - _controlTokenBinder.AddControlBinding(BorderBrushProperty, GlobalResourceKey.ColorPrimaryActive, + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); } else if (_styleState.HasFlag(ControlStyleState.MouseOver)) { - _controlTokenBinder.AddControlBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryHover, + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); } } else { if (InOptionGroup) { - _controlTokenBinder.AddControlBinding(this, BackgroundProperty, GlobalResourceKey.ColorTransparent); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorTransparent); } else { - _controlTokenBinder.AddControlBinding(this, BackgroundProperty, + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonCheckedBackground); } - _controlTokenBinder.AddControlBinding(this, BorderBrushProperty, GlobalResourceKey.ColorBorder); - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, OptionButtonResourceKey.ButtonColor); + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorBorder); + BindUtils.CreateTokenBinding(this, ForegroundProperty, OptionButtonResourceKey.ButtonColor); if (_styleState.HasFlag(ControlStyleState.Sunken)) { - _controlTokenBinder.AddControlBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryActive, + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); } else if (_styleState.HasFlag(ControlStyleState.MouseOver)) { - _controlTokenBinder.AddControlBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryHover, + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); } } } else { - _controlTokenBinder.AddControlBinding(this, BorderBrushProperty, GlobalResourceKey.ColorBorder); + BindUtils.CreateTokenBinding(this, BorderBrushProperty, GlobalResourceKey.ColorBorder); if (_styleState.HasFlag(ControlStyleState.Selected)) { - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, + BindUtils.CreateTokenBinding(this, ForegroundProperty, OptionButtonResourceKey.ButtonCheckedColorDisabled); - _controlTokenBinder.AddControlBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonCheckedBgDisabled); + BindUtils.CreateTokenBinding(this, BackgroundProperty, OptionButtonResourceKey.ButtonCheckedBgDisabled); } else { - _controlTokenBinder.AddControlBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextDisabled); - _controlTokenBinder.AddControlBinding(this, BackgroundProperty, GlobalResourceKey.ColorBgContainerDisabled); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextDisabled); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorBgContainerDisabled); } } } diff --git a/src/AtomUI.Controls/OptionButtonBox/OptionButtonGroup.cs b/src/AtomUI.Controls/OptionButtonBox/OptionButtonGroup.cs index 7dcd57e23..8aba5aa61 100644 --- a/src/AtomUI.Controls/OptionButtonBox/OptionButtonGroup.cs +++ b/src/AtomUI.Controls/OptionButtonBox/OptionButtonGroup.cs @@ -88,7 +88,6 @@ public partial class OptionButtonGroup : StyledControl, private bool _initialized = false; private ControlStyleState _styleState; private IControlCustomStyle _customStyle; - private ControlTokenBinder _controlTokenBinder; private StackPanel? _layout; private readonly BorderRenderHelper _borderRenderHelper = new BorderRenderHelper(); @@ -101,7 +100,6 @@ public partial class OptionButtonGroup : StyledControl, public OptionButtonGroup() { - _controlTokenBinder = new ControlTokenBinder(this, OptionButtonToken.ID); _customStyle = this; _customStyle.InitOnConstruct(); Options.CollectionChanged += OptionsChanged; @@ -248,17 +246,17 @@ public partial class OptionButtonGroup : StyledControl, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); } void IControlCustomStyle.ApplyFixedStyleConfig() { - _controlTokenBinder.AddControlBinding(MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); - _controlTokenBinder.AddControlBinding(ColorBorderTokenProperty, GlobalResourceKey.ColorBorder); - _controlTokenBinder.AddControlBinding(ColorPrimaryTokenProperty, GlobalResourceKey.ColorPrimary); - _controlTokenBinder.AddControlBinding(ColorPrimaryHoverTokenProperty, GlobalResourceKey.ColorPrimaryHover); - _controlTokenBinder.AddControlBinding(ColorPrimaryActiveTokenProperty, GlobalResourceKey.ColorPrimaryActive); - _controlTokenBinder.AddControlBinding(SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimary); + BindUtils.CreateTokenBinding(this, MotionDurationTokenProperty, GlobalResourceKey.MotionDurationMid); + BindUtils.CreateTokenBinding(this, ColorBorderTokenProperty, GlobalResourceKey.ColorBorder); + BindUtils.CreateTokenBinding(this, ColorPrimaryTokenProperty, GlobalResourceKey.ColorPrimary); + BindUtils.CreateTokenBinding(this, ColorPrimaryHoverTokenProperty, GlobalResourceKey.ColorPrimaryHover); + BindUtils.CreateTokenBinding(this, ColorPrimaryActiveTokenProperty, GlobalResourceKey.ColorPrimaryActive); + BindUtils.CreateTokenBinding(this, SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimary); } void IControlCustomStyle.ApplyRenderScalingAwareStyleConfig() @@ -279,14 +277,14 @@ public partial class OptionButtonGroup : StyledControl, void IControlCustomStyle.ApplySizeTypeStyleConfig() { if (SizeType == SizeType.Small) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeightSM); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeightSM); } else if (SizeType == SizeType.Middle) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadius); - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadius); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); } else if (SizeType == SizeType.Large) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusLG); - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeightLG); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusLG); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeightLG); } ApplyButtonSizeConfig(); @@ -370,11 +368,10 @@ public partial class OptionButtonGroup : StyledControl, private void HandleOptionPointerEvent(object? sender, OptionButtonPointerEventArgs args) { if (args.Button == SelectedOption) { - _controlTokenBinder.ReleaseTriggerBindings(this); if (args.IsPressed) { - _controlTokenBinder.AddControlBinding(SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); + BindUtils.CreateTokenBinding(this, SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimaryActive, BindingPriority.StyleTrigger); } else if (args.IsHovering) { - _controlTokenBinder.AddControlBinding(SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); + BindUtils.CreateTokenBinding(this, SelectedOptionBorderColorProperty, GlobalResourceKey.ColorPrimaryHover, BindingPriority.StyleTrigger); } } } diff --git a/src/AtomUI.Controls/Popup/Popup.cs b/src/AtomUI.Controls/Popup/Popup.cs index 1e8d9efae..39c739ad0 100644 --- a/src/AtomUI.Controls/Popup/Popup.cs +++ b/src/AtomUI.Controls/Popup/Popup.cs @@ -50,7 +50,6 @@ public class Popup : AbstractPopup private static readonly MethodInfo ConfigurePositionMethodInfo; private PopupShadowLayer? _shadowLayer; - private readonly GlobalTokenBinder _globalTokenBinder; private CompositeDisposable? _compositeDisposable; private bool _initialized; @@ -66,14 +65,13 @@ public class Popup : AbstractPopup public Popup() { IsLightDismissEnabled = false; - _globalTokenBinder = new GlobalTokenBinder(); } protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); if (!_initialized) { - _globalTokenBinder.AddGlobalBinding(this, MaskShadowsProperty, GlobalResourceKey.BoxShadowsSecondary); + BindUtils.CreateGlobalTokenBinding(this, MaskShadowsProperty, GlobalResourceKey.BoxShadowsSecondary); _initialized = true; } } diff --git a/src/AtomUI.Controls/ProgressBar/AbstractCircleProgress.cs b/src/AtomUI.Controls/ProgressBar/AbstractCircleProgress.cs index f28aa5e34..71b58645e 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractCircleProgress.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractCircleProgress.cs @@ -244,16 +244,16 @@ public abstract partial class AbstractCircleProgress : AbstractProgressBar HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorError); - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); + BindUtils.CreateTokenBinding(_exceptionCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorError); + BindUtils.CreateTokenBinding(_exceptionCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); _successCompletedIcon = new PathIcon { Kind = "CheckOutlined", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; - _controlTokenBinder.AddControlBinding(_successCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorSuccess); - _controlTokenBinder.AddControlBinding(_successCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); + BindUtils.CreateTokenBinding(_successCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorSuccess); + BindUtils.CreateTokenBinding(_successCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); _successCompletedIcon.IsVisible = false; _exceptionCompletedIcon.IsVisible = false; AddChildControl(_exceptionCompletedIcon); @@ -263,8 +263,8 @@ public abstract partial class AbstractCircleProgress : AbstractProgressBar protected override void NotifyApplyFixedStyleConfig() { base.NotifyApplyFixedStyleConfig(); - _controlTokenBinder.AddControlBinding(CircleMinimumTextFontSizeTokenProperty, ProgressBarResourceKey.CircleMinimumTextFontSize); - _controlTokenBinder.AddControlBinding(CircleMinimumIconSizeTokenProperty, ProgressBarResourceKey.CircleMinimumIconSize); + BindUtils.CreateTokenBinding(this, CircleMinimumTextFontSizeTokenProperty, ProgressBarResourceKey.CircleMinimumTextFontSize); + BindUtils.CreateTokenBinding(this, CircleMinimumIconSizeTokenProperty, ProgressBarResourceKey.CircleMinimumIconSize); } protected override void NotifyEffectSizeTypeChanged() diff --git a/src/AtomUI.Controls/ProgressBar/AbstractLineProgress.cs b/src/AtomUI.Controls/ProgressBar/AbstractLineProgress.cs index a944bac38..197d0a5db 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractLineProgress.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractLineProgress.cs @@ -64,9 +64,9 @@ public abstract partial class AbstractLineProgress : AbstractProgressBar { base.ApplyEffectiveSizeTypeStyleConfig(); if (EffectiveSizeType == SizeType.Large || EffectiveSizeType == SizeType.Middle) { - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSize); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSize); } else { - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSizeSM); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSizeSM); } } @@ -120,13 +120,13 @@ public abstract partial class AbstractLineProgress : AbstractProgressBar protected override void NotifyApplyFixedStyleConfig() { base.NotifyApplyFixedStyleConfig(); - _controlTokenBinder.AddControlBinding(LineProgressPaddingTokenProperty, ProgressBarResourceKey.LineProgressPadding); - _controlTokenBinder.AddControlBinding(LineExtraInfoMarginTokenProperty, ProgressBarResourceKey.LineExtraInfoMargin); - _controlTokenBinder.AddControlBinding(FontSizeTokenProperty, GlobalResourceKey.FontSize); - _controlTokenBinder.AddControlBinding(FontSizeSMTokenProperty, GlobalResourceKey.FontSizeSM); + BindUtils.CreateTokenBinding(this, LineProgressPaddingTokenProperty, ProgressBarResourceKey.LineProgressPadding); + BindUtils.CreateTokenBinding(this, LineExtraInfoMarginTokenProperty, ProgressBarResourceKey.LineExtraInfoMargin); + BindUtils.CreateTokenBinding(this, FontSizeTokenProperty, GlobalResourceKey.FontSize); + BindUtils.CreateTokenBinding(this, FontSizeSMTokenProperty, GlobalResourceKey.FontSizeSM); - _controlTokenBinder.AddControlBinding(LineInfoIconSizeTokenProperty, ProgressBarResourceKey.LineInfoIconSize); - _controlTokenBinder.AddControlBinding(LineInfoIconSizeSMTokenProperty, ProgressBarResourceKey.LineInfoIconSizeSM); + BindUtils.CreateTokenBinding(this, LineInfoIconSizeTokenProperty, ProgressBarResourceKey.LineInfoIconSize); + BindUtils.CreateTokenBinding(this, LineInfoIconSizeSMTokenProperty, ProgressBarResourceKey.LineInfoIconSizeSM); } protected override void CreateCompletedIcons() @@ -136,15 +136,15 @@ public abstract partial class AbstractLineProgress : AbstractProgressBar Kind = "CloseCircleFilled", HorizontalAlignment = HorizontalAlignment.Left }; - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorError); - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); + BindUtils.CreateTokenBinding(_exceptionCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorError); + BindUtils.CreateTokenBinding(_exceptionCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); _successCompletedIcon = new PathIcon { Kind = "CheckCircleFilled", HorizontalAlignment = HorizontalAlignment.Left }; - _controlTokenBinder.AddControlBinding(_successCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorSuccess); - _controlTokenBinder.AddControlBinding(_successCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); + BindUtils.CreateTokenBinding(_successCompletedIcon, PathIcon.NormalFillBrushProperty, GlobalResourceKey.ColorSuccess); + BindUtils.CreateTokenBinding(_successCompletedIcon, PathIcon.DisabledFilledBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); _successCompletedIcon.IsVisible = false; _exceptionCompletedIcon.IsVisible = false; AddChildControl(_exceptionCompletedIcon); @@ -156,28 +156,28 @@ public abstract partial class AbstractLineProgress : AbstractProgressBar base.NotifyEffectSizeTypeChanged(); if (_initialized) { if (EffectiveSizeType == SizeType.Large) { - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon!, WidthProperty, + BindUtils.CreateTokenBinding(_exceptionCompletedIcon!, WidthProperty, ProgressBarResourceKey.LineInfoIconSize, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon!, HeightProperty, + BindUtils.CreateTokenBinding(_exceptionCompletedIcon!, HeightProperty, ProgressBarResourceKey.LineInfoIconSize, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_successCompletedIcon!, WidthProperty, + BindUtils.CreateTokenBinding(_successCompletedIcon!, WidthProperty, ProgressBarResourceKey.LineInfoIconSize, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_successCompletedIcon!, HeightProperty, + BindUtils.CreateTokenBinding(_successCompletedIcon!, HeightProperty, ProgressBarResourceKey.LineInfoIconSize, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSize); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSize); } else { - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon!, WidthProperty, + BindUtils.CreateTokenBinding( _exceptionCompletedIcon!, WidthProperty, ProgressBarResourceKey.LineInfoIconSizeSM, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_exceptionCompletedIcon!, HeightProperty, + BindUtils.CreateTokenBinding(_exceptionCompletedIcon!, HeightProperty, ProgressBarResourceKey.LineInfoIconSizeSM, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_successCompletedIcon!, WidthProperty, + BindUtils.CreateTokenBinding(_successCompletedIcon!, WidthProperty, ProgressBarResourceKey.LineInfoIconSizeSM, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(_successCompletedIcon!, HeightProperty, + BindUtils.CreateTokenBinding(_successCompletedIcon!, HeightProperty, ProgressBarResourceKey.LineInfoIconSizeSM, BindingPriority.LocalValue); - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSizeSM); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSizeSM); } } } diff --git a/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs b/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs index c807eb915..1607895a0 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs @@ -200,7 +200,6 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, protected bool _initialized = false; protected ControlStyleState _styleState; - protected ControlTokenBinder _controlTokenBinder; internal IControlCustomStyle _customStyle; protected Label? _percentageLabel; protected PathIcon? _successCompletedIcon; @@ -222,7 +221,6 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, public AbstractProgressBar() { - _controlTokenBinder = new ControlTokenBinder(this, ProgressBarToken.ID); _customStyle = this; _effectiveSizeType = SizeType; } @@ -352,7 +350,7 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); } void IControlCustomStyle.ApplyFixedStyleConfig() @@ -400,7 +398,7 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, protected virtual void NotifyApplyFixedStyleConfig() { - _controlTokenBinder.AddControlBinding(SuccessThresholdBrushProperty, GlobalResourceKey.ColorSuccess); + BindUtils.CreateTokenBinding(this, SuccessThresholdBrushProperty, GlobalResourceKey.ColorSuccess); } protected virtual void NotifyPropertyChanged(AvaloniaPropertyChangedEventArgs e) @@ -409,7 +407,6 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, void IControlCustomStyle.ApplyVariableStyleConfig() { - _controlTokenBinder.ReleaseTriggerBindings(this); NotifyApplyVariableStyleConfig(); } @@ -419,26 +416,26 @@ public abstract partial class AbstractProgressBar : RangeBaseControl, if (TrailColor.HasValue) { GrooveBrush = new SolidColorBrush(TrailColor.Value); } else { - _controlTokenBinder.AddControlBinding(GrooveBrushProperty, ProgressBarResourceKey.RemainingColor); + BindUtils.CreateTokenBinding(this, GrooveBrushProperty, ProgressBarResourceKey.RemainingColor); } if (Status == ProgressStatus.Success || MathUtils.AreClose(Value, Maximum)) { - _controlTokenBinder.AddControlBinding(IndicatorBarBrushProperty, GlobalResourceKey.ColorSuccess); + BindUtils.CreateTokenBinding(this, IndicatorBarBrushProperty, GlobalResourceKey.ColorSuccess); } else if (Status == ProgressStatus.Exception) { - _controlTokenBinder.AddControlBinding(IndicatorBarBrushProperty, GlobalResourceKey.ColorError); + BindUtils.CreateTokenBinding(this, IndicatorBarBrushProperty, GlobalResourceKey.ColorError); } else { - _controlTokenBinder.AddControlBinding(IndicatorBarBrushProperty, ProgressBarResourceKey.DefaultColor); + BindUtils.CreateTokenBinding(this, IndicatorBarBrushProperty, ProgressBarResourceKey.DefaultColor); } - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorTextLabel); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextLabel); if (_initialized) { _exceptionCompletedIcon!.IconMode = IconMode.Normal; _successCompletedIcon!.IconMode = IconMode.Normal; } } else { - _controlTokenBinder.AddControlBinding(GrooveBrushProperty, GlobalResourceKey.ColorBgContainerDisabled); - _controlTokenBinder.AddControlBinding(IndicatorBarBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorTextDisabled); + BindUtils.CreateTokenBinding(this, GrooveBrushProperty, GlobalResourceKey.ColorBgContainerDisabled); + BindUtils.CreateTokenBinding(this, IndicatorBarBrushProperty, GlobalResourceKey.ControlItemBgActiveDisabled); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextDisabled); if (_initialized) { _exceptionCompletedIcon!.IconMode = IconMode.Disabled; _successCompletedIcon!.IconMode = IconMode.Disabled; diff --git a/src/AtomUI.Controls/ProgressBar/ProgressBar.cs b/src/AtomUI.Controls/ProgressBar/ProgressBar.cs index 25d51d3a8..efeba739f 100644 --- a/src/AtomUI.Controls/ProgressBar/ProgressBar.cs +++ b/src/AtomUI.Controls/ProgressBar/ProgressBar.cs @@ -182,8 +182,8 @@ public partial class ProgressBar : AbstractLineProgress protected override void NotifyApplyFixedStyleConfig() { base.NotifyApplyFixedStyleConfig(); - _controlTokenBinder.AddControlBinding(ColorTextLabelTokenProperty, GlobalResourceKey.ColorTextLabel); - _controlTokenBinder.AddControlBinding(ColorTextLightSolidTokenProperty, GlobalResourceKey.ColorTextLightSolid); + BindUtils.CreateTokenBinding(this, ColorTextLabelTokenProperty, GlobalResourceKey.ColorTextLabel); + BindUtils.CreateTokenBinding(this, ColorTextLightSolidTokenProperty, GlobalResourceKey.ColorTextLightSolid); } protected override SizeType CalculateEffectiveSizeType(double size) diff --git a/src/AtomUI.Controls/RadioButton/RadioButton.cs b/src/AtomUI.Controls/RadioButton/RadioButton.cs index 3cd45d8a2..07ddf7c64 100644 --- a/src/AtomUI.Controls/RadioButton/RadioButton.cs +++ b/src/AtomUI.Controls/RadioButton/RadioButton.cs @@ -130,7 +130,7 @@ public partial class RadioButton : AvaloniaRadioButton, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { diff --git a/src/AtomUI.Controls/RadioButton/RadioButtonTheme.cs b/src/AtomUI.Controls/RadioButton/RadioButtonTheme.cs index c06c886c7..34039cc01 100644 --- a/src/AtomUI.Controls/RadioButton/RadioButtonTheme.cs +++ b/src/AtomUI.Controls/RadioButton/RadioButtonTheme.cs @@ -40,16 +40,16 @@ internal class RadioButtonTheme : ControlTheme // 选中 var checkedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Checked)); - checkedStyle.Setters.Add(new Setter(RadioButton.RadioBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); - checkedStyle.Setters.Add(new Setter(RadioButton.RadioBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + checkedStyle.Add(new Setter(RadioButton.RadioBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + checkedStyle.Add(new Setter(RadioButton.RadioBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); enabledStyle.Add(checkedStyle); // 没选中 var unCheckedStyle = new Style(selector => selector.Nesting().Not(x=> x.Nesting().Class(StdPseudoClass.Checked))); - unCheckedStyle.Setters.Add(new Setter(RadioButton.RadioBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainer))); + unCheckedStyle.Add(new Setter(RadioButton.RadioBackgroundProperty, new DynamicResourceExtension(GlobalResourceKey.ColorBgContainer))); var unCheckedHoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - unCheckedHoverStyle.Setters.Add(new Setter(RadioButton.RadioBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); + unCheckedHoverStyle.Add(new Setter(RadioButton.RadioBorderBrushProperty, new DynamicResourceExtension(GlobalResourceKey.ColorPrimary))); unCheckedStyle.Add(unCheckedHoverStyle); enabledStyle.Add(unCheckedStyle); diff --git a/src/AtomUI.Controls/Segmented/SegmentedItem.cs b/src/AtomUI.Controls/Segmented/SegmentedItem.cs index 25b450d7a..9fb26098e 100644 --- a/src/AtomUI.Controls/Segmented/SegmentedItem.cs +++ b/src/AtomUI.Controls/Segmented/SegmentedItem.cs @@ -161,7 +161,7 @@ public class SegmentedItem : TemplatedControl, IControlCustomStyle void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { diff --git a/src/AtomUI.Controls/Segmented/SegmentedItemBox.cs b/src/AtomUI.Controls/Segmented/SegmentedItemBox.cs index 76aa67fa9..b17245417 100644 --- a/src/AtomUI.Controls/Segmented/SegmentedItemBox.cs +++ b/src/AtomUI.Controls/Segmented/SegmentedItemBox.cs @@ -53,7 +53,6 @@ internal partial class SegmentedItemBox : BorderedStyleControl, internal bool IsCurrentItem { get => _isCurrentItem; set => SetCurrentItem(value); } private bool _initialized = false; private IControlCustomStyle _customStyle; - private ControlTokenBinder _controlTokenBinder; private bool _isPressed = false; private ControlStyleState _styleState; @@ -68,7 +67,6 @@ internal partial class SegmentedItemBox : BorderedStyleControl, public SegmentedItemBox(Control item) { - _controlTokenBinder = new ControlTokenBinder(this, SegmentedToken.ID); _customStyle = this; Item = item; Child = Item; @@ -191,7 +189,7 @@ internal partial class SegmentedItemBox : BorderedStyleControl, void IControlCustomStyle.CollectStyleState() { - StyleUtils.InitCommonState(this, ref _styleState); + ControlStateUtils.InitCommonState(this, ref _styleState); if (IsPressed) { _styleState |= ControlStyleState.Sunken; } else { @@ -206,46 +204,45 @@ internal partial class SegmentedItemBox : BorderedStyleControl, void IControlCustomStyle.ApplySizeTypeStyleConfig() { if (SizeType == SizeType.Large) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadius); - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSizeLG); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadius); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSizeLG); } else if (SizeType == SizeType.Middle) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSize); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusSM); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSize); } else if (SizeType == SizeType.Small) { - _controlTokenBinder.AddControlBinding(CornerRadiusProperty, GlobalResourceKey.BorderRadiusXS); - _controlTokenBinder.AddControlBinding(FontSizeProperty, GlobalResourceKey.FontSize); + BindUtils.CreateTokenBinding(this, CornerRadiusProperty, GlobalResourceKey.BorderRadiusXS); + BindUtils.CreateTokenBinding(this, FontSizeProperty, GlobalResourceKey.FontSize); } } void IControlCustomStyle.ApplyVariableStyleConfig() { - _controlTokenBinder.ReleaseTriggerBindings(this); if (_styleState.HasFlag(ControlStyleState.Enabled)) { if (!_styleState.HasFlag(ControlStyleState.Selected)) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, GlobalResourceKey.ColorTransparent); - _controlTokenBinder.AddControlBinding(ForegroundProperty, SegmentedResourceKey.ItemColor); + BindUtils.CreateTokenBinding(this, BackgroundProperty, GlobalResourceKey.ColorTransparent); + BindUtils.CreateTokenBinding(this, ForegroundProperty, SegmentedResourceKey.ItemColor); if (_styleState.HasFlag(ControlStyleState.Sunken)) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, SegmentedResourceKey.ItemActiveBg, BindingPriority.StyleTrigger); + BindUtils.CreateTokenBinding(this, BackgroundProperty, SegmentedResourceKey.ItemActiveBg, BindingPriority.StyleTrigger); } else if (_styleState.HasFlag(ControlStyleState.MouseOver)) { - _controlTokenBinder.AddControlBinding(BackgroundProperty, SegmentedResourceKey.ItemHoverBg, BindingPriority.StyleTrigger); - _controlTokenBinder.AddControlBinding(ForegroundProperty, SegmentedResourceKey.ItemHoverColor, BindingPriority.StyleTrigger); + BindUtils.CreateTokenBinding(this, BackgroundProperty, SegmentedResourceKey.ItemHoverBg, BindingPriority.StyleTrigger); + BindUtils.CreateTokenBinding(this, ForegroundProperty, SegmentedResourceKey.ItemHoverColor, BindingPriority.StyleTrigger); } } else { - _controlTokenBinder.AddControlBinding(ForegroundProperty, SegmentedResourceKey.ItemSelectedColor); + BindUtils.CreateTokenBinding(this, ForegroundProperty, SegmentedResourceKey.ItemSelectedColor); } } else { - _controlTokenBinder.AddControlBinding(ForegroundProperty, GlobalResourceKey.ColorTextDisabled); + BindUtils.CreateTokenBinding(this, ForegroundProperty, GlobalResourceKey.ColorTextDisabled); } } void IControlCustomStyle.ApplyFixedStyleConfig() { - _controlTokenBinder.AddControlBinding(ControlHeightSMTokenProperty, GlobalResourceKey.ControlHeightSM); - _controlTokenBinder.AddControlBinding(ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); - _controlTokenBinder.AddControlBinding(ControlHeightLGTokenProperty, GlobalResourceKey.ControlHeightLG); - _controlTokenBinder.AddControlBinding(TrackPaddingTokenProperty, SegmentedResourceKey.TrackPadding); - _controlTokenBinder.AddControlBinding(SegmentedItemPaddingSMTokenProperty, SegmentedResourceKey.SegmentedItemPaddingSM); - _controlTokenBinder.AddControlBinding(SegmentedItemPaddingTokenProperty, SegmentedResourceKey.SegmentedItemPadding); + BindUtils.CreateTokenBinding(this, ControlHeightSMTokenProperty, GlobalResourceKey.ControlHeightSM); + BindUtils.CreateTokenBinding(this, ControlHeightTokenProperty, GlobalResourceKey.ControlHeight); + BindUtils.CreateTokenBinding(this, ControlHeightLGTokenProperty, GlobalResourceKey.ControlHeightLG); + BindUtils.CreateTokenBinding(this, TrackPaddingTokenProperty, SegmentedResourceKey.TrackPadding); + BindUtils.CreateTokenBinding(this, SegmentedItemPaddingSMTokenProperty, SegmentedResourceKey.SegmentedItemPaddingSM); + BindUtils.CreateTokenBinding(this, SegmentedItemPaddingTokenProperty, SegmentedResourceKey.SegmentedItemPadding); } void IControlCustomStyle.HandlePropertyChangedForStyle(AvaloniaPropertyChangedEventArgs e) diff --git a/src/AtomUI.Controls/Segmented/SegmentedItemTheme.cs b/src/AtomUI.Controls/Segmented/SegmentedItemTheme.cs index c518fec98..b23275b18 100644 --- a/src/AtomUI.Controls/Segmented/SegmentedItemTheme.cs +++ b/src/AtomUI.Controls/Segmented/SegmentedItemTheme.cs @@ -3,7 +3,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Templates; using Avalonia.Layout; -using Avalonia.Markup.Xaml.MarkupExtensions; using Avalonia.Styling; namespace AtomUI.Controls; @@ -48,7 +47,7 @@ internal class SegmentedItemTheme : ControlTheme var hasIconStyle = new Style(selector => selector.Nesting().Not(x => x.Nesting().PropertyEquals(SegmentedItem.IconProperty, null))); { var labelStyle = new Style(selector => selector.Nesting().Template().OfType