using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Venus_Themes.CustomControls { public class Pagination : Control { private Venus_Themes.UserControls.PathButton _btnPrev = null; private Button _btnOne = null; private Button _btnDotPrev = null; private Button _btnCenterOne = null; private Button _btnCenterTwo = null; private Button _btnCenterThree = null; private Button _btnCenterFour = null; private Button _btnCenterFive = null; private Button _btnDotNext = null; private Button _btnLast = null; private Venus_Themes.UserControls.PathButton _btnNext = null; public Action CurrentPageChanged; public int PageCount { get { return (int)GetValue(PageCountProperty); } set { SetValue(PageCountProperty, value); } } public static readonly DependencyProperty PageCountProperty = DependencyProperty.Register("PageCount", typeof(int), typeof(Pagination), new PropertyMetadata(1, (d, e) => { if (!(d is Pagination pagination)) return; var page = (int)e.NewValue; pagination.IsSimple = page < 6; })); public bool IsSimple { get { return (bool)GetValue(IsSimpleProperty); } set { SetValue(IsSimpleProperty, value); } } public static readonly DependencyProperty IsSimpleProperty = DependencyProperty.Register("IsSimple", typeof(bool), typeof(Pagination), new PropertyMetadata(false)); public int CurrentPage { get { return (int)GetValue(CurrentPageProperty); } set { SetValue(CurrentPageProperty, value); CurrentPageChanged(value); } } public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register("CurrentPage", typeof(int), typeof(Pagination), new PropertyMetadata(1, (d, e) => { if (!(d is Pagination pagination)) return; if (pagination.PageCount > 5) { pagination.UpdateControl(); } else { pagination.UpdateControlSimple(); } })); public override void OnApplyTemplate() { base.OnApplyTemplate(); if (PageCount > 5) { InitControls(); } else { InitControlsSimple(); } } private List