mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-22 00:46:48 +08:00
Refactor Pagination
Use axaml
This commit is contained in:
@@ -29,4 +29,20 @@
|
||||
PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Avalonia.Base">
|
||||
<HintPath>C:\Users\CHINBOY\.nuget\packages\avalonia\11.3.1\lib\net6.0\Avalonia.Base.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="Pagination\Themes\Pagination.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\PaginationNavItemTheme.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\PaginationNavTheme.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\Paginations.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\PaginationTheme.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\QuickJumperBarTheme.axaml" />
|
||||
<AdditionalFiles Include="Pagination\Themes\SimplePaginationTheme.axaml" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
<atom:ControlThemesProvider.ControlThemes>
|
||||
<ResourceInclude Source="Alert/AlertTheme.axaml" />
|
||||
<ResourceInclude Source="Tag/TagTheme.axaml" />
|
||||
<ResourceInclude Source="Pagination/Themes/Paginations.axaml" />
|
||||
</atom:ControlThemesProvider.ControlThemes>
|
||||
</atom:ControlThemesProvider>
|
||||
-5
@@ -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());
|
||||
|
||||
@@ -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<PaginationNav>(PaginationTheme.NavPart);
|
||||
_paginationNav = e.NameScope.Find<PaginationNav>(PaginationThemeConstants.NavPart);
|
||||
Debug.Assert(_paginationNav is not null);
|
||||
this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, PageTextProperty, PaginationLangResourceKey.PageText));
|
||||
this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, TotalInfoTemplateProperty, PaginationLangResourceKey.TotalInfoFormat));
|
||||
|
||||
@@ -107,7 +107,7 @@ internal class PaginationNav : SelectingItemsControl,
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
_itemsPresenter = e.NameScope.Find<NavItemsPresenter>(PaginationNavTheme.ItemsPresenterPart);
|
||||
_itemsPresenter = e.NameScope.Find<NavItemsPresenter>(PaginationNavThemeConstants.ItemsPresenterPart);
|
||||
SetupItemPresenterSpacing();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>((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<object?, object?>(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<Cursor>(() => 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);
|
||||
}
|
||||
}
|
||||
@@ -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>((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;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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>((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<object?, object?>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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<LineEdit>(QuickJumperBarTheme.PageLineEditPart);
|
||||
_lineEdit = e.NameScope.Find<LineEdit>(PaginationQuickJumperBarThemeConstants.PageLineEditPart);
|
||||
this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, JumpToTextProperty, PaginationLangResourceKey.JumpToText));
|
||||
this.AddResourceBindingDisposable(LanguageResourceBinder.CreateBinding(this, PageTextProperty, PaginationLangResourceKey.PageText));
|
||||
|
||||
|
||||
@@ -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>((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<object?, object?>(
|
||||
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<object?, object?>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -50,10 +50,10 @@ public class SimplePagination : AbstractPagination,
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
_previousPageItem = e.NameScope.Find<PaginationNavItem>(SimplePaginationTheme.PreviousNavItemPart);
|
||||
_nextPageItem = e.NameScope.Find<PaginationNavItem>(SimplePaginationTheme.NextNavItemPart);
|
||||
_infoIndicator = e.NameScope.Find<TextBlock>(SimplePaginationTheme.InfoIndicatorPart);
|
||||
_quickJumper = e.NameScope.Find<LineEdit>(SimplePaginationTheme.QuickJumperPart);
|
||||
_previousPageItem = e.NameScope.Find<PaginationNavItem>(SimplePaginationThemeConstants.PreviousNavItemPart);
|
||||
_nextPageItem = e.NameScope.Find<PaginationNavItem>(SimplePaginationThemeConstants.NextNavItemPart);
|
||||
_infoIndicator = e.NameScope.Find<TextBlock>(SimplePaginationThemeConstants.InfoIndicatorPart);
|
||||
_quickJumper = e.NameScope.Find<LineEdit>(SimplePaginationThemeConstants.QuickJumperPart);
|
||||
|
||||
Debug.Assert(_nextPageItem != null);
|
||||
Debug.Assert(_previousPageItem != 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>((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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<atom:StringToTextBlockConverter x:Key="StringToTextBlockConverter" />
|
||||
<ControlTheme x:Key="{x:Type atom:PaginationNavItem}" TargetType="atom:PaginationNavItem">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Panel Name="{x:Static atom:PaginationNavItemThemeConstants.RootLayoutPart}">
|
||||
<Border Name="{x:Static atom:PaginationNavItemThemeConstants.MainFramePart}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" />
|
||||
<ContentPresenter Name="{x:Static atom:PaginationNavItemThemeConstants.ContentPart}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="{TemplateBinding Content, Mode=Default, Converter={StaticResource StringToTextBlockConverter}}" />
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource {x:Static atom:SharedTokenKey.BorderRadius}}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource {x:Static atom:SharedTokenKey.FontSize}}" />
|
||||
<Setter Property="Padding"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationItemPaddingInline}}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTransparent}}" />
|
||||
<Style Selector="^[IsEnabled=True]">
|
||||
<Style Selector="^:not(^[PaginationItemType=Ellipses])">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Style>
|
||||
|
||||
<!-- BuildPageIndicatorEnabledStyle 开始 -->
|
||||
<Style Selector="^[PaginationItemType=PageIndicator]">
|
||||
<Style Selector="^:selected">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemActiveBg}}" />
|
||||
<Setter Property="FontWeight" Value="SemiBold" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimaryHover}}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimaryHover}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^:not(:selected)">
|
||||
<Setter Property="Background" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemBg}}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorText}}" />
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBgTextHover}}" />
|
||||
</Style>
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBgTextActive}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- BuildPageIndicatorEnabledStyle 结束 -->
|
||||
|
||||
<!-- BuildPreviousAndNextItemEnabledStyle 开始 -->
|
||||
<Style Selector="^[PaginationItemType=Previous], ^[PaginationItemType=Next]">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTransparent}}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorText}}" />
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBgTextHover}}" />
|
||||
</Style>
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBgTextActive}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- BuildPreviousAndNextItemEnabledStyle 结束 -->
|
||||
</Style>
|
||||
|
||||
<!-- BuildSizeTypeStyle 开始 -->
|
||||
<Style Selector="^[SizeType=Large]">
|
||||
<Setter Property="Height" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSize}}" />
|
||||
<Setter Property="MinWidth" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSize}}" />
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Middle]">
|
||||
<Setter Property="Height" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSize}}" />
|
||||
<Setter Property="MinWidth" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSize}}" />
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Small]">
|
||||
<Setter Property="Height" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSizeSM}}" />
|
||||
<Setter Property="MinWidth" Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemSizeSM}}" />
|
||||
</Style>
|
||||
<!-- BuildSizeTypeStyle 结束 -->
|
||||
|
||||
<!-- BuildDisabledStyle 开始 -->
|
||||
<Style Selector="^:disabled">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemActiveColorDisabled}}" />
|
||||
<Style Selector="^:selected">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.ItemActiveBgDisabled}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- BuildDisabledStyle 结束 -->
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,17 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<ControlTheme x:Key="{x:Type atom:PaginationNav}" TargetType="atom:PaginationNav">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Name="{x:Static atom:PaginationNavThemeConstants.FramePart}"
|
||||
ClipToBounds="True"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<atom:NavItemsPresenter Name="{x:Static atom:PaginationNavThemeConstants.ItemsPresenterPart}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,53 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<atom:StringToTextBlockConverter x:Key="StringToTextBlockConverter" />
|
||||
<ControlTheme x:Key="{x:Type atom:Pagination}" TargetType="atom:Pagination">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<StackPanel Name="{x:Static atom:PaginationThemeConstants.RootLayoutPart}"
|
||||
Orientation="Horizontal">
|
||||
<ContentPresenter Name="{x:Static atom:PaginationThemeConstants.TotalInfoPresenterPart}"
|
||||
IsVisible="{TemplateBinding ShowTotalInfo}"
|
||||
Content="{TemplateBinding TotalInfoText, Mode=Default, Converter={StaticResource StringToTextBlockConverter}}" />
|
||||
<atom:PaginationNav
|
||||
Name="{x:Static atom:PaginationThemeConstants.NavPart}"
|
||||
IsMotionEnabled="{TemplateBinding IsMotionEnabled}"
|
||||
SizeType="{TemplateBinding SizeType}" />
|
||||
<ContentPresenter Name="{x:Static atom:PaginationThemeConstants.SizeChangerPresenterPart}"
|
||||
IsVisible="{TemplateBinding ShowSizeChanger}"
|
||||
Content="{TemplateBinding SizeChanger}" />
|
||||
<ContentPresenter Name="{x:Static atom:PaginationThemeConstants.QuickJumperBarPresenterPart}"
|
||||
IsVisible="{TemplateBinding ShowQuickJumper}"
|
||||
Content="{TemplateBinding QuickJumperBar}" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[Align=Start]">
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
</Style>
|
||||
<Style Selector="^[Align=Center]">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style Selector="^[Align=End]">
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^[SizeType=Large]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayout">
|
||||
<Setter Property="Spacing" Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutSpacing}}"/>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Middle]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayout">
|
||||
<Setter Property="Spacing" Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutSpacing}}"/>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Small]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayout">
|
||||
<Setter Property="Spacing" Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutMiniSpacing}}"/>
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="PaginationNavItemTheme.axaml"/>
|
||||
<ResourceInclude Source="PaginationNavTheme.axaml"/>
|
||||
<ResourceInclude Source="PaginationTheme.axaml"/>
|
||||
<ResourceInclude Source="QuickJumperBarTheme.axaml"/>
|
||||
<ResourceInclude Source="SimplePaginationTheme.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,29 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<atom:StringToTextBlockConverter x:Key="StringToTextBlockConverter"/>
|
||||
<ControlTheme x:Key="{x:Type atom:QuickJumperBar}" TargetType="atom:QuickJumperBar">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<StackPanel Name="{x:Static atom:PaginationQuickJumperBarThemeConstants.RootLayoutPart}"
|
||||
Orientation="Horizontal">
|
||||
<ContentPresenter Name="{x:Static atom:PaginationQuickJumperBarThemeConstants.JumpToContentPresenterPart}"
|
||||
Content="{TemplateBinding JumpToText, Mode=Default, Converter={StaticResource StringToTextBlockConverter}}"/>
|
||||
<atom:LineEdit Name="{x:Static atom:PaginationQuickJumperBarThemeConstants.PageLineEditPart}"
|
||||
SizeType="{TemplateBinding SizeType}"/>
|
||||
<ContentPresenter Name="{x:Static atom:PaginationQuickJumperBarThemeConstants.PageContentPresenterPart}"
|
||||
Content="{TemplateBinding PageText, Mode=Default, Converter={StaticResource StringToTextBlockConverter}}"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayout">
|
||||
<Setter Property="Spacing" Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutSpacing}}"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ atom|LineEdit#PART_PageLineEdit">
|
||||
<Setter Property="Width" Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationQuickJumperInputWidth}}"/>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,67 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<ControlTheme x:Key="{x:Type atom:SimplePagination}" TargetType="atom:SimplePagination">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<StackPanel Name="{x:Static atom:SimplePaginationThemeConstants.RootLayoutPart}"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<atom:PaginationNavItem Name="{x:Static atom:SimplePaginationThemeConstants.PreviousNavItemPart}"
|
||||
PaginationItemType="Previous"
|
||||
Content="{atom:IconProvider LeftOutlined}"
|
||||
SizeType="{TemplateBinding SizeType}"
|
||||
IsEnabled="{TemplateBinding IsEnabled}" />
|
||||
<atom:LineEdit Name="{x:Static atom:SimplePaginationThemeConstants.QuickJumperPart}"
|
||||
IsVisible="{TemplateBinding IsReadOnly, Mode=Default, Converter={x:Static BoolConverters.Not}}"
|
||||
SizeType="{TemplateBinding SizeType}"
|
||||
IsEnabled="{TemplateBinding IsEnabled}" />
|
||||
<atom:TextBlock Name="{x:Static atom:SimplePaginationThemeConstants.InfoIndicatorPart}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
IsEnabled="{TemplateBinding IsEnabled}" />
|
||||
<atom:PaginationNavItem Name="{x:Static atom:SimplePaginationThemeConstants.NextNavItemPart}"
|
||||
PaginationItemType="Previous"
|
||||
Content="{atom:IconProvider RightOutlined}"
|
||||
SizeType="{TemplateBinding SizeType}"
|
||||
IsEnabled="{TemplateBinding IsEnabled}" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[Align=Start]">
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
<Style Selector="^[Align=Center]">
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style Selector="^[Align=End]">
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^[SizeType=Large]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayoutPart">
|
||||
<Setter Property="Spacing"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutSpacing}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Middle]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayoutPart">
|
||||
<Setter Property="Spacing"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutSpacing}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^[SizeType=Small]">
|
||||
<Style Selector="^ /template/ StackPanel#PART_RootLayoutPart">
|
||||
<Setter Property="Spacing"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationLayoutMiniSpacing}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ atom|LineEdit#PART_QuickJumper">
|
||||
<Setter Property="MinWidth"
|
||||
Value="{DynamicResource {x:Static atom:PaginationTokenKey.PaginationQuickJumperInputWidth}}" />
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@
|
||||
<Setter Property="SelectedIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTextLightSolid}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- BuildCloseButtonStyle 结束 -->
|
||||
|
||||
</ControlTheme>
|
||||
|
||||
Reference in New Issue
Block a user