123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace NEIntelligentControl2.Views.Basic
- {
- /// <summary>
- /// 状态栏
- /// </summary>
- public partial class InfoBar : UserControl
- {
- public static readonly DependencyProperty IsPaginationProperty = DependencyProperty.Register("IsPagination", typeof(bool), typeof(InfoBar));
- public static readonly DependencyProperty PageCountProperty = DependencyProperty.Register("PageCount", typeof(int), typeof(InfoBar));
- public static readonly DependencyProperty PageIndexProperty = DependencyProperty.Register("PageIndex", typeof(int), typeof(InfoBar));
- public static readonly DependencyProperty EachPageCountProperty = DependencyProperty.Register("EachPageCount", typeof(int), typeof(InfoBar));
- /// <summary>
- /// 是否分页
- /// </summary>
- public bool IsPagination { get => (bool)GetValue(IsPaginationProperty); set => SetValue(IsPaginationProperty, value); }
- /// <summary>
- /// 总页数
- /// </summary>
- public int PageCount { get=>(int)GetValue(PageCountProperty); set => SetValue(PageCountProperty, value); }
- /// <summary>
- /// 当前页码
- /// </summary>
- public int PageIndex { get => (int)GetValue(PageIndexProperty); set => SetValue(PageIndexProperty, value); }
- /// <summary>
- /// 每页条数
- /// </summary>
- public int EachPageCount { get => (int)GetValue(EachPageCountProperty); set => SetValue(EachPageCountProperty, value); }
- /// <summary>
- /// 分页动作 每页数据,第几页
- /// </summary>
- public Action<int,int> OnPagination { get; set; }
- public InfoBar()
- {
- InitializeComponent();
- IsPagination = true;
- PageCount = 1;
- PageIndex = 1;
- EachPageCount = 100;
- }
- internal void Inof(string v)
- {
- // FFCA5100 FF006CBE
- Dispatcher.Invoke(() =>
- {
- this.Visibility = Visibility.Visible;
- _SBMain.Background = new SolidColorBrush(Color.FromRgb(0x00, 0x6C, 0xBE));
- _TBStatus.Text = v;
- _tbEachCountTitle.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
- });
- }
- internal void Warning(string v)
- {
- Dispatcher.Invoke(() =>
- {
- this.Visibility = Visibility.Visible;
- _SBMain.Background = new SolidColorBrush(Color.FromRgb(0xCA, 0x51, 0x00));
- _TBStatus.Text = v;
- _tbEachCountTitle.Foreground = new SolidColorBrush(Colors.WhiteSmoke);
- });
- }
- internal void Success()
- {
- Dispatcher.Invoke(() =>
- {
- this._TBStatus.Text = "就绪";
- _SBMain.Background = new SolidColorBrush(Colors.WhiteSmoke);
- _tbEachCountTitle.Foreground = new SolidColorBrush(Colors.Black);
- if (!IsPagination)
- {
- this.Visibility = Visibility.Collapsed;
- }
- });
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- var tag = ((Control)sender).Tag as string;
- if (tag == null) return;
- switch (tag)
- {
- case "first":// 第一页
- PageIndex = 1;
- break;
- case "previous":// 上一页
- if (PageIndex <= 1) return;
- --PageIndex;
- break;
- case "last":// 下一页
- if (PageIndex >= PageCount) return;
- ++PageIndex;
- break;
- case "latest":// 最后一页
- PageIndex = PageCount;
- break;
- default:return;
- }
- this.OnPagination?.Invoke(EachPageCount, PageIndex);
- }
- }
- }
|