+ UIPagination:新增分页控件
This commit is contained in:
parent
ad5a7d9c18
commit
3a043477f7
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
79
SunnyUI.Demo/Controls/FDataGridView.Designer.cs
generated
79
SunnyUI.Demo/Controls/FDataGridView.Designer.cs
generated
@ -28,12 +28,12 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.uiDataGridView1 = new Sunny.UI.UIDataGridView();
|
||||
this.uiDataGridPage1 = new Sunny.UI.UIDataGridPage();
|
||||
this.uiPagination1 = new Sunny.UI.UIPagination();
|
||||
this.PagePanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uiDataGridView1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -41,37 +41,37 @@
|
||||
// PagePanel
|
||||
//
|
||||
this.PagePanel.Controls.Add(this.uiDataGridView1);
|
||||
this.PagePanel.Controls.Add(this.uiDataGridPage1);
|
||||
this.PagePanel.Controls.Add(this.uiPagination1);
|
||||
//
|
||||
// uiDataGridView1
|
||||
//
|
||||
this.uiDataGridView1.AllowUserToAddRows = false;
|
||||
this.uiDataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||
this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
|
||||
dataGridViewCellStyle9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||
this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle9;
|
||||
this.uiDataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.uiDataGridView1.BackgroundColor = System.Drawing.Color.White;
|
||||
this.uiDataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.uiDataGridView1.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
|
||||
this.uiDataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
|
||||
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
|
||||
dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||
dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White;
|
||||
dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10;
|
||||
this.uiDataGridView1.ColumnHeadersHeight = 32;
|
||||
this.uiDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
|
||||
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
|
||||
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle3;
|
||||
dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
dataGridViewCellStyle11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
|
||||
dataGridViewCellStyle11.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle11;
|
||||
this.uiDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.uiDataGridView1.EnableHeadersVisualStyles = false;
|
||||
this.uiDataGridView1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
@ -81,8 +81,8 @@
|
||||
this.uiDataGridView1.Name = "uiDataGridView1";
|
||||
this.uiDataGridView1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||
this.uiDataGridView1.RowHeadersVisible = false;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.Color.White;
|
||||
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle4;
|
||||
dataGridViewCellStyle12.BackColor = System.Drawing.Color.White;
|
||||
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle12;
|
||||
this.uiDataGridView1.RowTemplate.Height = 29;
|
||||
this.uiDataGridView1.SelectedIndex = -1;
|
||||
this.uiDataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
@ -91,19 +91,20 @@
|
||||
this.uiDataGridView1.TabIndex = 0;
|
||||
this.uiDataGridView1.TagString = null;
|
||||
//
|
||||
// uiDataGridPage1
|
||||
// uiPagination1
|
||||
//
|
||||
this.uiDataGridPage1.ActivePage = 6;
|
||||
this.uiDataGridPage1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.uiDataGridPage1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiDataGridPage1.Location = new System.Drawing.Point(0, 380);
|
||||
this.uiDataGridPage1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.uiDataGridPage1.Name = "uiDataGridPage1";
|
||||
this.uiDataGridPage1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
|
||||
this.uiDataGridPage1.Size = new System.Drawing.Size(800, 35);
|
||||
this.uiDataGridPage1.TabIndex = 1;
|
||||
this.uiDataGridPage1.Text = "uiDataGridPage1";
|
||||
this.uiDataGridPage1.TotalCount = 800;
|
||||
this.uiPagination1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.uiPagination1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiPagination1.Location = new System.Drawing.Point(0, 380);
|
||||
this.uiPagination1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.uiPagination1.Name = "uiPagination1";
|
||||
this.uiPagination1.PagerCount = 11;
|
||||
this.uiPagination1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
|
||||
this.uiPagination1.Size = new System.Drawing.Size(800, 35);
|
||||
this.uiPagination1.TabIndex = 1;
|
||||
this.uiPagination1.Text = "uiDataGridPage1";
|
||||
this.uiPagination1.TotalCount = 800;
|
||||
this.uiPagination1.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.uiPagination1_PageChanged);
|
||||
//
|
||||
// FDataGridView
|
||||
//
|
||||
@ -123,6 +124,6 @@
|
||||
#endregion
|
||||
|
||||
private UIDataGridView uiDataGridView1;
|
||||
private UIDataGridPage uiDataGridPage1;
|
||||
private UIPagination uiPagination1;
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace Sunny.UI.Demo
|
||||
base.Init();
|
||||
|
||||
List<Data> datas = new List<Data>();
|
||||
for (int i = 0; i < 200; i++)
|
||||
for (int i = 0; i < 365; i++)
|
||||
{
|
||||
Data data = new Data();
|
||||
data.Column1 = "Data" + i.ToString("D2");
|
||||
@ -30,8 +30,8 @@ namespace Sunny.UI.Demo
|
||||
datas.Add(data);
|
||||
}
|
||||
|
||||
uiDataGridView1.DataSource = datas;
|
||||
uiDataGridView1.SelectedIndex = 160;
|
||||
uiPagination1.DataSource = datas;
|
||||
uiPagination1.ActivePage = 1;
|
||||
}
|
||||
|
||||
public class Data
|
||||
@ -49,5 +49,10 @@ namespace Sunny.UI.Demo
|
||||
return Column1;
|
||||
}
|
||||
}
|
||||
|
||||
private void uiPagination1_PageChanged(object sender, object pagingSource, int pageIndex, int count)
|
||||
{
|
||||
uiDataGridView1.DataSource = pagingSource;
|
||||
}
|
||||
}
|
||||
}
|
@ -181,6 +181,7 @@ namespace Sunny.UI
|
||||
|
||||
try
|
||||
{
|
||||
inSetDataConnection = true;
|
||||
if (dataSourceChanged || displayMemberChanged)
|
||||
{
|
||||
CurrencyManager newDataManager = null;
|
||||
|
@ -1,656 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class UIDataGridPage : UIPanel
|
||||
{
|
||||
private UISymbolButton b1;
|
||||
private UISymbolButton b3;
|
||||
private UISymbolButton b2;
|
||||
private UISymbolButton b7;
|
||||
private UISymbolButton b6;
|
||||
private UISymbolButton b5;
|
||||
private UISymbolButton b4;
|
||||
private UISymbolButton b15;
|
||||
private UISymbolButton b14;
|
||||
private UISymbolButton b13;
|
||||
private UISymbolButton b12;
|
||||
private UISymbolButton b11;
|
||||
private UISymbolButton b10;
|
||||
private UISymbolButton b9;
|
||||
private UISymbolButton b8;
|
||||
private UISymbolButton b16;
|
||||
private UIPanel p1;
|
||||
private UILabel uiLabel2;
|
||||
private UITextBox edtPage;
|
||||
private UILabel uiLabel1;
|
||||
private UIComboBox cb1;
|
||||
private UISymbolButton b0;
|
||||
private ConcurrentDictionary<int, UISymbolButton> buttons = new ConcurrentDictionary<int, UISymbolButton>();
|
||||
|
||||
public UIDataGridPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ShowText = false;
|
||||
buttons.TryAdd(0, b0);
|
||||
buttons.TryAdd(1, b1);
|
||||
buttons.TryAdd(2, b2);
|
||||
buttons.TryAdd(3, b3);
|
||||
buttons.TryAdd(4, b4);
|
||||
buttons.TryAdd(5, b5);
|
||||
buttons.TryAdd(6, b6);
|
||||
buttons.TryAdd(7, b7);
|
||||
buttons.TryAdd(8, b8);
|
||||
buttons.TryAdd(9, b9);
|
||||
buttons.TryAdd(10, b10);
|
||||
buttons.TryAdd(11, b11);
|
||||
buttons.TryAdd(12, b12);
|
||||
buttons.TryAdd(13, b13);
|
||||
buttons.TryAdd(14, b14);
|
||||
buttons.TryAdd(15, b15);
|
||||
buttons.TryAdd(16, b16);
|
||||
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
buttons[i].MouseEnter += UIDataGridPage_MouseEnter;
|
||||
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
|
||||
buttons[i].Click += UIDataGridPage_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDataGridPage_Click(object sender, EventArgs e)
|
||||
{
|
||||
UISymbolButton btn = (UISymbolButton)sender;
|
||||
if (btn.TagString.IsValid())
|
||||
{
|
||||
ActivePage += btn.Tag.ToString().ToInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivePage = btn.Tag.ToString().ToInt();
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDataGridPage_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
UISymbolButton btn = (UISymbolButton)sender;
|
||||
if (btn.TagString == "<<" || btn.TagString == ">>")
|
||||
{
|
||||
btn.Symbol = 0;
|
||||
btn.Text = @"···";
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDataGridPage_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
UISymbolButton btn = (UISymbolButton)sender;
|
||||
if (btn.TagString == "<<")
|
||||
{
|
||||
btn.Symbol = 61696;
|
||||
btn.Text = "";
|
||||
}
|
||||
|
||||
if (btn.TagString == ">>")
|
||||
{
|
||||
btn.Symbol = 61697;
|
||||
btn.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
#region InitializeComponent
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.b0 = new Sunny.UI.UISymbolButton();
|
||||
this.b1 = new Sunny.UI.UISymbolButton();
|
||||
this.b3 = new Sunny.UI.UISymbolButton();
|
||||
this.b2 = new Sunny.UI.UISymbolButton();
|
||||
this.b7 = new Sunny.UI.UISymbolButton();
|
||||
this.b6 = new Sunny.UI.UISymbolButton();
|
||||
this.b5 = new Sunny.UI.UISymbolButton();
|
||||
this.b4 = new Sunny.UI.UISymbolButton();
|
||||
this.b15 = new Sunny.UI.UISymbolButton();
|
||||
this.b14 = new Sunny.UI.UISymbolButton();
|
||||
this.b13 = new Sunny.UI.UISymbolButton();
|
||||
this.b12 = new Sunny.UI.UISymbolButton();
|
||||
this.b11 = new Sunny.UI.UISymbolButton();
|
||||
this.b10 = new Sunny.UI.UISymbolButton();
|
||||
this.b9 = new Sunny.UI.UISymbolButton();
|
||||
this.b8 = new Sunny.UI.UISymbolButton();
|
||||
this.b16 = new Sunny.UI.UISymbolButton();
|
||||
this.p1 = new Sunny.UI.UIPanel();
|
||||
this.uiLabel2 = new Sunny.UI.UILabel();
|
||||
this.edtPage = new Sunny.UI.UITextBox();
|
||||
this.uiLabel1 = new Sunny.UI.UILabel();
|
||||
this.cb1 = new Sunny.UI.UIComboBox();
|
||||
this.p1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// b0
|
||||
//
|
||||
this.b0.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b0.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b0.Location = new System.Drawing.Point(3, 3);
|
||||
this.b0.Name = "b0";
|
||||
this.b0.Size = new System.Drawing.Size(29, 29);
|
||||
this.b0.Symbol = 61700;
|
||||
this.b0.TabIndex = 0;
|
||||
this.b0.Tag = "-1";
|
||||
this.b0.TagString = "<";
|
||||
//
|
||||
// b1
|
||||
//
|
||||
this.b1.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b1.Location = new System.Drawing.Point(35, 3);
|
||||
this.b1.Name = "b1";
|
||||
this.b1.Size = new System.Drawing.Size(29, 29);
|
||||
this.b1.Symbol = 0;
|
||||
this.b1.TabIndex = 1;
|
||||
this.b1.Text = "0";
|
||||
//
|
||||
// b3
|
||||
//
|
||||
this.b3.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b3.Location = new System.Drawing.Point(99, 3);
|
||||
this.b3.Name = "b3";
|
||||
this.b3.Size = new System.Drawing.Size(29, 29);
|
||||
this.b3.Symbol = 0;
|
||||
this.b3.TabIndex = 3;
|
||||
this.b3.Text = "0";
|
||||
//
|
||||
// b2
|
||||
//
|
||||
this.b2.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b2.Location = new System.Drawing.Point(67, 3);
|
||||
this.b2.Name = "b2";
|
||||
this.b2.Size = new System.Drawing.Size(29, 29);
|
||||
this.b2.Symbol = 0;
|
||||
this.b2.TabIndex = 2;
|
||||
this.b2.Text = "0";
|
||||
//
|
||||
// b7
|
||||
//
|
||||
this.b7.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b7.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b7.Location = new System.Drawing.Point(227, 3);
|
||||
this.b7.Name = "b7";
|
||||
this.b7.Size = new System.Drawing.Size(29, 29);
|
||||
this.b7.Symbol = 0;
|
||||
this.b7.TabIndex = 7;
|
||||
this.b7.Text = "0";
|
||||
//
|
||||
// b6
|
||||
//
|
||||
this.b6.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b6.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b6.Location = new System.Drawing.Point(195, 3);
|
||||
this.b6.Name = "b6";
|
||||
this.b6.Size = new System.Drawing.Size(29, 29);
|
||||
this.b6.Symbol = 0;
|
||||
this.b6.TabIndex = 6;
|
||||
this.b6.Text = "0";
|
||||
//
|
||||
// b5
|
||||
//
|
||||
this.b5.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b5.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b5.Location = new System.Drawing.Point(163, 3);
|
||||
this.b5.Name = "b5";
|
||||
this.b5.Size = new System.Drawing.Size(29, 29);
|
||||
this.b5.Symbol = 0;
|
||||
this.b5.TabIndex = 5;
|
||||
this.b5.Text = "0";
|
||||
//
|
||||
// b4
|
||||
//
|
||||
this.b4.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b4.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b4.Location = new System.Drawing.Point(131, 3);
|
||||
this.b4.Name = "b4";
|
||||
this.b4.Size = new System.Drawing.Size(29, 29);
|
||||
this.b4.Symbol = 0;
|
||||
this.b4.TabIndex = 4;
|
||||
this.b4.Text = "0";
|
||||
//
|
||||
// b15
|
||||
//
|
||||
this.b15.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b15.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b15.Location = new System.Drawing.Point(483, 3);
|
||||
this.b15.Name = "b15";
|
||||
this.b15.Size = new System.Drawing.Size(29, 29);
|
||||
this.b15.Symbol = 0;
|
||||
this.b15.TabIndex = 15;
|
||||
this.b15.Text = "0";
|
||||
//
|
||||
// b14
|
||||
//
|
||||
this.b14.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b14.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b14.Location = new System.Drawing.Point(451, 3);
|
||||
this.b14.Name = "b14";
|
||||
this.b14.Size = new System.Drawing.Size(29, 29);
|
||||
this.b14.Symbol = 0;
|
||||
this.b14.TabIndex = 14;
|
||||
this.b14.Text = "0";
|
||||
//
|
||||
// b13
|
||||
//
|
||||
this.b13.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b13.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b13.Location = new System.Drawing.Point(419, 3);
|
||||
this.b13.Name = "b13";
|
||||
this.b13.Size = new System.Drawing.Size(29, 29);
|
||||
this.b13.Symbol = 0;
|
||||
this.b13.TabIndex = 13;
|
||||
this.b13.Text = "0";
|
||||
//
|
||||
// b12
|
||||
//
|
||||
this.b12.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b12.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b12.Location = new System.Drawing.Point(387, 3);
|
||||
this.b12.Name = "b12";
|
||||
this.b12.Size = new System.Drawing.Size(29, 29);
|
||||
this.b12.Symbol = 0;
|
||||
this.b12.TabIndex = 12;
|
||||
this.b12.Text = "0";
|
||||
//
|
||||
// b11
|
||||
//
|
||||
this.b11.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b11.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b11.Location = new System.Drawing.Point(355, 3);
|
||||
this.b11.Name = "b11";
|
||||
this.b11.Size = new System.Drawing.Size(29, 29);
|
||||
this.b11.Symbol = 0;
|
||||
this.b11.TabIndex = 11;
|
||||
this.b11.Text = "0";
|
||||
//
|
||||
// b10
|
||||
//
|
||||
this.b10.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b10.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b10.Location = new System.Drawing.Point(323, 3);
|
||||
this.b10.Name = "b10";
|
||||
this.b10.Size = new System.Drawing.Size(29, 29);
|
||||
this.b10.Symbol = 0;
|
||||
this.b10.TabIndex = 10;
|
||||
this.b10.Text = "0";
|
||||
//
|
||||
// b9
|
||||
//
|
||||
this.b9.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b9.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b9.Location = new System.Drawing.Point(291, 3);
|
||||
this.b9.Name = "b9";
|
||||
this.b9.Size = new System.Drawing.Size(29, 29);
|
||||
this.b9.Symbol = 0;
|
||||
this.b9.TabIndex = 9;
|
||||
this.b9.Text = "0";
|
||||
//
|
||||
// b8
|
||||
//
|
||||
this.b8.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b8.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b8.Location = new System.Drawing.Point(259, 3);
|
||||
this.b8.Name = "b8";
|
||||
this.b8.Size = new System.Drawing.Size(29, 29);
|
||||
this.b8.Symbol = 0;
|
||||
this.b8.TabIndex = 8;
|
||||
this.b8.Text = "0";
|
||||
//
|
||||
// b16
|
||||
//
|
||||
this.b16.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.b16.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.b16.Location = new System.Drawing.Point(515, 3);
|
||||
this.b16.Name = "b16";
|
||||
this.b16.Size = new System.Drawing.Size(29, 29);
|
||||
this.b16.Symbol = 61701;
|
||||
this.b16.TabIndex = 16;
|
||||
this.b16.Tag = "1";
|
||||
this.b16.TagString = ">";
|
||||
this.b16.LocationChanged += new System.EventHandler(this.b16_LocationChanged);
|
||||
//
|
||||
// p1
|
||||
//
|
||||
this.p1.Controls.Add(this.uiLabel2);
|
||||
this.p1.Controls.Add(this.edtPage);
|
||||
this.p1.Controls.Add(this.uiLabel1);
|
||||
this.p1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.p1.Location = new System.Drawing.Point(549, 3);
|
||||
this.p1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.p1.Name = "p1";
|
||||
this.p1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
|
||||
this.p1.Size = new System.Drawing.Size(126, 29);
|
||||
this.p1.TabIndex = 17;
|
||||
this.p1.Text = null;
|
||||
//
|
||||
// uiLabel2
|
||||
//
|
||||
this.uiLabel2.AutoSize = true;
|
||||
this.uiLabel2.BackColor = System.Drawing.Color.Transparent;
|
||||
this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLabel2.Location = new System.Drawing.Point(100, 4);
|
||||
this.uiLabel2.Name = "uiLabel2";
|
||||
this.uiLabel2.Size = new System.Drawing.Size(26, 21);
|
||||
this.uiLabel2.TabIndex = 2;
|
||||
this.uiLabel2.Text = "页";
|
||||
this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// edtPage
|
||||
//
|
||||
this.edtPage.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.edtPage.DoubleValue = 10D;
|
||||
this.edtPage.FillColor = System.Drawing.Color.White;
|
||||
this.edtPage.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.edtPage.HasMinimum = true;
|
||||
this.edtPage.IntValue = 10;
|
||||
this.edtPage.Location = new System.Drawing.Point(45, 0);
|
||||
this.edtPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.edtPage.Maximum = 2147483647D;
|
||||
this.edtPage.Minimum = 1D;
|
||||
this.edtPage.Name = "edtPage";
|
||||
this.edtPage.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.edtPage.Size = new System.Drawing.Size(53, 29);
|
||||
this.edtPage.TabIndex = 1;
|
||||
this.edtPage.Text = "10";
|
||||
this.edtPage.TextAlignment = System.Drawing.ContentAlignment.BottomCenter;
|
||||
this.edtPage.Type = Sunny.UI.UITextBox.UIEditType.Integer;
|
||||
this.edtPage.Leave += new System.EventHandler(this.edtPage_Leave);
|
||||
//
|
||||
// uiLabel1
|
||||
//
|
||||
this.uiLabel1.AutoSize = true;
|
||||
this.uiLabel1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiLabel1.Location = new System.Drawing.Point(3, 4);
|
||||
this.uiLabel1.Name = "uiLabel1";
|
||||
this.uiLabel1.Size = new System.Drawing.Size(42, 21);
|
||||
this.uiLabel1.TabIndex = 0;
|
||||
this.uiLabel1.Text = "前往";
|
||||
this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// cb1
|
||||
//
|
||||
this.cb1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.cb1.FillColor = System.Drawing.Color.White;
|
||||
this.cb1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.cb1.Items.AddRange(new object[] {
|
||||
"10条/页",
|
||||
"20条/页",
|
||||
"50条/页",
|
||||
"100条/页",
|
||||
"200条/页"});
|
||||
this.cb1.Location = new System.Drawing.Point(683, 3);
|
||||
this.cb1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.cb1.MinimumSize = new System.Drawing.Size(63, 0);
|
||||
this.cb1.Name = "cb1";
|
||||
this.cb1.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
|
||||
this.cb1.Size = new System.Drawing.Size(103, 29);
|
||||
this.cb1.TabIndex = 19;
|
||||
this.cb1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.cb1.Visible = false;
|
||||
//
|
||||
// UIDataGridPage
|
||||
//
|
||||
this.Controls.Add(this.cb1);
|
||||
this.Controls.Add(this.p1);
|
||||
this.Controls.Add(this.b16);
|
||||
this.Controls.Add(this.b15);
|
||||
this.Controls.Add(this.b14);
|
||||
this.Controls.Add(this.b13);
|
||||
this.Controls.Add(this.b12);
|
||||
this.Controls.Add(this.b11);
|
||||
this.Controls.Add(this.b10);
|
||||
this.Controls.Add(this.b9);
|
||||
this.Controls.Add(this.b8);
|
||||
this.Controls.Add(this.b7);
|
||||
this.Controls.Add(this.b6);
|
||||
this.Controls.Add(this.b5);
|
||||
this.Controls.Add(this.b4);
|
||||
this.Controls.Add(this.b3);
|
||||
this.Controls.Add(this.b2);
|
||||
this.Controls.Add(this.b1);
|
||||
this.Controls.Add(this.b0);
|
||||
this.Name = "UIDataGridPage";
|
||||
this.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
|
||||
this.Size = new System.Drawing.Size(1100, 35);
|
||||
this.p1.ResumeLayout(false);
|
||||
this.p1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion InitializeComponent
|
||||
|
||||
private int totalCount = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// 总条目数
|
||||
/// </summary>
|
||||
[DefaultValue(1000), Description("总条目数")]
|
||||
public int TotalCount
|
||||
{
|
||||
get => totalCount;
|
||||
set
|
||||
{
|
||||
if (totalCount != value)
|
||||
{
|
||||
totalCount = Math.Max(0, value);
|
||||
SetShowButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int pageSize = 20;
|
||||
|
||||
/// <summary>
|
||||
/// 每页显示条目个数
|
||||
/// </summary>
|
||||
[DefaultValue(20),Description("每页显示条目个数")]
|
||||
public int PageSize
|
||||
{
|
||||
get => pageSize;
|
||||
set
|
||||
{
|
||||
if (pageSize != value)
|
||||
{
|
||||
pageSize = Math.Max(1, value);
|
||||
SetShowButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int pagerCount = 7;
|
||||
|
||||
/// <summary>
|
||||
/// 页码按钮的数量,当总页数超过该值时会折叠
|
||||
/// 大于等于 5 且小于等于 13 的奇数
|
||||
/// </summary>
|
||||
[DefaultValue(7),Description("页码按钮的数量,当总页数超过该值时会折叠,大于等于5且小于等于13的奇数")]
|
||||
public int PagerCount
|
||||
{
|
||||
get => pagerCount;
|
||||
set
|
||||
{
|
||||
if (pagerCount != value)
|
||||
{
|
||||
pagerCount = Math.Max(5, value);
|
||||
pagerCount = Math.Min(13, pagerCount);
|
||||
if (pagerCount.Mod(2) == 0)
|
||||
pagerCount = pagerCount - 1;
|
||||
|
||||
SetShowButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int PageCount;
|
||||
private int activePage=1;
|
||||
|
||||
/// <summary>
|
||||
/// 选中页面
|
||||
/// </summary>
|
||||
[DefaultValue(1), Description("选中页面")]
|
||||
public int ActivePage
|
||||
{
|
||||
get => activePage;
|
||||
set
|
||||
{
|
||||
if (activePage != value)
|
||||
{
|
||||
activePage = Math.Max(1, value);
|
||||
edtPage.IntValue = activePage;
|
||||
SetShowButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetShowButton(int buttonIdx, int pageIdx, int activeIdx)
|
||||
{
|
||||
buttons[buttonIdx].Symbol = 0;
|
||||
buttons[buttonIdx].Text = pageIdx.ToString();
|
||||
buttons[buttonIdx].Tag = pageIdx;
|
||||
buttons[buttonIdx].Visible = true;
|
||||
buttons[buttonIdx].TagString = "";
|
||||
buttons[buttonIdx].Selected = activeIdx == pageIdx;
|
||||
}
|
||||
|
||||
private void SetShowButton(int buttonIdx, int addCount, string tagString)
|
||||
{
|
||||
buttons[buttonIdx].Symbol = 0;
|
||||
buttons[buttonIdx].Text = @"···";
|
||||
buttons[buttonIdx].Tag = addCount;
|
||||
buttons[buttonIdx].Visible = true;
|
||||
buttons[buttonIdx].TagString = tagString;
|
||||
buttons[buttonIdx].Selected = false;
|
||||
}
|
||||
|
||||
private void SetHideButton(int beginIdx)
|
||||
{
|
||||
for (int i = beginIdx; i < 16; i++)
|
||||
{
|
||||
buttons[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetShowButtons()
|
||||
{
|
||||
b0.Visible = true;
|
||||
b16.Visible = true;
|
||||
|
||||
PageCount = TotalCount.Mod(PageSize) == 0 ? TotalCount / PageSize : TotalCount / PageSize + 1;
|
||||
edtPage.HasMaximum = true;
|
||||
edtPage.Maximum = PageCount;
|
||||
|
||||
if (activePage > PageCount) activePage = PageCount;
|
||||
if (activePage < 1) activePage = 1;
|
||||
edtPage.IntValue = activePage;
|
||||
|
||||
if (TotalCount == 0)
|
||||
{
|
||||
PageCount = 1;
|
||||
activePage = 1;
|
||||
SetShowButton(1, 1, 1);
|
||||
SetHideButton(2);
|
||||
b16.Left = b1.Right + 3;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PageCount <= PagerCount + 2)
|
||||
{
|
||||
for (int i = 1; i <= PageCount; i++)
|
||||
{
|
||||
SetShowButton(i, i, activePage);
|
||||
}
|
||||
|
||||
b16.Left = buttons[PageCount].Right + 3;
|
||||
SetHideButton(PageCount + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//左
|
||||
int leftShow = PagerCount / 2 + 1 + 2;
|
||||
if (activePage <= leftShow)
|
||||
{
|
||||
for (int i = 1; i <= leftShow; i++)
|
||||
{
|
||||
SetShowButton(i, i, activePage);
|
||||
}
|
||||
|
||||
SetShowButton(leftShow + 1, PagerCount - 2, ">>");
|
||||
SetShowButton(leftShow + 2, PageCount, activePage);
|
||||
SetHideButton(leftShow + 3);
|
||||
b16.Left = buttons[leftShow + 2].Right + 3;
|
||||
return;
|
||||
}
|
||||
|
||||
//右
|
||||
int rightShow = PageCount - (PagerCount / 2 + 1) - 1;
|
||||
if (activePage >= rightShow)
|
||||
{
|
||||
SetShowButton(1, 1, activePage);
|
||||
SetShowButton(2, 2 - PagerCount, "<<");
|
||||
|
||||
int idx = 3;
|
||||
for (int i = rightShow; i <= PageCount; i++)
|
||||
{
|
||||
SetShowButton(idx, i, activePage);
|
||||
idx++;
|
||||
}
|
||||
|
||||
b16.Left = buttons[idx - 1].Right + 3;
|
||||
SetHideButton(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
//中
|
||||
SetShowButton(1, 1, activePage);
|
||||
SetShowButton(2, 2 - PagerCount, "<<");
|
||||
int cIdx = 3;
|
||||
int sIdx = (PagerCount - 2) / 2;
|
||||
for (int i = cIdx; i <= PagerCount; i++)
|
||||
{
|
||||
SetShowButton(cIdx, activePage - sIdx + (i - 3), activePage);
|
||||
cIdx++;
|
||||
}
|
||||
|
||||
SetShowButton(cIdx, PagerCount - 2, ">>");
|
||||
SetShowButton(cIdx + 1, PageCount, activePage);
|
||||
b16.Left = buttons[cIdx + 1].Right + 3;
|
||||
SetHideButton(cIdx + 2);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
|
||||
foreach (var button in buttons.Values)
|
||||
{
|
||||
button.FillColor = uiColor.PlainColor;
|
||||
button.ForeColor = uiColor.RectColor;
|
||||
button.FillSelectedColor = uiColor.ButtonFillColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void b16_LocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
p1.Left = b16.Right + 3;
|
||||
}
|
||||
|
||||
private void edtPage_Leave(object sender, EventArgs e)
|
||||
{
|
||||
ActivePage = edtPage.IntValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -473,6 +473,19 @@ namespace Sunny.UI
|
||||
return column;
|
||||
}
|
||||
|
||||
public DataGridViewColumn AddButtonColumn(string columnName, string dataPropertyName, int fillWeight = 100, bool readOnly = true)
|
||||
{
|
||||
DataGridViewColumn column = new DataGridViewButtonColumn();
|
||||
column.HeaderText = columnName;
|
||||
column.DataPropertyName = dataPropertyName;
|
||||
column.Name = columnName;
|
||||
column.ReadOnly = readOnly;
|
||||
column.FillWeight = fillWeight;
|
||||
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
Columns.Add(column);
|
||||
return column;
|
||||
}
|
||||
|
||||
public void ClearRows()
|
||||
{
|
||||
if (DataSource != null)
|
||||
|
813
SunnyUI/Controls/UIPagination.cs
Normal file
813
SunnyUI/Controls/UIPagination.cs
Normal file
@ -0,0 +1,813 @@
|
||||
/******************************************************************************
|
||||
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
|
||||
* CopyRight (C) 2012-2020 ShenYongHua(沈永华).
|
||||
* QQ群:56829229 QQ:17612584 EMail:SunnyUI@qq.com
|
||||
*
|
||||
* Blog: https://www.cnblogs.com/yhuse
|
||||
* Gitee: https://gitee.com/yhuse/SunnyUI
|
||||
* GitHub: https://github.com/yhuse/SunnyUI
|
||||
*
|
||||
* SunnyUI can be used for free under the GPL-3.0 license.
|
||||
* If you use this code, please keep this note.
|
||||
* 如果您使用此代码,请保留此说明。
|
||||
******************************************************************************
|
||||
* 文件名称: UIPagination.cs
|
||||
* 文件说明: 分页
|
||||
* 当前版本: V2.2
|
||||
* 创建日期: 2020-07-26
|
||||
*
|
||||
* 2020-07-15: V2.2.6 新增分页控件
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
public class UIPagination : UIPanel
|
||||
{
|
||||
public delegate void OnPageChangeEventHandler(object sender, object pagingSource, int pageIndex, int count);
|
||||
|
||||
private int activePage = 1;
|
||||
private UISymbolButton b0;
|
||||
private UISymbolButton b1;
|
||||
private UISymbolButton b10;
|
||||
private UISymbolButton b11;
|
||||
private UISymbolButton b12;
|
||||
private UISymbolButton b13;
|
||||
private UISymbolButton b14;
|
||||
private UISymbolButton b15;
|
||||
private UISymbolButton b16;
|
||||
private UISymbolButton b2;
|
||||
private UISymbolButton b3;
|
||||
private UISymbolButton b4;
|
||||
private UISymbolButton b5;
|
||||
private UISymbolButton b6;
|
||||
private UISymbolButton b7;
|
||||
private UISymbolButton b8;
|
||||
private UISymbolButton b9;
|
||||
private UISymbolButton btnSelect;
|
||||
|
||||
private readonly ConcurrentDictionary<int, UISymbolButton> buttons =
|
||||
new ConcurrentDictionary<int, UISymbolButton>();
|
||||
|
||||
private UIComboBox cb1;
|
||||
private CurrencyManager dataManager;
|
||||
|
||||
private object dataSource;
|
||||
private UITextBox edtPage;
|
||||
|
||||
private bool inSetDataConnection;
|
||||
private UIPanel p1;
|
||||
|
||||
private int PageCount;
|
||||
|
||||
private int pagerCount = 7;
|
||||
|
||||
private int pageSize = 20;
|
||||
|
||||
private int totalCount = 1000;
|
||||
private UILabel uiLabel1;
|
||||
private UILabel uiLabel2;
|
||||
|
||||
public UIPagination()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ShowText = false;
|
||||
buttons.TryAdd(0, b0);
|
||||
buttons.TryAdd(1, b1);
|
||||
buttons.TryAdd(2, b2);
|
||||
buttons.TryAdd(3, b3);
|
||||
buttons.TryAdd(4, b4);
|
||||
buttons.TryAdd(5, b5);
|
||||
buttons.TryAdd(6, b6);
|
||||
buttons.TryAdd(7, b7);
|
||||
buttons.TryAdd(8, b8);
|
||||
buttons.TryAdd(9, b9);
|
||||
buttons.TryAdd(10, b10);
|
||||
buttons.TryAdd(11, b11);
|
||||
buttons.TryAdd(12, b12);
|
||||
buttons.TryAdd(13, b13);
|
||||
buttons.TryAdd(14, b14);
|
||||
buttons.TryAdd(15, b15);
|
||||
buttons.TryAdd(16, b16);
|
||||
|
||||
for (var i = 0; i < 17; i++)
|
||||
{
|
||||
buttons[i].MouseEnter += UIDataGridPage_MouseEnter;
|
||||
buttons[i].MouseLeave += UIDataGridPage_MouseLeave;
|
||||
buttons[i].Click += UIDataGridPage_Click;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 总条目数
|
||||
/// </summary>
|
||||
[DefaultValue(1000)]
|
||||
[Description("总条目数")]
|
||||
[Category("SunnyUI")]
|
||||
public int TotalCount
|
||||
{
|
||||
get => totalCount;
|
||||
set
|
||||
{
|
||||
if (totalCount != value)
|
||||
{
|
||||
totalCount = Math.Max(0, value);
|
||||
SetShowButtons();
|
||||
DataBind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每页显示条目个数
|
||||
/// </summary>
|
||||
[DefaultValue(20)]
|
||||
[Description("每页显示条目个数")]
|
||||
[Category("SunnyUI")]
|
||||
public int PageSize
|
||||
{
|
||||
get => pageSize;
|
||||
set
|
||||
{
|
||||
if (pageSize != value)
|
||||
{
|
||||
pageSize = Math.Max(1, value);
|
||||
SetShowButtons();
|
||||
DataBind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 页码按钮的数量,当总页数超过该值时会折叠
|
||||
/// 大于等于 5 且小于等于 13 的奇数
|
||||
/// </summary>
|
||||
[DefaultValue(7)]
|
||||
[Description("页码按钮的数量,当总页数超过该值时会折叠,大于等于5且小于等于13的奇数")]
|
||||
[Category("SunnyUI")]
|
||||
public int PagerCount
|
||||
{
|
||||
get => pagerCount;
|
||||
set
|
||||
{
|
||||
if (pagerCount != value)
|
||||
{
|
||||
pagerCount = Math.Max(5, value);
|
||||
pagerCount = Math.Min(13, pagerCount);
|
||||
if (pagerCount.Mod(2) == 0)
|
||||
pagerCount = pagerCount - 1;
|
||||
|
||||
SetShowButtons();
|
||||
DataBind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选中页面
|
||||
/// </summary>
|
||||
[DefaultValue(1)]
|
||||
[Description("选中页面")]
|
||||
[Category("SunnyUI")]
|
||||
public int ActivePage
|
||||
{
|
||||
get => activePage;
|
||||
set
|
||||
{
|
||||
if (activePage != value)
|
||||
{
|
||||
activePage = Math.Max(1, value);
|
||||
edtPage.IntValue = activePage;
|
||||
SetShowButtons();
|
||||
DataBind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool ShowJumpButton
|
||||
{
|
||||
get => p1.Visible;
|
||||
set => p1.Visible = value;
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[RefreshProperties(RefreshProperties.Repaint)]
|
||||
[AttributeProvider(typeof(IListSource))]
|
||||
public object DataSource
|
||||
{
|
||||
get => dataSource;
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
if (!(value is DataTable || value is IList))
|
||||
throw new Exception(UILocalize.GridDataSourceException);
|
||||
|
||||
SetDataConnection(value, new BindingMemberInfo(""));
|
||||
dataSource = value;
|
||||
activePage = 1;
|
||||
TotalCount = dataManager?.List.Count ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)] public object PageDataSource { get; private set; }
|
||||
|
||||
private void UIDataGridPage_Click(object sender, EventArgs e)
|
||||
{
|
||||
var btn = (UISymbolButton)sender;
|
||||
btn.BringToFront();
|
||||
if (btn.TagString.IsValid())
|
||||
ActivePage += btn.Tag.ToString().ToInt();
|
||||
else
|
||||
ActivePage = btn.Tag.ToString().ToInt();
|
||||
}
|
||||
|
||||
private void UIDataGridPage_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
var btn = (UISymbolButton)sender;
|
||||
if (btn.TagString == "<<" || btn.TagString == ">>")
|
||||
{
|
||||
btn.Symbol = 0;
|
||||
btn.Text = @"···";
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDataGridPage_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
var btn = (UISymbolButton)sender;
|
||||
if (btn.TagString == "<<")
|
||||
{
|
||||
btn.Symbol = 61696;
|
||||
btn.Text = "";
|
||||
}
|
||||
|
||||
if (btn.TagString == ">>")
|
||||
{
|
||||
btn.Symbol = 61697;
|
||||
btn.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
#region InitializeComponent
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
b0 = new UISymbolButton();
|
||||
b1 = new UISymbolButton();
|
||||
b3 = new UISymbolButton();
|
||||
b2 = new UISymbolButton();
|
||||
b7 = new UISymbolButton();
|
||||
b6 = new UISymbolButton();
|
||||
b5 = new UISymbolButton();
|
||||
b4 = new UISymbolButton();
|
||||
b15 = new UISymbolButton();
|
||||
b14 = new UISymbolButton();
|
||||
b13 = new UISymbolButton();
|
||||
b12 = new UISymbolButton();
|
||||
b11 = new UISymbolButton();
|
||||
b10 = new UISymbolButton();
|
||||
b9 = new UISymbolButton();
|
||||
b8 = new UISymbolButton();
|
||||
b16 = new UISymbolButton();
|
||||
p1 = new UIPanel();
|
||||
btnSelect = new UISymbolButton();
|
||||
uiLabel2 = new UILabel();
|
||||
edtPage = new UITextBox();
|
||||
uiLabel1 = new UILabel();
|
||||
cb1 = new UIComboBox();
|
||||
p1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// b0
|
||||
//
|
||||
b0.Cursor = Cursors.Hand;
|
||||
b0.Font = new Font("微软雅黑", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
b0.ImageAlign = ContentAlignment.MiddleLeft;
|
||||
b0.Location = new Point(3, 3);
|
||||
b0.Name = "b0";
|
||||
b0.Padding = new Padding(5, 0, 5, 0);
|
||||
b0.RadiusSides = UICornerRadiusSides.LeftTop | UICornerRadiusSides.LeftBottom;
|
||||
b0.Size = new Size(75, 29);
|
||||
b0.Symbol = 61700;
|
||||
b0.TabIndex = 0;
|
||||
b0.Tag = "-1";
|
||||
b0.TagString = "<";
|
||||
b0.Text = "上一页";
|
||||
b0.TextAlign = ContentAlignment.MiddleRight;
|
||||
//
|
||||
// b1
|
||||
//
|
||||
b1.Cursor = Cursors.Hand;
|
||||
b1.Font = new Font("微软雅黑", 12F);
|
||||
b1.Location = new Point(77, 3);
|
||||
b1.Name = "b1";
|
||||
b1.RadiusSides = UICornerRadiusSides.None;
|
||||
b1.Size = new Size(29, 29);
|
||||
b1.Symbol = 0;
|
||||
b1.TabIndex = 1;
|
||||
b1.Text = "0";
|
||||
//
|
||||
// b3
|
||||
//
|
||||
b3.Cursor = Cursors.Hand;
|
||||
b3.Font = new Font("微软雅黑", 12F);
|
||||
b3.Location = new Point(133, 3);
|
||||
b3.Name = "b3";
|
||||
b3.RadiusSides = UICornerRadiusSides.None;
|
||||
b3.Size = new Size(29, 29);
|
||||
b3.Symbol = 0;
|
||||
b3.TabIndex = 3;
|
||||
b3.Text = "0";
|
||||
//
|
||||
// b2
|
||||
//
|
||||
b2.Cursor = Cursors.Hand;
|
||||
b2.Font = new Font("微软雅黑", 12F);
|
||||
b2.Location = new Point(105, 3);
|
||||
b2.Name = "b2";
|
||||
b2.RadiusSides = UICornerRadiusSides.None;
|
||||
b2.Size = new Size(29, 29);
|
||||
b2.Symbol = 0;
|
||||
b2.TabIndex = 2;
|
||||
b2.Text = "0";
|
||||
//
|
||||
// b7
|
||||
//
|
||||
b7.Cursor = Cursors.Hand;
|
||||
b7.Font = new Font("微软雅黑", 12F);
|
||||
b7.Location = new Point(245, 3);
|
||||
b7.Name = "b7";
|
||||
b7.RadiusSides = UICornerRadiusSides.None;
|
||||
b7.Size = new Size(29, 29);
|
||||
b7.Symbol = 0;
|
||||
b7.TabIndex = 7;
|
||||
b7.Text = "0";
|
||||
//
|
||||
// b6
|
||||
//
|
||||
b6.Cursor = Cursors.Hand;
|
||||
b6.Font = new Font("微软雅黑", 12F);
|
||||
b6.Location = new Point(217, 3);
|
||||
b6.Name = "b6";
|
||||
b6.RadiusSides = UICornerRadiusSides.None;
|
||||
b6.Size = new Size(29, 29);
|
||||
b6.Symbol = 0;
|
||||
b6.TabIndex = 6;
|
||||
b6.Text = "0";
|
||||
//
|
||||
// b5
|
||||
//
|
||||
b5.Cursor = Cursors.Hand;
|
||||
b5.Font = new Font("微软雅黑", 12F);
|
||||
b5.Location = new Point(189, 3);
|
||||
b5.Name = "b5";
|
||||
b5.RadiusSides = UICornerRadiusSides.None;
|
||||
b5.Size = new Size(29, 29);
|
||||
b5.Symbol = 0;
|
||||
b5.TabIndex = 5;
|
||||
b5.Text = "0";
|
||||
//
|
||||
// b4
|
||||
//
|
||||
b4.Cursor = Cursors.Hand;
|
||||
b4.Font = new Font("微软雅黑", 12F);
|
||||
b4.Location = new Point(161, 3);
|
||||
b4.Name = "b4";
|
||||
b4.RadiusSides = UICornerRadiusSides.None;
|
||||
b4.Size = new Size(29, 29);
|
||||
b4.Symbol = 0;
|
||||
b4.TabIndex = 4;
|
||||
b4.Text = "0";
|
||||
//
|
||||
// b15
|
||||
//
|
||||
b15.Cursor = Cursors.Hand;
|
||||
b15.Font = new Font("微软雅黑", 12F);
|
||||
b15.Location = new Point(469, 3);
|
||||
b15.Name = "b15";
|
||||
b15.RadiusSides = UICornerRadiusSides.None;
|
||||
b15.Size = new Size(29, 29);
|
||||
b15.Symbol = 0;
|
||||
b15.TabIndex = 15;
|
||||
b15.Text = "0";
|
||||
//
|
||||
// b14
|
||||
//
|
||||
b14.Cursor = Cursors.Hand;
|
||||
b14.Font = new Font("微软雅黑", 12F);
|
||||
b14.Location = new Point(441, 3);
|
||||
b14.Name = "b14";
|
||||
b14.RadiusSides = UICornerRadiusSides.None;
|
||||
b14.Size = new Size(29, 29);
|
||||
b14.Symbol = 0;
|
||||
b14.TabIndex = 14;
|
||||
b14.Text = "0";
|
||||
//
|
||||
// b13
|
||||
//
|
||||
b13.Cursor = Cursors.Hand;
|
||||
b13.Font = new Font("微软雅黑", 12F);
|
||||
b13.Location = new Point(413, 3);
|
||||
b13.Name = "b13";
|
||||
b13.RadiusSides = UICornerRadiusSides.None;
|
||||
b13.Size = new Size(29, 29);
|
||||
b13.Symbol = 0;
|
||||
b13.TabIndex = 13;
|
||||
b13.Text = "0";
|
||||
//
|
||||
// b12
|
||||
//
|
||||
b12.Cursor = Cursors.Hand;
|
||||
b12.Font = new Font("微软雅黑", 12F);
|
||||
b12.Location = new Point(385, 3);
|
||||
b12.Name = "b12";
|
||||
b12.RadiusSides = UICornerRadiusSides.None;
|
||||
b12.Size = new Size(29, 29);
|
||||
b12.Symbol = 0;
|
||||
b12.TabIndex = 12;
|
||||
b12.Text = "0";
|
||||
//
|
||||
// b11
|
||||
//
|
||||
b11.Cursor = Cursors.Hand;
|
||||
b11.Font = new Font("微软雅黑", 12F);
|
||||
b11.Location = new Point(357, 3);
|
||||
b11.Name = "b11";
|
||||
b11.RadiusSides = UICornerRadiusSides.None;
|
||||
b11.Size = new Size(29, 29);
|
||||
b11.Symbol = 0;
|
||||
b11.TabIndex = 11;
|
||||
b11.Text = "0";
|
||||
//
|
||||
// b10
|
||||
//
|
||||
b10.Cursor = Cursors.Hand;
|
||||
b10.Font = new Font("微软雅黑", 12F);
|
||||
b10.Location = new Point(329, 3);
|
||||
b10.Name = "b10";
|
||||
b10.RadiusSides = UICornerRadiusSides.None;
|
||||
b10.Size = new Size(29, 29);
|
||||
b10.Symbol = 0;
|
||||
b10.TabIndex = 10;
|
||||
b10.Text = "0";
|
||||
//
|
||||
// b9
|
||||
//
|
||||
b9.Cursor = Cursors.Hand;
|
||||
b9.Font = new Font("微软雅黑", 12F);
|
||||
b9.Location = new Point(301, 3);
|
||||
b9.Name = "b9";
|
||||
b9.RadiusSides = UICornerRadiusSides.None;
|
||||
b9.Size = new Size(29, 29);
|
||||
b9.Symbol = 0;
|
||||
b9.TabIndex = 9;
|
||||
b9.Text = "0";
|
||||
//
|
||||
// b8
|
||||
//
|
||||
b8.Cursor = Cursors.Hand;
|
||||
b8.Font = new Font("微软雅黑", 12F);
|
||||
b8.Location = new Point(273, 3);
|
||||
b8.Name = "b8";
|
||||
b8.RadiusSides = UICornerRadiusSides.None;
|
||||
b8.Size = new Size(29, 29);
|
||||
b8.Symbol = 0;
|
||||
b8.TabIndex = 8;
|
||||
b8.Text = "0";
|
||||
//
|
||||
// b16
|
||||
//
|
||||
b16.Cursor = Cursors.Hand;
|
||||
b16.Font = new Font("微软雅黑", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
b16.ImageAlign = ContentAlignment.MiddleRight;
|
||||
b16.Location = new Point(497, 3);
|
||||
b16.Name = "b16";
|
||||
b16.Padding = new Padding(5, 0, 5, 0);
|
||||
b16.RadiusSides = UICornerRadiusSides.RightTop | UICornerRadiusSides.RightBottom;
|
||||
b16.Size = new Size(75, 29);
|
||||
b16.Symbol = 61701;
|
||||
b16.TabIndex = 16;
|
||||
b16.Tag = "1";
|
||||
b16.TagString = ">";
|
||||
b16.Text = "下一页";
|
||||
b16.TextAlign = ContentAlignment.MiddleLeft;
|
||||
b16.LocationChanged += b16_LocationChanged;
|
||||
//
|
||||
// p1
|
||||
//
|
||||
p1.Controls.Add(btnSelect);
|
||||
p1.Controls.Add(uiLabel2);
|
||||
p1.Controls.Add(edtPage);
|
||||
p1.Controls.Add(uiLabel1);
|
||||
p1.Font = new Font("微软雅黑", 12F);
|
||||
p1.Location = new Point(579, 3);
|
||||
p1.Margin = new Padding(4, 5, 4, 5);
|
||||
p1.Name = "p1";
|
||||
p1.RectSides = ToolStripStatusLabelBorderSides.None;
|
||||
p1.Size = new Size(191, 29);
|
||||
p1.TabIndex = 17;
|
||||
p1.Text = null;
|
||||
p1.LocationChanged += p1_LocationChanged;
|
||||
//
|
||||
// btnSelect
|
||||
//
|
||||
btnSelect.Cursor = Cursors.Hand;
|
||||
btnSelect.Font = new Font("微软雅黑", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnSelect.Location = new Point(127, 0);
|
||||
btnSelect.Name = "btnSelect";
|
||||
btnSelect.Size = new Size(61, 29);
|
||||
btnSelect.Symbol = 0;
|
||||
btnSelect.TabIndex = 3;
|
||||
btnSelect.Text = "确定";
|
||||
btnSelect.Click += btnSelect_Click;
|
||||
//
|
||||
// uiLabel2
|
||||
//
|
||||
uiLabel2.AutoSize = true;
|
||||
uiLabel2.BackColor = Color.Transparent;
|
||||
uiLabel2.Font = new Font("微软雅黑", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
uiLabel2.Location = new Point(100, 4);
|
||||
uiLabel2.Name = "uiLabel2";
|
||||
uiLabel2.Size = new Size(23, 20);
|
||||
uiLabel2.TabIndex = 2;
|
||||
uiLabel2.Text = "页";
|
||||
uiLabel2.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// edtPage
|
||||
//
|
||||
edtPage.Cursor = Cursors.IBeam;
|
||||
edtPage.DoubleValue = 10D;
|
||||
edtPage.FillColor = Color.White;
|
||||
edtPage.Font = new Font("微软雅黑", 12F);
|
||||
edtPage.HasMinimum = true;
|
||||
edtPage.IntValue = 10;
|
||||
edtPage.Location = new Point(43, 0);
|
||||
edtPage.Margin = new Padding(4, 5, 4, 5);
|
||||
edtPage.Maximum = 2147483647D;
|
||||
edtPage.Minimum = 1D;
|
||||
edtPage.Name = "edtPage";
|
||||
edtPage.Padding = new Padding(5);
|
||||
edtPage.Size = new Size(53, 29);
|
||||
edtPage.TabIndex = 1;
|
||||
edtPage.Text = "10";
|
||||
edtPage.TextAlignment = ContentAlignment.BottomCenter;
|
||||
edtPage.Type = UITextBox.UIEditType.Integer;
|
||||
//
|
||||
// uiLabel1
|
||||
//
|
||||
uiLabel1.AutoSize = true;
|
||||
uiLabel1.BackColor = Color.Transparent;
|
||||
uiLabel1.Font = new Font("微软雅黑", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
uiLabel1.Location = new Point(3, 4);
|
||||
uiLabel1.Name = "uiLabel1";
|
||||
uiLabel1.Size = new Size(37, 20);
|
||||
uiLabel1.TabIndex = 0;
|
||||
uiLabel1.Text = "到第";
|
||||
uiLabel1.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// cb1
|
||||
//
|
||||
cb1.DropDownStyle = UIDropDownStyle.DropDownList;
|
||||
cb1.FillColor = Color.White;
|
||||
cb1.Font = new Font("微软雅黑", 12F);
|
||||
cb1.Items.AddRange(new object[]
|
||||
{
|
||||
"20条/页",
|
||||
"50条/页",
|
||||
"100条/页",
|
||||
"200条/页"
|
||||
});
|
||||
cb1.Location = new Point(906, 3);
|
||||
cb1.Margin = new Padding(4, 5, 4, 5);
|
||||
cb1.MinimumSize = new Size(63, 0);
|
||||
cb1.Name = "cb1";
|
||||
cb1.Padding = new Padding(0, 0, 30, 0);
|
||||
cb1.Size = new Size(103, 29);
|
||||
cb1.TabIndex = 19;
|
||||
cb1.TextAlignment = ContentAlignment.MiddleLeft;
|
||||
cb1.Visible = false;
|
||||
//
|
||||
// UIPagination
|
||||
//
|
||||
Controls.Add(cb1);
|
||||
Controls.Add(p1);
|
||||
Controls.Add(b16);
|
||||
Controls.Add(b15);
|
||||
Controls.Add(b14);
|
||||
Controls.Add(b13);
|
||||
Controls.Add(b12);
|
||||
Controls.Add(b11);
|
||||
Controls.Add(b10);
|
||||
Controls.Add(b9);
|
||||
Controls.Add(b8);
|
||||
Controls.Add(b7);
|
||||
Controls.Add(b6);
|
||||
Controls.Add(b5);
|
||||
Controls.Add(b4);
|
||||
Controls.Add(b3);
|
||||
Controls.Add(b2);
|
||||
Controls.Add(b1);
|
||||
Controls.Add(b0);
|
||||
Name = "UIPagination";
|
||||
RectSides = ToolStripStatusLabelBorderSides.None;
|
||||
Size = new Size(1100, 35);
|
||||
p1.ResumeLayout(false);
|
||||
p1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion InitializeComponent
|
||||
|
||||
private void SetShowButton(int buttonIdx, int pageIdx, int activeIdx)
|
||||
{
|
||||
buttons[buttonIdx].Symbol = 0;
|
||||
buttons[buttonIdx].Text = pageIdx.ToString();
|
||||
buttons[buttonIdx].Tag = pageIdx;
|
||||
buttons[buttonIdx].Visible = true;
|
||||
buttons[buttonIdx].TagString = "";
|
||||
buttons[buttonIdx].Selected = activeIdx == pageIdx;
|
||||
if (buttons[buttonIdx].Selected) buttons[buttonIdx].BringToFront();
|
||||
}
|
||||
|
||||
private void SetShowButton(int buttonIdx, int addCount, string tagString)
|
||||
{
|
||||
buttons[buttonIdx].Symbol = 0;
|
||||
buttons[buttonIdx].Text = @"···";
|
||||
buttons[buttonIdx].Tag = addCount;
|
||||
buttons[buttonIdx].Visible = true;
|
||||
buttons[buttonIdx].TagString = tagString;
|
||||
buttons[buttonIdx].Selected = false;
|
||||
}
|
||||
|
||||
private void SetHideButton(int beginIdx)
|
||||
{
|
||||
for (var i = beginIdx; i < 16; i++) buttons[i].Visible = false;
|
||||
}
|
||||
|
||||
private void SetShowButtons()
|
||||
{
|
||||
b0.Visible = true;
|
||||
b16.Visible = true;
|
||||
|
||||
PageCount = TotalCount.Mod(PageSize) == 0 ? TotalCount / PageSize : TotalCount / PageSize + 1;
|
||||
edtPage.HasMaximum = true;
|
||||
edtPage.Maximum = PageCount;
|
||||
|
||||
if (activePage > PageCount) activePage = PageCount;
|
||||
if (activePage < 1) activePage = 1;
|
||||
edtPage.IntValue = activePage;
|
||||
|
||||
if (TotalCount == 0)
|
||||
{
|
||||
PageCount = 1;
|
||||
activePage = 1;
|
||||
SetShowButton(1, 1, 1);
|
||||
SetHideButton(2);
|
||||
b16.Left = b1.Right - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PageCount <= PagerCount + 2)
|
||||
{
|
||||
for (var i = 1; i <= PageCount; i++) SetShowButton(i, i, activePage);
|
||||
|
||||
b16.Left = buttons[PageCount].Right - 1;
|
||||
SetHideButton(PageCount + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//左
|
||||
var leftShow = PagerCount / 2 + 1 + 2;
|
||||
if (activePage <= leftShow)
|
||||
{
|
||||
for (var i = 1; i <= leftShow; i++) SetShowButton(i, i, activePage);
|
||||
|
||||
SetShowButton(leftShow + 1, PagerCount - 2, ">>");
|
||||
SetShowButton(leftShow + 2, PageCount, activePage);
|
||||
SetHideButton(leftShow + 3);
|
||||
b16.Left = buttons[leftShow + 2].Right - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
//右
|
||||
var rightShow = PageCount - (PagerCount / 2 + 1) - 1;
|
||||
if (activePage >= rightShow)
|
||||
{
|
||||
SetShowButton(1, 1, activePage);
|
||||
SetShowButton(2, 2 - PagerCount, "<<");
|
||||
|
||||
var idx = 3;
|
||||
for (var i = rightShow; i <= PageCount; i++)
|
||||
{
|
||||
SetShowButton(idx, i, activePage);
|
||||
idx++;
|
||||
}
|
||||
|
||||
b16.Left = buttons[idx - 1].Right - 1;
|
||||
SetHideButton(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
//中
|
||||
SetShowButton(1, 1, activePage);
|
||||
SetShowButton(2, 2 - PagerCount, "<<");
|
||||
var cIdx = 3;
|
||||
var sIdx = (PagerCount - 2) / 2;
|
||||
for (var i = cIdx; i <= PagerCount; i++)
|
||||
{
|
||||
SetShowButton(cIdx, activePage - sIdx + (i - 3), activePage);
|
||||
cIdx++;
|
||||
}
|
||||
|
||||
SetShowButton(cIdx, PagerCount - 2, ">>");
|
||||
SetShowButton(cIdx + 1, PageCount, activePage);
|
||||
b16.Left = buttons[cIdx + 1].Right - 1;
|
||||
SetHideButton(cIdx + 2);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
|
||||
foreach (var button in buttons.Values)
|
||||
{
|
||||
button.FillColor = uiColor.PlainColor;
|
||||
button.ForeColor = uiColor.RectColor;
|
||||
button.FillSelectedColor = uiColor.ButtonFillColor;
|
||||
}
|
||||
|
||||
btnSelect.FillColor = uiColor.PlainColor;
|
||||
btnSelect.ForeColor = uiColor.RectColor;
|
||||
btnSelect.FillSelectedColor = uiColor.ButtonFillColor;
|
||||
}
|
||||
|
||||
private void b16_LocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
p1.Left = b16.Right + 3;
|
||||
}
|
||||
|
||||
private void btnSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
ActivePage = edtPage.IntValue;
|
||||
}
|
||||
|
||||
private void SetDataConnection(object newDataSource, BindingMemberInfo newDisplayMember)
|
||||
{
|
||||
var dataSourceChanged = dataSource != newDataSource;
|
||||
|
||||
if (inSetDataConnection) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (dataSourceChanged)
|
||||
{
|
||||
inSetDataConnection = true;
|
||||
CurrencyManager newDataManager = null;
|
||||
if (newDataSource != null && newDataSource != Convert.DBNull)
|
||||
newDataManager = (CurrencyManager)BindingContext[newDataSource, newDisplayMember.BindingPath];
|
||||
|
||||
dataManager = newDataManager;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
inSetDataConnection = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DataBind()
|
||||
{
|
||||
if (dataSource == null)
|
||||
{
|
||||
PageChanged?.Invoke(this, dataSource, 1, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
var objects = new List<object>();
|
||||
var iBegin = PageSize * (ActivePage - 1);
|
||||
for (var i = iBegin; i < iBegin + PageSize; i++)
|
||||
if (i < TotalCount)
|
||||
objects.Add(dataManager.List[i]);
|
||||
|
||||
PageDataSource = objects;
|
||||
PageChanged?.Invoke(this, objects, activePage, objects.Count);
|
||||
}
|
||||
|
||||
public event OnPageChangeEventHandler PageChanged;
|
||||
|
||||
private void p1_LocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
cb1.Left = p1.Right;
|
||||
}
|
||||
}
|
||||
}
|
@ -117,6 +117,9 @@
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\UINavMenuHelper.cs" />
|
||||
<Compile Include="Controls\UIPagination.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\UIRichTextBox.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
@ -399,9 +402,6 @@
|
||||
<Compile Include="Controls\UIToolTip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\UIDataGridPage.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Units\USnowflakeID.cs" />
|
||||
<Compile Include="Units\UThunder.cs" />
|
||||
<Compile Include="Controls\UILine.cs">
|
||||
|
Loading…
x
Reference in New Issue
Block a user