Commit 3622c191 HZH

新增DataGridView,分页控件

1 个父辈 ee050c1b
正在显示 147 个修改的文件 包含 687 行增加129 行删除
namespace HZH_Controls.Controls
{
partial class UCDataGridViewRow
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panCells = new System.Windows.Forms.TableLayoutPanel();
this.SuspendLayout();
//
// ucSplitLine_H1
//
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 55);
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
this.ucSplitLine_H1.Size = new System.Drawing.Size(661, 1);
this.ucSplitLine_H1.TabIndex = 0;
this.ucSplitLine_H1.TabStop = false;
//
// panCells
//
this.panCells.ColumnCount = 1;
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.panCells.Dock = System.Windows.Forms.DockStyle.Fill;
this.panCells.Location = new System.Drawing.Point(0, 0);
this.panCells.Name = "panCells";
this.panCells.RowCount = 1;
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.panCells.Size = new System.Drawing.Size(661, 55);
this.panCells.TabIndex = 1;
//
// UCDataGridViewItem
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.panCells);
this.Controls.Add(this.ucSplitLine_H1);
this.Name = "UCDataGridViewItem";
this.Size = new System.Drawing.Size(661, 56);
this.ResumeLayout(false);
}
#endregion
private UCSplitLine_H ucSplitLine_H1;
private System.Windows.Forms.TableLayoutPanel panCells;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
public partial class UCDataGridViewRow : UserControl, IDataGridViewRow
{
#region 属性
public event DataGridViewCellEventHandler CheckBoxChangeEvent;
public event DataGridViewCellEventHandler CellClick;
public event DataGridViewCellEventHandler SourceChanged;
public List<DataGridViewColumnEntity> Columns
{
get;
set;
}
public object DataSource
{
get;
set;
}
public bool IsShowCheckBox
{
get;
set;
}
private bool m_isChecked;
public bool IsChecked
{
get
{
return m_isChecked;
}
set
{
if (m_isChecked != value)
{
m_isChecked = value;
(this.panCells.Controls.Find("check", false)[0] as UCCheckBox).Checked = value;
}
}
}
#endregion
public UCDataGridViewRow()
{
InitializeComponent();
}
public void BindingCellData()
{
for (int i = 0; i < Columns.Count; i++)
{
DataGridViewColumnEntity com = Columns[i];
var cs = this.panCells.Controls.Find("lbl_" + com.DataField, false);
if (cs != null && cs.Length > 0)
{
var pro = DataSource.GetType().GetProperty(com.DataField);
if (pro != null)
cs[0].Text = pro.GetValue(DataSource, null).ToStringExt();
}
}
}
void Item_MouseDown(object sender, MouseEventArgs e)
{
if (CellClick != null)
{
CellClick(sender, new DataGridViewCellEventArgs()
{
CellControl = this,
CellIndex = (sender as Control).Tag.ToInt()
});
}
}
public void SetSelect(bool blnSelected)
{
if (blnSelected)
{
this.BackColor = Color.FromArgb(255, 247, 245);
}
else
{
this.BackColor = Color.Transparent;
}
}
public void ReloadCells()
{
try
{
ControlHelper.FreezeControl(this, true);
this.panCells.Controls.Clear();
this.panCells.ColumnStyles.Clear();
int intColumnsCount = Columns.Count();
if (Columns != null && intColumnsCount > 0)
{
if (IsShowCheckBox)
{
intColumnsCount++;
}
this.panCells.ColumnCount = intColumnsCount;
for (int i = 0; i < intColumnsCount; i++)
{
Control c = null;
if (i == 0 && IsShowCheckBox)
{
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.Absolute, 30F));
UCCheckBox box = new UCCheckBox();
box.Name = "check";
box.TextValue = "";
box.Size = new Size(30, 30);
box.Dock = DockStyle.Fill;
box.CheckedChangeEvent += (a, b) =>
{
IsChecked = box.Checked;
if (CheckBoxChangeEvent != null)
{
CheckBoxChangeEvent(a, new DataGridViewCellEventArgs()
{
CellControl = box,
CellIndex = 0
});
}
};
c = box;
}
else
{
var item = Columns[i - (IsShowCheckBox ? 1 : 0)];
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
Label lbl = new Label();
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
lbl.Name = "lbl_" + item.DataField;
lbl.Font = new Font("微软雅黑", 12);
lbl.ForeColor = Color.Black;
lbl.AutoSize = false;
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.MouseDown += (a, b) =>
{
Item_MouseDown(a, b);
};
c = lbl;
}
this.panCells.Controls.Add(c, i, 0);
}
}
}
finally
{
ControlHelper.FreezeControl(this, false);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Controls
{
public interface IPageControl
{
/// <summary>
/// 数据源改变时发生
/// </summary>
event PageControlEventHandler ShowChanged;
/// <summary>
/// 数据源
/// </summary>
List<object> DataSource { get; set; }
/// <summary>
/// 显示数量
/// </summary>
int PageSize { get; set; }
/// <summary>
/// 开始下标
/// </summary>
int StartIndex { get; set; }
/// <summary>
/// 第一页
/// </summary>
void FirstPage();
/// <summary>
/// 前一页
/// </summary>
void PreviousPage();
/// <summary>
/// 下一页
/// </summary>
void NextPage();
/// <summary>
/// 最后一页
/// </summary>
void EndPage();
/// <summary>
/// 重新加载
/// </summary>
void Reload();
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns></returns>
List<object> GetCurrentSource();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace HZH_Controls.Controls
{
[Serializable]
[ComVisible(true)]
public delegate void PageControlEventHandler(object currentSource);
}
namespace HZH_Controls.Controls
namespace HZH_Controls.Controls.List
{
partial class UCPagerControl
{
......@@ -29,6 +29,8 @@
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1.SuspendLayout();
......@@ -36,27 +38,53 @@
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.panel2, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.Controls.Add(this.panel4, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(304, 58);
this.tableLayoutPanel1.TabIndex = 0;
this.tableLayoutPanel1.TabIndex = 1;
//
// panel4
//
this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end;
this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel4.Location = new System.Drawing.Point(228, 6);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(68, 46);
this.panel4.TabIndex = 3;
this.panel4.Visible = false;
this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown);
//
// panel3
//
this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first;
this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel3.Location = new System.Drawing.Point(6, 6);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(68, 46);
this.panel3.TabIndex = 2;
this.panel3.Visible = false;
this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown);
//
// panel2
//
this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.rigth;
this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel2.Location = new System.Drawing.Point(155, 6);
this.panel2.Location = new System.Drawing.Point(154, 6);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(143, 46);
this.panel2.Size = new System.Drawing.Size(68, 46);
this.panel2.TabIndex = 1;
this.panel2.Visible = false;
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown);
......@@ -65,20 +93,18 @@
//
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Location = new System.Drawing.Point(6, 6);
this.panel1.Location = new System.Drawing.Point(80, 6);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(143, 46);
this.panel1.Size = new System.Drawing.Size(68, 46);
this.panel1.TabIndex = 0;
this.panel1.Visible = false;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// UCPagerControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "UCPagerControl";
this.Size = new System.Drawing.Size(304, 58);
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
......@@ -87,7 +113,9 @@
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel1;
}
}
......@@ -7,140 +7,39 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
namespace HZH_Controls.Controls.List
{
public partial class UCPagerControl : UserControl
public partial class UCPagerControl : UCPagerControlBase
{
public delegate void PageClickEvent(List<object> currentSource);
/// <summary>
/// 关联的数据源
/// </summary>
public List<object> Source { get; set; }
public event PageClickEvent LeftClick;
public event PageClickEvent RightClick;
public event PageClickEvent ShowChanged;
private int showCount = 1;
/// <summary>
/// 每页显示数量
/// </summary>
public int ShowCount
{
get { return showCount; }
set { showCount = value; }
}
private int startIndex = 0;
/// <summary>
/// 开始的下标
/// </summary>
public int StartIndex
{
get { return startIndex; }
set
{
startIndex = value;
if (startIndex <= 0)
startIndex = 0;
}
}
public UCPagerControl()
{
InitializeComponent();
}
public void NextPage()
{
if (startIndex + showCount >= Source.Count)
{
return;
}
startIndex += showCount;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSoutce();
if (RightClick != null)
{
RightClick(s);
}
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public void LastPage()
{
if (startIndex == 0)
return;
startIndex -= showCount;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSoutce();
if (LeftClick != null)
{
LeftClick(s);
}
if (ShowChanged != null)
{
ShowChanged(s);
}
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
LastPage();
PreviousPage();
}
private void panel2_MouseDown(object sender, MouseEventArgs e)
{
NextPage();
}
public void Reload()
{
var s = GetCurrentSoutce();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public List<object> GetCurrentSoutce()
{
int intShowCount = showCount;
if (intShowCount + startIndex > Source.Count)
intShowCount = Source.Count - startIndex;
object[] objs = new object[intShowCount];
Source.CopyTo(startIndex, objs, 0, intShowCount);
var lst = objs.ToList();
if (lst.Count > 0)
{
if (Source.IndexOf(lst[0]) > 0)
{
panel1.Visible = true;
}
else
private void panel3_MouseDown(object sender, MouseEventArgs e)
{
panel1.Visible = false;
FirstPage();
}
if (Source.IndexOf(lst[lst.Count - 1]) >= Source.Count - 1)
{
panel2.Visible = false;
}
else
{
panel2.Visible = true;
}
}
else
private void panel4_MouseDown(object sender, MouseEventArgs e)
{
panel1.Visible = false;
panel2.Visible = false;
EndPage();
}
return lst;
protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
{
panel1.Visible = panel3.Visible = blnLeftBtn;
panel2.Visible = panel4.Visible = blnRightBtn;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
public class UCPagerControlBase : UserControl, IPageControl
{
#region 构造
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "UCPagerControlBase";
this.Size = new System.Drawing.Size(304, 58);
this.ResumeLayout(false);
}
#endregion
#endregion
/// <summary>
/// 关联的数据源
/// </summary>
public List<object> DataSource { get; set; }
public event PageControlEventHandler ShowChanged;
private int m_pageSize = 1;
/// <summary>
/// 每页显示数量
/// </summary>
public int PageSize
{
get { return m_pageSize; }
set { m_pageSize = value; }
}
private int startIndex = 0;
/// <summary>
/// 开始的下标
/// </summary>
public int StartIndex
{
get { return startIndex; }
set
{
startIndex = value;
if (startIndex <= 0)
startIndex = 0;
}
}
public UCPagerControlBase()
{
InitializeComponent();
}
public void FirstPage()
{
startIndex = 0;
var s = GetCurrentSource();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public void PreviousPage()
{
if (startIndex == 0)
return;
startIndex -= m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public void NextPage()
{
if (startIndex + m_pageSize >= DataSource.Count)
{
return;
}
startIndex += m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public void EndPage()
{
startIndex = DataSource.Count - 1 - m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public void Reload()
{
var s = GetCurrentSource();
if (ShowChanged != null)
{
ShowChanged(s);
}
}
public List<object> GetCurrentSource()
{
int intShowCount = m_pageSize;
if (intShowCount + startIndex > DataSource.Count)
intShowCount = DataSource.Count - startIndex;
object[] objs = new object[intShowCount];
DataSource.CopyTo(startIndex, objs, 0, intShowCount);
var lst = objs.ToList();
bool blnLeft = false;
bool blnRight = false;
if (lst.Count > 0)
{
if (DataSource.IndexOf(lst[0]) > 0)
{
blnLeft = true;
}
else
{
blnLeft = false;
}
if (DataSource.IndexOf(lst[lst.Count - 1]) >= DataSource.Count - 1)
{
blnRight = false;
}
else
{
blnRight = true;
}
}
ShowBtn(blnLeft, blnRight);
return lst;
}
/// <summary>
/// 控制按钮显示
/// </summary>
/// <param name="blnLeftBtn"></param>
/// <param name="blnRightBtn"></param>
protected virtual void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
{ }
}
}

1.1 KB | 宽: | 高:

582 字节 | 宽: | 高:

HZH_Controls/HZH_Controls/Resources/left.png
HZH_Controls/HZH_Controls/Resources/left.png
HZH_Controls/HZH_Controls/Resources/left.png
HZH_Controls/HZH_Controls/Resources/left.png
  • 两方对比
  • 交换覆盖
  • 透明覆盖
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!