Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 0cd8f1e1
由
HZH
编写于
2019-08-20 11:51:42 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加进度条
1 个父辈
a1c89bd1
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
314 行增加
和
6 行删除
HZH_Controls/HZH_Controls/Controls/Btn/UCBtnExt.cs
HZH_Controls/HZH_Controls/Controls/Process/UCProcessLine.cs
HZH_Controls/HZH_Controls/Controls/UCControlBase.cs
HZH_Controls/HZH_Controls/Forms/FrmTransparent.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/HZH_Controls/Helpers/ControlHelper.cs
HZH_Controls/HZH_Controls/Helpers/ITheme.cs
HZH_Controls/Test/Form2.Designer.cs
HZH_Controls/Test/Form2.cs
HZH_Controls/HZH_Controls/Controls/Btn/UCBtnExt.cs
查看文件 @
0cd8f1e
...
...
@@ -119,5 +119,14 @@ namespace HZH_Controls.Controls
if
(
this
.
BtnClick
!=
null
)
BtnClick
(
this
,
e
);
}
public
override
void
ResetTheme
(
ThemeEntity
theme
)
{
if
(
theme
.
BackColor
.
HasValue
&&
theme
.
BackColor
.
Value
!=
Color
.
Empty
)
{
BtnBackColor
=
theme
.
BackColor
.
Value
;
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Process/UCProcessLine.cs
0 → 100644
查看文件 @
0cd8f1e
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
;
using
System.Drawing.Drawing2D
;
namespace
HZH_Controls.Controls
{
public
class
UCProcessLine
:
Control
{
int
m_value
=
0
;
[
Description
(
"当前属性"
),
Category
(
"自定义"
)]
public
int
Value
{
set
{
if
(
value
>
m_maxValue
)
m_value
=
m_maxValue
;
else
if
(
value
<
0
)
m_value
=
0
;
else
m_value
=
value
;
Refresh
();
}
get
{
return
m_value
;
}
}
private
int
m_maxValue
=
100
;
[
Description
(
"最大值"
),
Category
(
"自定义"
)]
public
int
MaxValue
{
get
{
return
m_maxValue
;
}
set
{
if
(
value
<
m_value
)
m_maxValue
=
m_value
;
else
m_maxValue
=
value
;
Refresh
();
}
}
Color
m_valueColor
=
Color
.
FromArgb
(
73
,
119
,
232
);
[
Description
(
"值进度条颜色"
),
Category
(
"自定义"
)]
public
Color
ValueColor
{
get
{
return
m_valueColor
;
}
set
{
m_valueColor
=
value
;
Refresh
();
}
}
private
Color
m_valueBGColor
=
Color
.
White
;
[
Description
(
"值背景色"
),
Category
(
"自定义"
)]
public
Color
ValueBGColor
{
get
{
return
m_valueBGColor
;
}
set
{
m_valueBGColor
=
value
;
Refresh
();
}
}
private
Color
m_borderColor
=
Color
.
FromArgb
(
192
,
192
,
192
);
[
Description
(
"边框颜色"
),
Category
(
"自定义"
)]
public
Color
BorderColor
{
get
{
return
m_borderColor
;
}
set
{
m_borderColor
=
value
;
Refresh
();
}
}
[
Description
(
"值字体"
),
Category
(
"自定义"
)]
public
override
Font
Font
{
get
{
return
base
.
Font
;
}
set
{
base
.
Font
=
value
;
Refresh
();
}
}
[
Description
(
"值字体颜色"
),
Category
(
"自定义"
)]
public
override
System
.
Drawing
.
Color
ForeColor
{
get
{
return
base
.
ForeColor
;
}
set
{
base
.
ForeColor
=
value
;
Refresh
();
}
}
private
ValueTextType
m_valueTextType
=
ValueTextType
.
Percent
;
[
Description
(
"值显示样式"
),
Category
(
"自定义"
)]
public
ValueTextType
ValueTextType
{
get
{
return
m_valueTextType
;
}
set
{
m_valueTextType
=
value
;
Refresh
();
}
}
public
UCProcessLine
()
{
Size
=
new
Size
(
200
,
15
);
ForeColor
=
Color
.
FromArgb
(
255
,
77
,
59
);
Font
=
new
Font
(
"Arial Unicode MS"
,
10
);
this
.
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
this
.
SetStyle
(
ControlStyles
.
DoubleBuffer
,
true
);
this
.
SetStyle
(
ControlStyles
.
ResizeRedraw
,
true
);
this
.
SetStyle
(
ControlStyles
.
Selectable
,
true
);
this
.
SetStyle
(
ControlStyles
.
SupportsTransparentBackColor
,
true
);
this
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
}
protected
override
void
OnPaint
(
PaintEventArgs
e
)
{
Console
.
WriteLine
(
DateTime
.
Now
);
base
.
OnPaint
(
e
);
Graphics
g
=
e
.
Graphics
;
g
.
SetGDIHigh
();
Brush
sb
=
new
SolidBrush
(
m_valueBGColor
);
g
.
FillRectangle
(
sb
,
new
Rectangle
(
base
.
ClientRectangle
.
X
,
base
.
ClientRectangle
.
Y
,
base
.
ClientRectangle
.
Width
-
3
,
base
.
ClientRectangle
.
Height
-
2
));
GraphicsPath
path1
=
ControlHelper
.
CreateRoundedRectanglePath
(
new
Rectangle
(
base
.
ClientRectangle
.
X
,
base
.
ClientRectangle
.
Y
+
1
,
base
.
ClientRectangle
.
Width
-
3
,
base
.
ClientRectangle
.
Height
-
4
),
3
);
g
.
DrawPath
(
new
Pen
(
m_borderColor
,
1
),
path1
);
LinearGradientBrush
lgb
=
new
LinearGradientBrush
(
new
Point
(
0
,
0
),
new
Point
(
0
,
base
.
ClientRectangle
.
Height
-
3
),
m_valueColor
,
Color
.
FromArgb
(
200
,
m_valueColor
.
R
,
m_valueColor
.
G
,
m_valueColor
.
B
));
g
.
FillPath
(
lgb
,
ControlHelper
.
CreateRoundedRectanglePath
(
new
Rectangle
(
0
,
(
base
.
ClientRectangle
.
Height
-
(
base
.
ClientRectangle
.
Height
-
3
))
/
2
,
(
base
.
ClientRectangle
.
Width
-
3
)
*
Value
/
m_maxValue
,
base
.
ClientRectangle
.
Height
-
4
),
3
));
string
strValue
=
string
.
Empty
;
if
(
m_valueTextType
==
HZH_Controls
.
Controls
.
ValueTextType
.
Percent
)
strValue
=
((
float
)
Value
/
(
float
)
m_maxValue
).
ToString
(
"0%"
);
else
if
(
m_valueTextType
==
HZH_Controls
.
Controls
.
ValueTextType
.
Absolute
)
strValue
=
Value
+
"/"
+
m_maxValue
;
if
(!
string
.
IsNullOrEmpty
(
strValue
))
{
System
.
Drawing
.
SizeF
sizeF
=
g
.
MeasureString
(
strValue
,
Font
);
g
.
DrawString
(
strValue
,
Font
,
new
SolidBrush
(
ForeColor
),
new
PointF
((
this
.
Width
-
sizeF
.
Width
)
/
2
,
(
this
.
Height
-
sizeF
.
Height
)
/
2
+
1
));
}
}
}
public
enum
ValueTextType
{
None
,
/// <summary>
/// 百分比
/// </summary>
Percent
,
/// <summary>
/// 数值
/// </summary>
Absolute
}
}
HZH_Controls/HZH_Controls/Controls/UCControlBase.cs
查看文件 @
0cd8f1e
...
...
@@ -16,7 +16,7 @@ using System.Drawing.Drawing2D;
namespace
HZH_Controls.Controls
{
[
Designer
(
"System.Windows.Forms.Design.ParentControlDesigner, System.Design"
,
typeof
(
System
.
ComponentModel
.
Design
.
IDesigner
))]
public
partial
class
UCControlBase
:
UserControl
,
IContainerControl
public
partial
class
UCControlBase
:
UserControl
,
IContainerControl
,
ITheme
{
private
bool
_isRadius
=
false
;
...
...
@@ -189,7 +189,16 @@ namespace HZH_Controls.Controls
base
.
WndProc
(
ref
m
);
}
}
public
virtual
void
ResetTheme
(
ThemeEntity
theme
)
{
}
[
Description
(
"是否启用主题"
),
Category
(
"自定义"
)]
public
bool
EnabledTheme
{
get
;
set
;
}
}
}
HZH_Controls/HZH_Controls/Forms/FrmTransparent.cs
查看文件 @
0cd8f1e
...
...
@@ -29,7 +29,15 @@ namespace HZH_Controls.Forms
private
const
int
WM_MOUSEACTIVATE
=
33
;
private
const
int
MA_NOACTIVATE
=
3
;
protected
override
CreateParams
CreateParams
{
get
{
CreateParams
cp
=
base
.
CreateParams
;
cp
.
ExStyle
|=
0x02000000
;
// Turn on WS_EX_COMPOSITED
return
cp
;
}
}
public
FrmBase
frmchild
{
get
;
...
...
@@ -39,9 +47,12 @@ namespace HZH_Controls.Forms
{
InitializeComponent
();
base
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
base
.
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
base
.
SetStyle
(
ControlStyles
.
DoubleBuffer
,
true
);
this
.
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
this
.
SetStyle
(
ControlStyles
.
DoubleBuffer
,
true
);
this
.
SetStyle
(
ControlStyles
.
ResizeRedraw
,
true
);
this
.
SetStyle
(
ControlStyles
.
Selectable
,
true
);
this
.
SetStyle
(
ControlStyles
.
SupportsTransparentBackColor
,
true
);
this
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
MethodInfo
method
=
base
.
GetType
().
GetMethod
(
"SetStyle"
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
InvokeMethod
);
method
.
Invoke
(
this
,
BindingFlags
.
Instance
|
BindingFlags
.
NonPublic
|
BindingFlags
.
InvokeMethod
,
null
,
new
object
[]
...
...
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
0cd8f1e
...
...
@@ -116,6 +116,9 @@
<Compile Include="Controls\Process\UCProcessEllipse.Designer.cs">
<DependentUpon>UCProcessEllipse.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Process\UCProcessLine.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Step\UCStep.cs">
<SubType>UserControl</SubType>
</Compile>
...
...
@@ -349,6 +352,7 @@
<Compile Include="Forms\FrmWithTitle.Designer.cs">
<DependentUpon>FrmWithTitle.cs</DependentUpon>
</Compile>
<Compile Include="Helpers\ITheme.cs" />
<Compile Include="Helpers\MouseHook.cs" />
<Compile Include="Helpers\NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
...
...
HZH_Controls/HZH_Controls/Helpers/ControlHelper.cs
查看文件 @
0cd8f1e
...
...
@@ -642,5 +642,26 @@ namespace HZH_Controls
g
.
InterpolationMode
=
InterpolationMode
.
HighQualityBicubic
;
g
.
CompositingQuality
=
CompositingQuality
.
HighQuality
;
}
/// <summary>
/// 根据矩形和圆得到一个圆角矩形Path
/// </summary>
/// <param name="rect"></param>
/// <param name="cornerRadius"></param>
/// <returns></returns>
public
static
GraphicsPath
CreateRoundedRectanglePath
(
Rectangle
rect
,
int
cornerRadius
)
{
GraphicsPath
roundedRect
=
new
GraphicsPath
();
roundedRect
.
AddArc
(
rect
.
X
,
rect
.
Y
,
cornerRadius
*
2
,
cornerRadius
*
2
,
180
,
90
);
roundedRect
.
AddLine
(
rect
.
X
+
cornerRadius
,
rect
.
Y
,
rect
.
Right
-
cornerRadius
*
2
,
rect
.
Y
);
roundedRect
.
AddArc
(
rect
.
X
+
rect
.
Width
-
cornerRadius
*
2
,
rect
.
Y
,
cornerRadius
*
2
,
cornerRadius
*
2
,
270
,
90
);
roundedRect
.
AddLine
(
rect
.
Right
,
rect
.
Y
+
cornerRadius
*
2
,
rect
.
Right
,
rect
.
Y
+
rect
.
Height
-
cornerRadius
*
2
);
roundedRect
.
AddArc
(
rect
.
X
+
rect
.
Width
-
cornerRadius
*
2
,
rect
.
Y
+
rect
.
Height
-
cornerRadius
*
2
,
cornerRadius
*
2
,
cornerRadius
*
2
,
0
,
90
);
roundedRect
.
AddLine
(
rect
.
Right
-
cornerRadius
*
2
,
rect
.
Bottom
,
rect
.
X
+
cornerRadius
*
2
,
rect
.
Bottom
);
roundedRect
.
AddArc
(
rect
.
X
,
rect
.
Bottom
-
cornerRadius
*
2
,
cornerRadius
*
2
,
cornerRadius
*
2
,
90
,
90
);
roundedRect
.
AddLine
(
rect
.
X
,
rect
.
Bottom
-
cornerRadius
*
2
,
rect
.
X
,
rect
.
Y
+
cornerRadius
*
2
);
roundedRect
.
CloseFigure
();
return
roundedRect
;
}
}
}
HZH_Controls/HZH_Controls/Helpers/ITheme.cs
0 → 100644
查看文件 @
0cd8f1e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Drawing
;
namespace
HZH_Controls
{
public
interface
ITheme
{
/// <summary>
/// 重置主题
/// </summary>
/// <param name="theme"></param>
void
ResetTheme
(
ThemeEntity
theme
);
/// <summary>
/// 是否禁用一键换肤,默认禁用
/// </summary>
bool
EnabledTheme
{
get
;
set
;
}
}
public
class
ThemeEntity
{
/// <summary>
/// 边框颜色
/// </summary>
public
Color
?
BorderColor
{
get
;
set
;
}
/// <summary>
/// 填充颜色
/// </summary>
public
Color
?
FillColor
{
get
;
set
;
}
/// <summary>
/// 背景色
/// </summary>
public
Color
?
BackColor
{
get
;
set
;
}
/// <summary>
/// 前景色
/// </summary>
public
Color
?
ForeColor
{
get
;
set
;
}
/// <summary>
/// 字体颜色
/// </summary>
public
Color
?
FontColor
{
get
;
set
;
}
/// <summary>
/// 选中颜色
/// </summary>
public
Color
?
SelectedColor
{
get
;
set
;
}
/// <summary>
/// 选中字体颜色
/// </summary>
public
Color
?
SelectedFontColor
{
get
;
set
;
}
}
}
HZH_Controls/Test/Form2.Designer.cs
查看文件 @
0cd8f1e
...
...
@@ -31,6 +31,7 @@
this
.
components
=
new
System
.
ComponentModel
.
Container
();
System
.
ComponentModel
.
ComponentResourceManager
resources
=
new
System
.
ComponentModel
.
ComponentResourceManager
(
typeof
(
Form2
));
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
ucProcessLine1
=
new
HZH_Controls
.
Controls
.
UCProcessLine
();
this
.
ucSwitch10
=
new
HZH_Controls
.
Controls
.
UCSwitch
();
this
.
ucSwitch9
=
new
HZH_Controls
.
Controls
.
UCSwitch
();
this
.
ucSwitch6
=
new
HZH_Controls
.
Controls
.
UCSwitch
();
...
...
@@ -54,6 +55,19 @@
this
.
timer1
.
Enabled
=
true
;
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// ucProcessLine1
//
this
.
ucProcessLine1
.
BorderColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
192
)))),
((
int
)(((
byte
)(
192
)))),
((
int
)(((
byte
)(
192
)))));
this
.
ucProcessLine1
.
Location
=
new
System
.
Drawing
.
Point
(
406
,
224
);
this
.
ucProcessLine1
.
MaxValue
=
150
;
this
.
ucProcessLine1
.
Name
=
"ucProcessLine1"
;
this
.
ucProcessLine1
.
Size
=
new
System
.
Drawing
.
Size
(
269
,
32
);
this
.
ucProcessLine1
.
TabIndex
=
5
;
this
.
ucProcessLine1
.
Text
=
"ucProcessLine1"
;
this
.
ucProcessLine1
.
Value
=
150
;
this
.
ucProcessLine1
.
ValueBGColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucProcessLine1
.
ValueColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
73
)))),
((
int
)(((
byte
)(
119
)))),
((
int
)(((
byte
)(
232
)))));
//
// ucSwitch10
//
this
.
ucSwitch10
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
...
...
@@ -247,6 +261,7 @@
this
.
ucPanelTitle1
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
ucPanelTitle1
.
BorderColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
73
)))),
((
int
)(((
byte
)(
119
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucPanelTitle1
.
ConerRadius
=
10
;
this
.
ucPanelTitle1
.
EnabledTheme
=
false
;
this
.
ucPanelTitle1
.
FillColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucPanelTitle1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
15F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Pixel
);
this
.
ucPanelTitle1
.
IsRadius
=
true
;
...
...
@@ -309,6 +324,7 @@
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
825
,
594
);
this
.
Controls
.
Add
(
this
.
ucProcessLine1
);
this
.
Controls
.
Add
(
this
.
ucSwitch10
);
this
.
Controls
.
Add
(
this
.
ucSwitch9
);
this
.
Controls
.
Add
(
this
.
ucSwitch6
);
...
...
@@ -351,5 +367,6 @@
private
HZH_Controls
.
Controls
.
UCSwitch
ucSwitch10
;
private
HZH_Controls
.
Controls
.
UCProcessEllipse
ucProcessEllipse2
;
private
HZH_Controls
.
Controls
.
UCStep
ucStep2
;
private
HZH_Controls
.
Controls
.
UCProcessLine
ucProcessLine1
;
}
}
\ No newline at end of file
HZH_Controls/Test/Form2.cs
查看文件 @
0cd8f1e
...
...
@@ -25,10 +25,13 @@ namespace Test
{
this
.
ucProcessEllipse1
.
Value
++;
this
.
ucProcessEllipse2
.
Value
++;
this
.
ucProcessLine1
.
Value
++;
if
(
this
.
ucProcessEllipse1
.
Value
==
100
)
this
.
ucProcessEllipse1
.
Value
=
0
;
if
(
this
.
ucProcessEllipse2
.
Value
==
100
)
this
.
ucProcessEllipse2
.
Value
=
0
;
if
(
this
.
ucProcessLine1
.
Value
>=
this
.
ucProcessLine1
.
MaxValue
)
this
.
ucProcessLine1
.
Value
=
0
;
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论