diff --git a/src/AtomUI.Controls/AtomUI.Controls.csproj b/src/AtomUI.Controls/AtomUI.Controls.csproj index 46e649615..673ff1fbb 100644 --- a/src/AtomUI.Controls/AtomUI.Controls.csproj +++ b/src/AtomUI.Controls/AtomUI.Controls.csproj @@ -29,4 +29,20 @@ PrivateAssets="all"/> + + + C:\Users\CHINBOY\.nuget\packages\avalonia\11.3.1\lib\net6.0\Avalonia.Base.dll + + + + + + + + + + + + + diff --git a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml index a7a52e17a..582eb3cea 100644 --- a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml +++ b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml @@ -6,5 +6,6 @@ + \ No newline at end of file diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs index d40f6f0cf..71854f3c3 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs @@ -78,15 +78,11 @@ namespace AtomUI.Theme themes.Add(new AtomUI.Controls.NumericUpDownTheme()); themes.Add(new AtomUI.Controls.OptionButtonGroupTheme()); themes.Add(new AtomUI.Controls.OptionButtonTheme()); - themes.Add(new AtomUI.Controls.PaginationNavItemTheme()); - themes.Add(new AtomUI.Controls.PaginationNavTheme()); - themes.Add(new AtomUI.Controls.PaginationTheme()); themes.Add(new AtomUI.Controls.PickerClearUpButtonTheme()); themes.Add(new AtomUI.Controls.PopupConfirmContainerTheme()); themes.Add(new AtomUI.Controls.PrimaryButtonTheme()); themes.Add(new AtomUI.Controls.PrimaryDropdownButtonTheme()); themes.Add(new AtomUI.Controls.ProgressBarTheme()); - themes.Add(new AtomUI.Controls.QuickJumperBarTheme()); themes.Add(new AtomUI.Controls.RadioButtonTheme()); themes.Add(new AtomUI.Controls.RangeDatePickerFlyoutPresenterTheme()); themes.Add(new AtomUI.Controls.RangeDatePickerTheme()); @@ -99,7 +95,6 @@ namespace AtomUI.Theme themes.Add(new AtomUI.Controls.SegmentedItemTheme()); themes.Add(new AtomUI.Controls.SegmentedTheme()); themes.Add(new AtomUI.Controls.SeparatorTheme()); - themes.Add(new AtomUI.Controls.SimplePaginationTheme()); themes.Add(new AtomUI.Controls.SliderTheme()); themes.Add(new AtomUI.Controls.SliderThumbTheme()); themes.Add(new AtomUI.Controls.SplitButtonTheme()); diff --git a/src/AtomUI.Controls/Pagination/Pagination.cs b/src/AtomUI.Controls/Pagination/Pagination.cs index d3c560655..9d11a0737 100644 --- a/src/AtomUI.Controls/Pagination/Pagination.cs +++ b/src/AtomUI.Controls/Pagination/Pagination.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Reactive.Disposables; using AtomUI.Controls.PaginationLang; using AtomUI.Data; using AtomUI.IconPkg.AntDesign; @@ -9,9 +8,7 @@ using AtomUI.Theme.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; -using Avalonia.Data; using Avalonia.Layout; -using Avalonia.LogicalTree; using Avalonia.VisualTree; namespace AtomUI.Controls; @@ -157,7 +154,7 @@ public class Pagination : AbstractPagination, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _paginationNav = e.NameScope.Find(PaginationTheme.NavPart); + _paginationNav = e.NameScope.Find(PaginationThemeConstants.NavPart); Debug.Assert(_paginationNav is not null); this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, PageTextProperty, PaginationLangResourceKey.PageText)); this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, TotalInfoTemplateProperty, PaginationLangResourceKey.TotalInfoFormat)); diff --git a/src/AtomUI.Controls/Pagination/PaginationNav.cs b/src/AtomUI.Controls/Pagination/PaginationNav.cs index e8ba79ffc..f25e39dfb 100644 --- a/src/AtomUI.Controls/Pagination/PaginationNav.cs +++ b/src/AtomUI.Controls/Pagination/PaginationNav.cs @@ -107,7 +107,7 @@ internal class PaginationNav : SelectingItemsControl, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _itemsPresenter = e.NameScope.Find(PaginationNavTheme.ItemsPresenterPart); + _itemsPresenter = e.NameScope.Find(PaginationNavThemeConstants.ItemsPresenterPart); SetupItemPresenterSpacing(); } diff --git a/src/AtomUI.Controls/Pagination/PaginationNavItem.cs b/src/AtomUI.Controls/Pagination/PaginationNavItem.cs index 9ab9d3ec8..23f91614b 100644 --- a/src/AtomUI.Controls/Pagination/PaginationNavItem.cs +++ b/src/AtomUI.Controls/Pagination/PaginationNavItem.cs @@ -272,7 +272,10 @@ internal class PaginationNavItem : ContentControl, e.Handled = true; if (this.GetVisualsAt(e.GetPosition(this)).Any(c => this == c || this.IsVisualAncestorOf(c))) { - OnClick(); + if (PaginationItemType != PaginationItemType.Ellipses) + { + OnClick(); + } } } } diff --git a/src/AtomUI.Controls/Pagination/PaginationNavItemTheme.cs b/src/AtomUI.Controls/Pagination/PaginationNavItemTheme.cs deleted file mode 100644 index 60122f673..000000000 --- a/src/AtomUI.Controls/Pagination/PaginationNavItemTheme.cs +++ /dev/null @@ -1,188 +0,0 @@ -using AtomUI.Theme; -using AtomUI.Theme.Styling; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Presenters; -using Avalonia.Controls.Primitives; -using Avalonia.Controls.Templates; -using Avalonia.Data; -using Avalonia.Data.Converters; -using Avalonia.Input; -using Avalonia.Layout; -using Avalonia.Media; -using Avalonia.Styling; -using HorizontalAlignment = Avalonia.Layout.HorizontalAlignment; -using Selectors = Avalonia.Styling.Selectors; -using VerticalAlignment = Avalonia.Layout.VerticalAlignment; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class PaginationNavItemTheme : BaseControlTheme -{ - public const string RootLayoutPart = "PART_RootLayoutPart"; - public const string MainFramePart = "PART_MainFrame"; - public const string ContentPart = "PART_Content"; - - public PaginationNavItemTheme() - : base(typeof(PaginationNavItem)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - return new FuncControlTemplate((paginationNavItem, scope) => - { - var rootLayout = new Panel - { - Name = RootLayoutPart - }; - var mainFrame = new Border - { - Name = MainFramePart - }; - rootLayout.Children.Add(mainFrame); - CreateTemplateParentBinding(mainFrame, Border.BackgroundProperty, TemplatedControl.BackgroundProperty); - CreateTemplateParentBinding(mainFrame, Border.BorderBrushProperty, TemplatedControl.BorderBrushProperty); - CreateTemplateParentBinding(mainFrame, Border.CornerRadiusProperty, TemplatedControl.CornerRadiusProperty); - CreateTemplateParentBinding(mainFrame, Decorator.PaddingProperty, TemplatedControl.PaddingProperty); - CreateTemplateParentBinding(mainFrame, Border.BorderThicknessProperty, TemplatedControl.BorderThicknessProperty); - - var contentPresenter = new ContentPresenter - { - Name = ContentPart, - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - HorizontalContentAlignment = HorizontalAlignment.Center, - VerticalContentAlignment = VerticalAlignment.Center, - }; - contentPresenter.RegisterInNameScope(scope); - CreateTemplateParentBinding(contentPresenter, ContentPresenter.ContentProperty, - ContentControl.ContentProperty, - BindingMode.Default, - new FuncValueConverter(content => - { - if (content is string text) - { - return new TextBlock() - { - Text = text, - VerticalAlignment = VerticalAlignment.Center, - }; - } - return content; - })); - rootLayout.Children.Add(contentPresenter); - return rootLayout; - }); - } - - protected override void BuildStyles() - { - var commonStyle = new Style(selector => selector.Nesting()); - commonStyle.Add(TemplatedControl.CornerRadiusProperty, SharedTokenKey.BorderRadius); - commonStyle.Add(TemplatedControl.FontSizeProperty, SharedTokenKey.FontSize); - commonStyle.Add(TemplatedControl.PaddingProperty, PaginationTokenKey.PaginationItemPaddingInline); - commonStyle.Add(TemplatedControl.BorderBrushProperty, SharedTokenKey.ColorTransparent); - - var enabledStyle = - new Style(selector => selector.Nesting().PropertyEquals(InputElement.IsEnabledProperty, true)); - var handleStyle = new Style(selector => selector.Nesting().Not(selector.Nesting().PropertyEquals(PaginationNavItem.PaginationItemTypeProperty, PaginationItemType.Ellipses))); - handleStyle.Add(InputElement.CursorProperty, new SetterValueFactory(() => new Cursor(StandardCursorType.Hand))); - enabledStyle.Add(handleStyle); - BuildPageIndicatorEnabledStyle(enabledStyle); - BuildPreviousAndNextItemEnabledStyle(enabledStyle); - commonStyle.Add(enabledStyle); - Add(commonStyle); - BuildSizeTypeStyle(); - BuildDisabledStyle(); - } - - private void BuildPageIndicatorEnabledStyle(Style enabledStyle) - { - var indicatorStyle = new Style(selector => - selector.Nesting().PropertyEquals(PaginationNavItem.PaginationItemTypeProperty, - PaginationItemType.PageIndicator)); - var selectedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Selected)); - selectedStyle.Add(TemplatedControl.ForegroundProperty, SharedTokenKey.ColorPrimary); - selectedStyle.Add(TemplatedControl.BackgroundProperty, PaginationTokenKey.ItemActiveBg); - selectedStyle.Add(TemplatedControl.FontWeightProperty, FontWeight.Bold); - selectedStyle.Add(TemplatedControl.BorderBrushProperty, SharedTokenKey.ColorPrimary); - - { - var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Add(TemplatedControl.ForegroundProperty, SharedTokenKey.ColorPrimaryHover); - hoverStyle.Add(TemplatedControl.BorderBrushProperty, SharedTokenKey.ColorPrimaryHover); - selectedStyle.Add(hoverStyle); - } - - indicatorStyle.Add(selectedStyle); - var notSelectedStyle = - new Style(selector => selector.Nesting().Not(x => x.Nesting().Class(StdPseudoClass.Selected))); - notSelectedStyle.Add(TemplatedControl.BackgroundProperty, PaginationTokenKey.ItemBg); - notSelectedStyle.Add(TemplatedControl.ForegroundProperty, SharedTokenKey.ColorText); - { - var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Add(TemplatedControl.BackgroundProperty, SharedTokenKey.ColorBgTextHover); - notSelectedStyle.Add(hoverStyle); - } - { - var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Pressed)); - pressedStyle.Add(TemplatedControl.BackgroundProperty, SharedTokenKey.ColorBgTextActive); - notSelectedStyle.Add(pressedStyle); - } - indicatorStyle.Add(notSelectedStyle); - enabledStyle.Add(indicatorStyle); - } - - private void BuildPreviousAndNextItemEnabledStyle(Style enabledStyle) - { - var previousAndNextStyle = new Style(selector => - Selectors.Or(selector.Nesting().PropertyEquals(PaginationNavItem.PaginationItemTypeProperty, - PaginationItemType.Previous), - selector.Nesting().PropertyEquals(PaginationNavItem.PaginationItemTypeProperty, - PaginationItemType.Next))); - previousAndNextStyle.Add(TemplatedControl.BackgroundProperty, SharedTokenKey.ColorTransparent); - previousAndNextStyle.Add(TemplatedControl.ForegroundProperty, SharedTokenKey.ColorText); - var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver)); - hoverStyle.Add(TemplatedControl.BackgroundProperty, SharedTokenKey.ColorBgTextHover); - previousAndNextStyle.Add(hoverStyle); - var pressedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Pressed)); - pressedStyle.Add(TemplatedControl.BackgroundProperty, SharedTokenKey.ColorBgTextActive); - previousAndNextStyle.Add(pressedStyle); - enabledStyle.Add(previousAndNextStyle); - } - - private void BuildSizeTypeStyle() - { - var largeSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Large)); - largeSizeStyle.Add(Layoutable.HeightProperty, PaginationTokenKey.ItemSize); - largeSizeStyle.Add(Layoutable.MinWidthProperty, PaginationTokenKey.ItemSize); - Add(largeSizeStyle); - - var middleSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Middle)); - middleSizeStyle.Add(Layoutable.HeightProperty, PaginationTokenKey.ItemSize); - middleSizeStyle.Add(Layoutable.MinWidthProperty, PaginationTokenKey.ItemSize); - Add(middleSizeStyle); - - var smallSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Small)); - smallSizeStyle.Add(Layoutable.HeightProperty, PaginationTokenKey.ItemSizeSM); - smallSizeStyle.Add(Layoutable.MinWidthProperty, PaginationTokenKey.ItemSizeSM); - Add(smallSizeStyle); - } - - private void BuildDisabledStyle() - { - var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled)); - disabledStyle.Add(TemplatedControl.ForegroundProperty, PaginationTokenKey.ItemActiveColorDisabled); - - var selectedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Selected)); - selectedStyle.Add(TemplatedControl.BorderThicknessProperty, new Thickness(0)); - selectedStyle.Add(TemplatedControl.BackgroundProperty, PaginationTokenKey.ItemActiveBgDisabled); - disabledStyle.Add(selectedStyle); - Add(disabledStyle); - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/PaginationNavTheme.cs b/src/AtomUI.Controls/Pagination/PaginationNavTheme.cs deleted file mode 100644 index 6c3b7d647..000000000 --- a/src/AtomUI.Controls/Pagination/PaginationNavTheme.cs +++ /dev/null @@ -1,45 +0,0 @@ -using AtomUI.Theme; -using AtomUI.Theme.Data; -using AtomUI.Theme.Styling; -using Avalonia.Controls; -using Avalonia.Controls.Presenters; -using Avalonia.Controls.Primitives; -using Avalonia.Controls.Templates; -using Avalonia.Layout; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class PaginationNavTheme : BaseControlTheme -{ - public const string FramePart = "PART_Frame"; - public const string ItemsPresenterPart = "PART_ItemsPresenter"; - - public PaginationNavTheme() - : base(typeof(PaginationNav)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - return new FuncControlTemplate((paginationNav, scope) => - { - var frame = new Border - { - Name = FramePart, - ClipToBounds = true - }; - var itemsPresenter = new NavItemsPresenter - { - Name = ItemsPresenterPart - }; - itemsPresenter.RegisterInNameScope(scope); - frame.Child = itemsPresenter; - - CreateTemplateParentBinding(frame, Border.CornerRadiusProperty, - TemplatedControl.CornerRadiusProperty); - CreateTemplateParentBinding(frame, Decorator.PaddingProperty, TemplatedControl.PaddingProperty); - return frame; - }); - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/PaginationTheme.cs b/src/AtomUI.Controls/Pagination/PaginationTheme.cs deleted file mode 100644 index df7e1c73b..000000000 --- a/src/AtomUI.Controls/Pagination/PaginationTheme.cs +++ /dev/null @@ -1,138 +0,0 @@ -using AtomUI.Theme; -using AtomUI.Theme.Styling; -using Avalonia.Controls; -using Avalonia.Controls.Presenters; -using Avalonia.Controls.Templates; -using Avalonia.Data; -using Avalonia.Data.Converters; -using Avalonia.Layout; -using Avalonia.Styling; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class PaginationTheme : BaseControlTheme -{ - public const string RootLayoutPart = "PART_RootLayout"; - public const string NavPart = "PART_Nav"; - public const string SizeChangerPresenterPart = "PART_SizeChangerPresenter"; - public const string QuickJumperBarPresenterPart = "PART_QuickJumperBarPresenter"; - public const string TotalInfoPresenterPart = "PART_TotalInfoPresenter"; - - public PaginationTheme() - : base(typeof(Pagination)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - var controlTemplate = new FuncControlTemplate((pagination, scope) => - { - var rootLayout = new StackPanel - { - Name = RootLayoutPart, - Orientation = Orientation.Horizontal - }; - var showTotalPresenter = new ContentPresenter() - { - Name = TotalInfoPresenterPart - }; - CreateTemplateParentBinding(showTotalPresenter, ContentPresenter.IsVisibleProperty, Pagination.ShowTotalInfoProperty); - CreateTemplateParentBinding(showTotalPresenter, ContentPresenter.ContentProperty, - Pagination.TotalInfoTextProperty, - BindingMode.Default, - new FuncValueConverter( - o => - { - if (o is string str) - { - return new TextBlock() - { - Text = str, - VerticalAlignment = VerticalAlignment.Center - }; - } - return o; - })); - rootLayout.Children.Add(showTotalPresenter); - - var nav = new PaginationNav - { - Name = NavPart - }; - nav.RegisterInNameScope(scope); - CreateTemplateParentBinding(nav, PaginationNav.IsMotionEnabledProperty, Pagination.IsMotionEnabledProperty); - CreateTemplateParentBinding(nav, PaginationNav.SizeTypeProperty, Pagination.SizeTypeProperty); - rootLayout.Children.Add(nav); - - var showSizeChangerPresenter = new ContentPresenter() - { - Name = SizeChangerPresenterPart - }; - CreateTemplateParentBinding(showSizeChangerPresenter, ContentPresenter.IsVisibleProperty, Pagination.ShowSizeChangerProperty); - CreateTemplateParentBinding(showSizeChangerPresenter, ContentPresenter.ContentProperty, Pagination.SizeChangerProperty); - rootLayout.Children.Add(showSizeChangerPresenter); - - var quickJumperBarPresenter = new ContentPresenter() - { - Name = QuickJumperBarPresenterPart - }; - CreateTemplateParentBinding(quickJumperBarPresenter, ContentPresenter.IsVisibleProperty, Pagination.ShowQuickJumperProperty); - CreateTemplateParentBinding(quickJumperBarPresenter, ContentPresenter.ContentProperty, Pagination.QuickJumperBarProperty); - rootLayout.Children.Add(quickJumperBarPresenter); - - return rootLayout; - }); - return controlTemplate; - } - - protected override void BuildStyles() - { - var commonStyle = new Style(selector => selector.Nesting()); - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(Pagination.AlignProperty, PaginationAlign.Start)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Left); - commonStyle.Add(alignStyle); - } - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(Pagination.AlignProperty, PaginationAlign.Center)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Center); - commonStyle.Add(alignStyle); - } - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(Pagination.AlignProperty, PaginationAlign.End)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Right); - commonStyle.Add(alignStyle); - } - - var largeSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Large)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutSpacing); - largeSizeStyle.Add(layoutStyle); - } - - commonStyle.Add(largeSizeStyle); - - var middleSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Middle)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutSpacing); - middleSizeStyle.Add(layoutStyle); - } - commonStyle.Add(middleSizeStyle); - - var smallSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Small)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutMiniSpacing); - smallSizeStyle.Add(layoutStyle); - } - commonStyle.Add(smallSizeStyle); - - Add(commonStyle); - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/PaginationThemeConstants.cs b/src/AtomUI.Controls/Pagination/PaginationThemeConstants.cs new file mode 100644 index 000000000..c72fc6545 --- /dev/null +++ b/src/AtomUI.Controls/Pagination/PaginationThemeConstants.cs @@ -0,0 +1,40 @@ +namespace AtomUI.Controls; + +public static class PaginationThemeConstants +{ + public const string RootLayoutPart = "PART_RootLayout"; + public const string NavPart = "PART_Nav"; + public const string SizeChangerPresenterPart = "PART_SizeChangerPresenter"; + public const string QuickJumperBarPresenterPart = "PART_QuickJumperBarPresenter"; + public const string TotalInfoPresenterPart = "PART_TotalInfoPresenter"; +} + +public static class PaginationNavItemThemeConstants +{ + public const string RootLayoutPart = "PART_RootLayoutPart"; + public const string MainFramePart = "PART_MainFrame"; + public const string ContentPart = "PART_Content"; +} + +public static class PaginationNavThemeConstants +{ + public const string FramePart = "PART_Frame"; + public const string ItemsPresenterPart = "PART_ItemsPresenter"; +} + +public static class PaginationQuickJumperBarThemeConstants +{ + public const string RootLayoutPart = "PART_RootLayout"; + public const string JumpToContentPresenterPart = "PART_JumpToContentPresenter"; + public const string PageContentPresenterPart = "PART_PageContentPresenter"; + public const string PageLineEditPart = "PART_PageLineEdit"; +} + +public static class SimplePaginationThemeConstants +{ + public const string RootLayoutPart = "PART_RootLayoutPart"; + public const string PreviousNavItemPart = "PART_PreviousNavItem"; + public const string NextNavItemPart = "PART_NextNavItem"; + public const string InfoIndicatorPart = "PART_InfoIndicator"; + public const string QuickJumperPart = "PART_QuickJumper"; +} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/QuickJumperBar.cs b/src/AtomUI.Controls/Pagination/QuickJumperBar.cs index f2350ec65..1583b87af 100644 --- a/src/AtomUI.Controls/Pagination/QuickJumperBar.cs +++ b/src/AtomUI.Controls/Pagination/QuickJumperBar.cs @@ -6,7 +6,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Input; -using Avalonia.LogicalTree; namespace AtomUI.Controls; @@ -65,7 +64,7 @@ internal class QuickJumperBar : TemplatedControl, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _lineEdit = e.NameScope.Find(QuickJumperBarTheme.PageLineEditPart); + _lineEdit = e.NameScope.Find(PaginationQuickJumperBarThemeConstants.PageLineEditPart); this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, JumpToTextProperty, PaginationLangResourceKey.JumpToText)); this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, PageTextProperty, PaginationLangResourceKey.PageText)); diff --git a/src/AtomUI.Controls/Pagination/QuickJumperBarTheme.cs b/src/AtomUI.Controls/Pagination/QuickJumperBarTheme.cs deleted file mode 100644 index e786a6c1c..000000000 --- a/src/AtomUI.Controls/Pagination/QuickJumperBarTheme.cs +++ /dev/null @@ -1,101 +0,0 @@ -using AtomUI.Theme; -using AtomUI.Theme.Styling; -using Avalonia.Controls; -using Avalonia.Controls.Presenters; -using Avalonia.Controls.Templates; -using Avalonia.Data; -using Avalonia.Data.Converters; -using Avalonia.Layout; -using Avalonia.Styling; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class QuickJumperBarTheme : BaseControlTheme -{ - public const string RootLayoutPart = "PART_RootLayout"; - public const string JumpToContentPresenterPart = "PART_JumpToContentPresenter"; - public const string PageContentPresenterPart = "PART_PageContentPresenter"; - public const string PageLineEditPart = "PART_PageLineEdit"; - - public QuickJumperBarTheme() - : base(typeof(QuickJumperBar)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - return new FuncControlTemplate((quickJumperBar, scope) => - { - var rootLayout = new StackPanel - { - Orientation = Orientation.Horizontal, - Name = RootLayoutPart - }; - var jumpToText = new ContentPresenter() - { - Name = JumpToContentPresenterPart - }; - CreateTemplateParentBinding(jumpToText, ContentPresenter.ContentProperty, - QuickJumperBar.JumpToTextProperty, - BindingMode.Default, - new FuncValueConverter( - o => - { - if (o is string str) - { - return new TextBlock() - { - Text = str, - VerticalAlignment = VerticalAlignment.Center - }; - } - return o; - })); - rootLayout.Children.Add(jumpToText); - var input = new LineEdit() - { - Name = PageLineEditPart - }; - - CreateTemplateParentBinding(input, LineEdit.SizeTypeProperty, QuickJumperBar.SizeTypeProperty); - input.RegisterInNameScope(scope); - rootLayout.Children.Add(input); - var pageTextContentPresenter = new ContentPresenter() - { - Name = PageContentPresenterPart - }; - CreateTemplateParentBinding(pageTextContentPresenter, ContentPresenter.ContentProperty, - QuickJumperBar.PageTextProperty, - BindingMode.Default, - new FuncValueConverter( - o => - { - if (o is string str) - { - return new TextBlock() - { - Text = str, - VerticalAlignment = VerticalAlignment.Center - }; - } - return o; - })); - rootLayout.Children.Add(pageTextContentPresenter); - return rootLayout; - }); - } - - protected override void BuildStyles() - { - var commonStyle = new Style(selector => selector.Nesting()); - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutSpacing); - commonStyle.Add(layoutStyle); - - var lineEditStyle = new Style(selector => selector.Nesting().Template().Name(PageLineEditPart)); - lineEditStyle.Add(LineEdit.WidthProperty, PaginationTokenKey.PaginationQuickJumperInputWidth); - commonStyle.Add(lineEditStyle); - Add(commonStyle); - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/SimplePagination.cs b/src/AtomUI.Controls/Pagination/SimplePagination.cs index 55c5539f4..347c48e8e 100644 --- a/src/AtomUI.Controls/Pagination/SimplePagination.cs +++ b/src/AtomUI.Controls/Pagination/SimplePagination.cs @@ -50,10 +50,10 @@ public class SimplePagination : AbstractPagination, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _previousPageItem = e.NameScope.Find(SimplePaginationTheme.PreviousNavItemPart); - _nextPageItem = e.NameScope.Find(SimplePaginationTheme.NextNavItemPart); - _infoIndicator = e.NameScope.Find(SimplePaginationTheme.InfoIndicatorPart); - _quickJumper = e.NameScope.Find(SimplePaginationTheme.QuickJumperPart); + _previousPageItem = e.NameScope.Find(SimplePaginationThemeConstants.PreviousNavItemPart); + _nextPageItem = e.NameScope.Find(SimplePaginationThemeConstants.NextNavItemPart); + _infoIndicator = e.NameScope.Find(SimplePaginationThemeConstants.InfoIndicatorPart); + _quickJumper = e.NameScope.Find(SimplePaginationThemeConstants.QuickJumperPart); Debug.Assert(_nextPageItem != null); Debug.Assert(_previousPageItem != null); diff --git a/src/AtomUI.Controls/Pagination/SimplePaginationTheme.cs b/src/AtomUI.Controls/Pagination/SimplePaginationTheme.cs deleted file mode 100644 index 681524529..000000000 --- a/src/AtomUI.Controls/Pagination/SimplePaginationTheme.cs +++ /dev/null @@ -1,141 +0,0 @@ -using AtomUI.IconPkg.AntDesign; -using AtomUI.Theme; -using AtomUI.Theme.Styling; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using Avalonia.Data; -using Avalonia.Data.Converters; -using Avalonia.Layout; -using Avalonia.Styling; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class SimplePaginationTheme : BaseControlTheme -{ - public const string RootLayoutPart = "PART_RootLayoutPart"; - public const string PreviousNavItemPart = "PART_PreviousNavItem"; - public const string NextNavItemPart = "PART_NextNavItem"; - public const string InfoIndicatorPart = "PART_InfoIndicator"; - public const string QuickJumperPart = "PART_QuickJumper"; - - public SimplePaginationTheme() - : base(typeof(SimplePagination)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - return new FuncControlTemplate((simplePagination, scope) => - { - var mainLayout = new StackPanel() - { - Name = RootLayoutPart, - VerticalAlignment = VerticalAlignment.Center, - Orientation = Orientation.Horizontal, - }; - - var previousNavItem = new PaginationNavItem() - { - Name = PreviousNavItemPart, - PaginationItemType = PaginationItemType.Previous, - Content = AntDesignIconPackage.LeftOutlined() - }; - CreateTemplateParentBinding(previousNavItem, PaginationNavItem.SizeTypeProperty, SimplePagination.SizeTypeProperty); - CreateTemplateParentBinding(previousNavItem, PaginationNavItem.IsEnabledProperty, SimplePagination.IsEnabledProperty); - previousNavItem.RegisterInNameScope(scope); - mainLayout.Children.Add(previousNavItem); - - var quickJumperPart = new LineEdit() - { - Name = QuickJumperPart - }; - CreateTemplateParentBinding(quickJumperPart, - LineEdit.IsVisibleProperty, - SimplePagination.IsReadOnlyProperty, - BindingMode.Default, - BoolConverters.Not); - CreateTemplateParentBinding(quickJumperPart, LineEdit.SizeTypeProperty, SimplePagination.SizeTypeProperty); - CreateTemplateParentBinding(quickJumperPart, LineEdit.IsEnabledProperty, SimplePagination.IsEnabledProperty); - quickJumperPart.RegisterInNameScope(scope); - mainLayout.Children.Add(quickJumperPart); - - var infoIndicator = new TextBlock() - { - Name = InfoIndicatorPart, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Center - }; - infoIndicator.RegisterInNameScope(scope); - CreateTemplateParentBinding(infoIndicator, TextBlock.IsEnabledProperty, SimplePagination.IsEnabledProperty); - mainLayout.Children.Add(infoIndicator); - - var nextNavItem = new PaginationNavItem() - { - Name = NextNavItemPart, - PaginationItemType = PaginationItemType.Next, - Content = AntDesignIconPackage.RightOutlined() - }; - CreateTemplateParentBinding(nextNavItem, PaginationNavItem.IsEnabledProperty, SimplePagination.IsEnabledProperty); - CreateTemplateParentBinding(nextNavItem, PaginationNavItem.SizeTypeProperty, SimplePagination.SizeTypeProperty); - nextNavItem.RegisterInNameScope(scope); - mainLayout.Children.Add(nextNavItem); - return mainLayout; - }); - } - - protected override void BuildStyles() - { - var commonStyle = new Style(selector => selector.Nesting()); - - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(SimplePagination.AlignProperty, PaginationAlign.Start)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Left); - commonStyle.Add(alignStyle); - } - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(SimplePagination.AlignProperty, PaginationAlign.Center)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Center); - commonStyle.Add(alignStyle); - } - { - var alignStyle = new Style(selector => selector.Nesting().PropertyEquals(SimplePagination.AlignProperty, PaginationAlign.End)); - alignStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Right); - commonStyle.Add(alignStyle); - } - - var largeSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Large)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutSpacing); - largeSizeStyle.Add(layoutStyle); - } - - commonStyle.Add(largeSizeStyle); - - var middleSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Middle)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutSpacing); - middleSizeStyle.Add(layoutStyle); - } - commonStyle.Add(middleSizeStyle); - - var smallSizeStyle = - new Style(selector => selector.Nesting().PropertyEquals(PaginationNavItem.SizeTypeProperty, SizeType.Small)); - { - var layoutStyle = new Style(selector => selector.Nesting().Template().Name(RootLayoutPart)); - layoutStyle.Add(StackPanel.SpacingProperty, PaginationTokenKey.PaginationLayoutMiniSpacing); - smallSizeStyle.Add(layoutStyle); - } - commonStyle.Add(smallSizeStyle); - - var quickJumperStyle = new Style(selector => selector.Nesting().Template().Name(QuickJumperPart)); - quickJumperStyle.Add(LineEdit.MinWidthProperty, PaginationTokenKey.PaginationQuickJumperInputWidth); - commonStyle.Add(quickJumperStyle); - - Add(commonStyle); - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/PaginationNavItemTheme.axaml b/src/AtomUI.Controls/Pagination/Themes/PaginationNavItemTheme.axaml new file mode 100644 index 000000000..10b318c38 --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/PaginationNavItemTheme.axaml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/PaginationNavTheme.axaml b/src/AtomUI.Controls/Pagination/Themes/PaginationNavTheme.axaml new file mode 100644 index 000000000..ff7319ad6 --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/PaginationNavTheme.axaml @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/PaginationTheme.axaml b/src/AtomUI.Controls/Pagination/Themes/PaginationTheme.axaml new file mode 100644 index 000000000..f725682fa --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/PaginationTheme.axaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/Paginations.axaml b/src/AtomUI.Controls/Pagination/Themes/Paginations.axaml new file mode 100644 index 000000000..5af3a486d --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/Paginations.axaml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/QuickJumperBarTheme.axaml b/src/AtomUI.Controls/Pagination/Themes/QuickJumperBarTheme.axaml new file mode 100644 index 000000000..0ee37c233 --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/QuickJumperBarTheme.axaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Themes/SimplePaginationTheme.axaml b/src/AtomUI.Controls/Pagination/Themes/SimplePaginationTheme.axaml new file mode 100644 index 000000000..5a41e107f --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Themes/SimplePaginationTheme.axaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Pagination/Utils/StringToTextBlockConverter.cs b/src/AtomUI.Controls/Pagination/Utils/StringToTextBlockConverter.cs new file mode 100644 index 000000000..e75f98c5e --- /dev/null +++ b/src/AtomUI.Controls/Pagination/Utils/StringToTextBlockConverter.cs @@ -0,0 +1,26 @@ +using System.Globalization; +using Avalonia.Data.Converters; +using Avalonia.Layout; + +namespace AtomUI.Controls; + +internal class StringToTextBlockConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is string str) + { + return new TextBlock() + { + Text = str, + VerticalAlignment = VerticalAlignment.Center + }; + } + return value; + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/AtomUI.Controls/Tag/TagTheme.axaml b/src/AtomUI.Controls/Tag/TagTheme.axaml index dfb58a406..6de2e6909 100644 --- a/src/AtomUI.Controls/Tag/TagTheme.axaml +++ b/src/AtomUI.Controls/Tag/TagTheme.axaml @@ -91,7 +91,7 @@ - +