Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit fe97d256
由
HZH
编写于
2019-08-15 14:54:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加分页控件2
1 个父辈
c49b6bac
全部展开
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
396 行增加
和
5 行删除
HZH_Controls/HZH_Controls/Controls/List/IPageControl.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.Designer.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.resx
HZH_Controls/HZH_Controls/Controls/List/UCPagerControlBase.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/Test/Form1.Designer.cs
HZH_Controls/Test/Form1.cs
HZH_Controls/HZH_Controls/Controls/List/IPageControl.cs
查看文件 @
fe97d25
...
...
@@ -48,5 +48,8 @@ namespace HZH_Controls.Controls
/// </summary>
/// <returns></returns>
List
<
object
>
GetCurrentSource
();
int
PageCount
{
get
;
set
;
}
int
PageIndex
{
get
;
set
;
}
}
}
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.Designer.cs
0 → 100644
查看文件 @
fe97d25
此文件的差异被折叠,
点击展开。
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.cs
0 → 100644
查看文件 @
fe97d25
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.List
{
[
ToolboxItem
(
true
)]
public
partial
class
UCPagerControl2
:
UCPagerControlBase
{
public
UCPagerControl2
()
{
InitializeComponent
();
txtPage
.
txtInput
.
KeyDown
+=
txtInput_KeyDown
;
}
void
txtInput_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
btnToPage_BtnClick
(
null
,
null
);
txtPage
.
InputText
=
""
;
}
}
public
override
event
PageControlEventHandler
ShowSourceChanged
;
private
List
<
object
>
m_dataSource
;
public
override
List
<
object
>
DataSource
{
get
{
return
m_dataSource
;
}
set
{
m_dataSource
=
value
;
if
(
m_dataSource
==
null
)
m_dataSource
=
new
List
<
object
>();
ResetPageCount
();
}
}
private
int
m_intPageSize
=
0
;
public
override
int
PageSize
{
get
{
return
m_intPageSize
;
}
set
{
m_intPageSize
=
value
;
ResetPageCount
();
}
}
public
override
void
FirstPage
()
{
PageIndex
=
1
;
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
public
override
void
PreviousPage
()
{
PageIndex
--;
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
public
override
void
NextPage
()
{
PageIndex
++;
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
public
override
void
EndPage
()
{
PageIndex
=
PageCount
;
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
private
void
ResetPageCount
()
{
if
(
PageSize
>
0
)
{
PageCount
=
m_dataSource
.
Count
/
m_intPageSize
+
(
m_dataSource
.
Count
%
m_intPageSize
>
0
?
1
:
0
);
}
txtPage
.
MaxValue
=
PageCount
;
txtPage
.
MinValue
=
1
;
ReloadPage
();
}
private
void
ReloadPage
()
{
try
{
ControlHelper
.
FreezeControl
(
tableLayoutPanel1
,
true
);
List
<
int
>
lst
=
new
List
<
int
>();
if
(
PageCount
>
0
)
{
if
(
PageCount
<=
7
)
{
for
(
int
i
=
0
;
i
<
PageCount
;
i
++)
{
lst
.
Add
(
i
+
1
);
}
}
else
{
int
start
=
PageIndex
;
//开始按钮数字
int
end
=
1
;
//结束按钮数字
int
pageCount
=
PageCount
;
//总页数
int
offset
=
3
;
//偏移量
start
-=
offset
;
//计算左偏移量
start
=
start
<
1
?
1
:
start
;
//限定最小页码
end
=
start
+
7
-
1
;
//根据偏移计算结束按钮
end
=
end
>
pageCount
?
pageCount
:
end
;
//限定最大页码
start
=
end
-
7
+
1
;
//根据偏移计算开始页码
start
=
start
<
1
?
1
:
start
;
//限定最小页码
for
(
int
i
=
start
;
i
<=
end
;
i
++)
{
lst
.
Add
(
i
);
}
}
}
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
UCBtnExt
c
=
(
UCBtnExt
)
this
.
tableLayoutPanel1
.
Controls
.
Find
(
"p"
+
(
i
+
1
),
false
)[
0
];
if
(
i
>=
lst
.
Count
)
{
c
.
Visible
=
false
;
}
else
{
c
.
BtnText
=
lst
[
i
].
ToString
();
c
.
Visible
=
true
;
if
(
lst
[
i
]
==
PageIndex
)
{
c
.
RectColor
=
Color
.
FromArgb
(
255
,
77
,
59
);
}
else
{
c
.
RectColor
=
Color
.
FromArgb
(
223
,
223
,
223
);
}
}
}
}
finally
{
ControlHelper
.
FreezeControl
(
tableLayoutPanel1
,
false
);
}
}
private
void
page_BtnClick
(
object
sender
,
EventArgs
e
)
{
PageIndex
=
(
sender
as
UCBtnExt
).
BtnText
.
ToInt
();
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
protected
override
void
ShowBtn
(
bool
blnLeftBtn
,
bool
blnRightBtn
)
{
btnFirst
.
Enabled
=
btnPrevious
.
Enabled
=
blnLeftBtn
;
btnNext
.
Enabled
=
btnEnd
.
Enabled
=
blnRightBtn
;
}
private
void
btnFirst_BtnClick
(
object
sender
,
EventArgs
e
)
{
FirstPage
();
}
private
void
btnPrevious_BtnClick
(
object
sender
,
EventArgs
e
)
{
PreviousPage
();
}
private
void
btnNext_BtnClick
(
object
sender
,
EventArgs
e
)
{
NextPage
();
}
private
void
btnEnd_BtnClick
(
object
sender
,
EventArgs
e
)
{
EndPage
();
}
private
void
btnToPage_BtnClick
(
object
sender
,
EventArgs
e
)
{
if
(!
string
.
IsNullOrEmpty
(
txtPage
.
InputText
))
{
PageIndex
=
txtPage
.
InputText
.
ToInt
();
StartIndex
=
(
PageIndex
-
1
)
*
PageSize
;
ReloadPage
();
var
s
=
GetCurrentSource
();
if
(
ShowSourceChanged
!=
null
)
{
ShowSourceChanged
(
s
);
}
}
}
}
}
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl2.resx
0 → 100644
查看文件 @
fe97d25
<?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
HZH_Controls/HZH_Controls/Controls/List/UCPagerControlBase.cs
查看文件 @
fe97d25
...
...
@@ -53,12 +53,28 @@ namespace HZH_Controls.Controls
#
endregion
#
endregion
/// <summary>
/// 总页数
/// </summary>
public
virtual
int
PageCount
{
get
;
set
;
}
private
int
m_pageIndex
=
1
;
/// <summary>
/// 当前页码
/// </summary>
public
virtual
int
PageIndex
{
get
{
return
m_pageIndex
;
}
set
{
m_pageIndex
=
value
;
}
}
/// <summary>
/// 关联的数据源
/// </summary>
public
virtual
List
<
object
>
DataSource
{
get
;
set
;
}
public
event
PageControlEventHandler
ShowSourceChanged
;
public
virtual
event
PageControlEventHandler
ShowSourceChanged
;
private
int
m_pageSize
=
1
;
/// <summary>
/// 每页显示数量
...
...
@@ -85,7 +101,6 @@ namespace HZH_Controls.Controls
}
}
public
UCPagerControlBase
()
{
InitializeComponent
();
...
...
@@ -230,7 +245,5 @@ namespace HZH_Controls.Controls
/// <param name="blnRightBtn">是否显示下一页,最后一页</param>
protected
virtual
void
ShowBtn
(
bool
blnLeftBtn
,
bool
blnRightBtn
)
{
}
}
}
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
fe97d25
...
...
@@ -66,6 +66,12 @@
<Compile Include="Controls\List\UCPagerControl.Designer.cs">
<DependentUpon>UCPagerControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\List\UCPagerControl2.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\List\UCPagerControl2.Designer.cs">
<DependentUpon>UCPagerControl2.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Menu\IMenuItem.cs" />
<Compile Include="Controls\Menu\MenuItemEntity.cs" />
<Compile Include="Controls\Menu\UCMenu.cs">
...
...
@@ -369,6 +375,9 @@
<EmbeddedResource Include="Controls\List\UCPagerControl.resx">
<DependentUpon>UCPagerControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControl2.resx">
<DependentUpon>UCPagerControl2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControlBase.resx">
<DependentUpon>UCPagerControlBase.cs</DependentUpon>
</EmbeddedResource>
...
...
HZH_Controls/Test/Form1.Designer.cs
查看文件 @
fe97d25
此文件的差异被折叠,
点击展开。
HZH_Controls/Test/Form1.cs
查看文件 @
fe97d25
...
...
@@ -89,6 +89,15 @@ namespace Test
}
this
.
ucMenu1
.
MenuStyle
=
MenuStyle
.
Top
;
this
.
ucMenu1
.
DataSource
=
lstMenu
;
List
<
object
>
lstPage2
=
new
List
<
object
>();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
lstPage2
.
Add
(
i
);
}
ucPagerControl21
.
PageSize
=
10
;
ucPagerControl21
.
DataSource
=
lstPage2
;
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论