Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 20cada12
由
HZH
编写于
2019-09-06 16:38:42 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
管道阀门
1 个父辈
6761bffb
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
448 行增加
和
31 行删除
HZH_Controls/HZH_Controls/Controls/FactoryControls/Conduit/UCConduit.cs
HZH_Controls/HZH_Controls/Controls/FactoryControls/Valve/UCValve.cs
HZH_Controls/Test/Form4.Designer.cs
HZH_Controls/HZH_Controls/Controls/FactoryControls/Conduit/UCConduit.cs
查看文件 @
20cada1
...
...
@@ -113,6 +113,11 @@ namespace HZH_Controls.Controls.Conduit
set
{
liquidDirection
=
value
;
if
(
value
==
Conduit
.
LiquidDirection
.
None
)
m_timer
.
Enabled
=
false
;
else
m_timer
.
Enabled
=
true
;
Refresh
();
}
}
...
...
@@ -145,7 +150,7 @@ namespace HZH_Controls.Controls.Conduit
/// Gets or sets the width of the conduit.
/// </summary>
/// <value>The width of the conduit.</value>
[
Description
(
"管道宽度,
此值为管道入口处的宽度,
当ConduitStyle的值是Horizontal_Tilt_Up,Horizontal_Tilt_Down,Vertical_Tilt_Left,Vertical_Tilt_Right时有效,其他时候将根据管道大小使用自动宽度"
),
Category
(
"自定义"
)]
[
Description
(
"管道宽度,当ConduitStyle的值是Horizontal_Tilt_Up,Horizontal_Tilt_Down,Vertical_Tilt_Left,Vertical_Tilt_Right时有效,其他时候将根据管道大小使用自动宽度"
),
Category
(
"自定义"
)]
public
int
ConduitWidth
{
get
{
return
conduitWidth
;
}
...
...
@@ -616,8 +621,7 @@ namespace HZH_Controls.Controls.Conduit
{
_intPenWidth
=
conduitWidth
;
}
int
intCount
=
_intPenWidth
/
2
/
4
;
int
intSplit
=
(
255
-
100
)
/
intCount
;
int
intCount
=
_intPenWidth
/
2
/
4
;
for
(
int
i
=
0
;
i
<
intCount
;
i
++)
{
int
_penWidth
=
_intPenWidth
/
2
-
4
*
i
;
...
...
HZH_Controls/HZH_Controls/Controls/FactoryControls/Valve/UCValve.cs
查看文件 @
20cada1
using
System
;
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-06
//
// ***********************************************************************
// <copyright file="UCValve.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
HZH_Controls.Controls.Conduit
;
using
System.ComponentModel
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class UCValve.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public
class
UCValve
:
UserControl
{
private
ValveDirection
valveDirection
=
ValveDirection
.
Horizontal
;
/// <summary>
/// The valve style
/// </summary>
private
ValveStyle
valveStyle
=
ValveStyle
.
Horizontal_Top
;
public
ValveDirection
ValveDirection
/// <summary>
/// Gets or sets the valve style.
/// </summary>
/// <value>The valve style.</value>
public
ValveStyle
ValveStyle
{
get
{
return
valveDirection
;
}
set
{
valveDirection
=
value
;
}
get
{
return
valveStyle
;
}
set
{
valveStyle
=
value
;
Refresh
();
}
}
/// <summary>
/// The valve color
/// </summary>
private
Color
valveColor
=
Color
.
FromArgb
(
255
,
77
,
59
);
/// <summary>
/// Gets or sets the color of the valve.
/// </summary>
/// <value>The color of the valve.</value>
public
Color
ValveColor
{
get
{
return
valveColor
;
}
set
{
valveColor
=
value
;
Refresh
();
}
}
/// <summary>
/// The switch color
/// </summary>
private
Color
switchColor
=
Color
.
FromArgb
(
232
,
30
,
99
);
/// <summary>
/// Gets or sets the color of the switch.
/// </summary>
/// <value>The color of the switch.</value>
public
Color
SwitchColor
{
get
{
return
switchColor
;
}
set
{
switchColor
=
value
;
Refresh
();
}
}
/// <summary>
/// The axis color
/// </summary>
private
Color
axisColor
=
Color
.
FromArgb
(
3
,
169
,
243
);
/// <summary>
/// Gets or sets the color of the axis.
/// </summary>
/// <value>The color of the axis.</value>
public
Color
AxisColor
{
get
{
return
axisColor
;
}
set
{
axisColor
=
value
;
Refresh
();
}
}
/// <summary>
/// The opened
/// </summary>
private
bool
opened
=
true
;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="UCValve"/> is opened.
/// </summary>
/// <value><c>true</c> if opened; otherwise, <c>false</c>.</value>
public
bool
Opened
{
get
{
return
opened
;
}
set
{
opened
=
value
;
Refresh
();
}
}
/// <summary>
/// The liquid direction
/// </summary>
private
LiquidDirection
liquidDirection
=
LiquidDirection
.
Forward
;
/// <summary>
/// Gets or sets the liquid direction.
/// </summary>
/// <value>The liquid direction.</value>
[
Description
(
"液体流动方向"
),
Category
(
"自定义"
)]
public
LiquidDirection
LiquidDirection
{
get
{
return
liquidDirection
;
}
set
{
liquidDirection
=
value
;
if
(
value
==
Conduit
.
LiquidDirection
.
None
)
m_timer
.
Enabled
=
false
;
else
m_timer
.
Enabled
=
true
;
Refresh
();
}
}
/// <summary>
/// The liquid speed
/// </summary>
private
int
liquidSpeed
=
100
;
/// <summary>
/// 液体流速,越小,速度越快Gets or sets the liquid speed.
/// </summary>
/// <value>The liquid speed.</value>
[
Description
(
"液体流速,越小,速度越快"
),
Category
(
"自定义"
)]
public
int
LiquidSpeed
{
get
{
return
liquidSpeed
;
}
set
{
if
(
value
<=
0
)
return
;
liquidSpeed
=
value
;
m_timer
.
Interval
=
value
;
}
}
/// <summary>
/// The liquid color
/// </summary>
private
Color
liquidColor
=
Color
.
FromArgb
(
3
,
169
,
243
);
/// <summary>
/// Gets or sets the color of the liquid.
/// </summary>
/// <value>The color of the liquid.</value>
[
Description
(
"液体颜色"
),
Category
(
"自定义"
)]
public
Color
LiquidColor
{
get
{
return
liquidColor
;
}
set
{
liquidColor
=
value
;
if
(
liquidDirection
!=
Conduit
.
LiquidDirection
.
None
)
Refresh
();
}
}
/// <summary>
/// The m timer
/// </summary>
Timer
m_timer
;
/// <summary>
/// The int line left
/// </summary>
int
intLineLeft
=
0
;
/// <summary>
/// Initializes a new instance of the <see cref="UCValve"/> class.
/// </summary>
public
UCValve
()
{
this
.
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
...
...
@@ -26,42 +213,207 @@ namespace HZH_Controls.Controls
this
.
SetStyle
(
ControlStyles
.
Selectable
,
true
);
this
.
SetStyle
(
ControlStyles
.
SupportsTransparentBackColor
,
true
);
this
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
Size
=
new
Size
(
120
,
100
);
m_timer
=
new
Timer
();
m_timer
.
Interval
=
100
;
m_timer
.
Tick
+=
timer_Tick
;
m_timer
.
Enabled
=
true
;
}
/// <summary>
/// Handles the Tick event of the timer control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void
timer_Tick
(
object
sender
,
EventArgs
e
)
{
intLineLeft
+=
2
;
if
(
intLineLeft
>
12
)
intLineLeft
=
0
;
Refresh
();
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected
override
void
OnPaint
(
PaintEventArgs
e
)
{
base
.
OnPaint
(
e
);
var
g
=
e
.
Graphics
;
g
.
SetGDIHigh
();
Rectangle
rectGuan
=
Rectangle
.
Empty
;
Rectangle
rectJK1
=
Rectangle
.
Empty
;
Rectangle
rectJK2
=
Rectangle
.
Empty
;
Rectangle
rectZ
=
Rectangle
.
Empty
;
GraphicsPath
linePath
=
new
GraphicsPath
();
GraphicsPath
dzPath
=
new
GraphicsPath
();
GraphicsPath
bsPath
=
new
GraphicsPath
();
switch
(
valveStyle
)
{
case
ValveStyle
.
Horizontal_Top
:
rectGuan
=
new
Rectangle
(
0
,
this
.
Height
/
2
,
this
.
Width
,
this
.
Height
/
2
-
this
.
Height
/
8
);
rectJK1
=
new
Rectangle
(
this
.
Height
/
8
,
rectGuan
.
Top
-
this
.
Height
/
8
,
rectGuan
.
Height
/
2
,
rectGuan
.
Height
+
this
.
Height
/
4
);
rectJK2
=
new
Rectangle
(
rectGuan
.
Right
-
this
.
Height
/
8
-
rectGuan
.
Height
/
2
,
rectGuan
.
Top
-
this
.
Height
/
8
,
rectGuan
.
Height
/
2
,
rectGuan
.
Height
+
this
.
Height
/
4
);
linePath
.
AddLine
(
new
Point
(
rectGuan
.
Left
-
10
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
),
new
Point
(
rectGuan
.
Right
+
10
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
));
rectZ
=
new
Rectangle
(
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
/
4
)
/
2
,
10
,
rectGuan
.
Height
/
4
,
rectGuan
.
Top
-
10
);
Point
[]
psTop
=
new
Point
[]
{
new
Point
(
rectGuan
.
Left
+(
rectGuan
.
Width
-
rectGuan
.
Height
/
2
)/
2
,
rectGuan
.
Top
-
this
.
Height
/
8
-
5
),
new
Point
(
rectGuan
.
Right
-(
rectGuan
.
Width
-
rectGuan
.
Height
/
2
)/
2
,
rectGuan
.
Top
-
this
.
Height
/
8
-
5
),
new
Point
(
rectGuan
.
Right
-(
rectGuan
.
Width
-
rectGuan
.
Height
)/
2
,
rectGuan
.
Top
+
2
),
new
Point
(
rectGuan
.
Left
+(
rectGuan
.
Width
-
rectGuan
.
Height
)/
2
,
rectGuan
.
Top
+
2
),
};
dzPath
.
AddLines
(
psTop
);
dzPath
.
CloseAllFigures
();
if
(
opened
)
{
bsPath
.
AddLine
(
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
-
10
)
/
2
,
10
+
(
rectGuan
.
Height
/
3
)
/
2
,
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
-
10
)
/
2
+
rectGuan
.
Height
+
10
,
10
+
(
rectGuan
.
Height
/
3
)
/
2
);
}
else
{
bsPath
.
AddLine
(
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
-
3
,
1
),
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
+
4
,
rectGuan
.
Height
+
10
));
}
break
;
case
ValveStyle
.
Horizontal_Bottom
:
rectGuan
=
new
Rectangle
(
0
,
this
.
Height
/
8
,
this
.
Width
,
this
.
Height
/
2
-
this
.
Height
/
8
);
rectJK1
=
new
Rectangle
(
this
.
Height
/
8
,
rectGuan
.
Top
-
this
.
Height
/
8
,
rectGuan
.
Height
/
2
,
rectGuan
.
Height
+
this
.
Height
/
4
);
rectJK2
=
new
Rectangle
(
rectGuan
.
Right
-
this
.
Height
/
8
-
rectGuan
.
Height
/
2
,
rectGuan
.
Top
-
this
.
Height
/
8
,
rectGuan
.
Height
/
2
,
rectGuan
.
Height
+
this
.
Height
/
4
);
linePath
.
AddLine
(
new
Point
(
rectGuan
.
Left
-
10
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
),
new
Point
(
rectGuan
.
Right
+
10
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
));
rectZ
=
new
Rectangle
(
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
/
4
)
/
2
,
rectGuan
.
Bottom
+
10
,
rectGuan
.
Height
/
4
,
this
.
Height
-
10
-
(
rectGuan
.
Bottom
+
10
));
Point
[]
psBottom
=
new
Point
[]
{
new
Point
(
rectGuan
.
Left
+(
rectGuan
.
Width
-
rectGuan
.
Height
/
2
)/
2
,
rectGuan
.
Bottom
+
this
.
Height
/
8
+
5
),
new
Point
(
rectGuan
.
Right
-(
rectGuan
.
Width
-
rectGuan
.
Height
/
2
)/
2
,
rectGuan
.
Bottom
+
this
.
Height
/
8
+
5
),
new
Point
(
rectGuan
.
Right
-(
rectGuan
.
Width
-
rectGuan
.
Height
)/
2
,
rectGuan
.
Bottom
-
2
),
new
Point
(
rectGuan
.
Left
+(
rectGuan
.
Width
-
rectGuan
.
Height
)/
2
,
rectGuan
.
Bottom
-
2
),
};
dzPath
.
AddLines
(
psBottom
);
dzPath
.
CloseAllFigures
();
if
(
opened
)
{
bsPath
.
AddLine
(
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
-
10
)
/
2
,
this
.
Height
-
(
10
+
(
rectGuan
.
Height
/
3
)
/
2
),
rectGuan
.
Left
+
(
rectGuan
.
Width
-
rectGuan
.
Height
-
10
)
/
2
+
rectGuan
.
Height
+
10
,
this
.
Height
-
(
10
+
(
rectGuan
.
Height
/
3
)
/
2
));
}
else
{
bsPath
.
AddLine
(
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
-
3
,
this
.
Height
-
1
),
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
+
4
,
this
.
Height
-
(
rectGuan
.
Height
+
10
)));
}
break
;
case
ValveStyle
.
Vertical_Left
:
rectGuan
=
new
Rectangle
(
this
.
Width
/
8
,
0
,
this
.
Width
/
2
-
this
.
Width
/
8
,
this
.
Height
);
rectJK1
=
new
Rectangle
(
0
,
this
.
Width
/
8
,
rectGuan
.
Width
+
this
.
Width
/
4
,
rectGuan
.
Width
/
2
);
rectJK2
=
new
Rectangle
(
0
,
this
.
Height
-
this
.
Width
/
8
-
rectGuan
.
Width
/
2
,
rectGuan
.
Width
+
this
.
Width
/
4
,
rectGuan
.
Width
/
2
);
linePath
.
AddLine
(
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
,
rectGuan
.
Top
-
10
),
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
,
rectGuan
.
Bottom
+
10
));
rectZ
=
new
Rectangle
(
rectGuan
.
Right
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
4
)
/
2
,
rectGuan
.
Right
-
10
,
rectGuan
.
Width
/
4
);
Point
[]
psLeft
=
new
Point
[]
{
new
Point
(
rectGuan
.
Right
+
this
.
Width
/
8
+
5
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
2
)
/
2
),
new
Point
(
rectGuan
.
Right
+
this
.
Width
/
8
+
5
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
2
)
/
2
+
rectGuan
.
Width
/
2
),
new
Point
(
rectGuan
.
Right
-
2
,
rectGuan
.
Top
+(
rectGuan
.
Height
-
rectGuan
.
Width
)/
2
+
rectGuan
.
Width
),
new
Point
(
rectGuan
.
Right
-
2
,
rectGuan
.
Top
+(
rectGuan
.
Height
-
rectGuan
.
Width
)/
2
),
};
dzPath
.
AddLines
(
psLeft
);
dzPath
.
CloseAllFigures
();
if
(
opened
)
{
bsPath
.
AddLine
(
this
.
Width
-
(
10
+
(
rectGuan
.
Width
/
3
)
/
2
),
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
-
10
)
/
2
,
this
.
Width
-
(
10
+
(
rectGuan
.
Width
/
3
)
/
2
),
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
-
10
)
/
2
+
rectGuan
.
Width
+
10
);
}
else
{
bsPath
.
AddLine
(
new
Point
(
this
.
Width
-
1
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
-
3
),
new
Point
(
this
.
Width
-
(
rectGuan
.
Width
+
10
),
rectGuan
.
Top
+
rectGuan
.
Height
/
2
+
4
));
}
break
;
case
ValveStyle
.
Vertical_Right
:
rectGuan
=
new
Rectangle
(
this
.
Width
-
this
.
Width
/
8
-
(
this
.
Width
/
2
-
this
.
Width
/
8
),
0
,
this
.
Width
/
2
-
this
.
Width
/
8
,
this
.
Height
);
rectJK1
=
new
Rectangle
(
this
.
Width
-
(
rectGuan
.
Width
+
this
.
Width
/
4
),
this
.
Width
/
8
,
rectGuan
.
Width
+
this
.
Width
/
4
,
rectGuan
.
Width
/
2
);
rectJK2
=
new
Rectangle
(
this
.
Width
-
(
rectGuan
.
Width
+
this
.
Width
/
4
),
this
.
Height
-
this
.
Width
/
8
-
rectGuan
.
Width
/
2
,
rectGuan
.
Width
+
this
.
Width
/
4
,
rectGuan
.
Width
/
2
);
linePath
.
AddLine
(
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
,
rectGuan
.
Top
-
10
),
new
Point
(
rectGuan
.
Left
+
rectGuan
.
Width
/
2
,
rectGuan
.
Bottom
+
10
));
rectZ
=
new
Rectangle
(
10
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
4
)
/
2
,
rectGuan
.
Left
-
10
,
rectGuan
.
Width
/
4
);
Point
[]
psRight
=
new
Point
[]
{
new
Point
(
rectGuan
.
Left
-
(
this
.
Width
/
8
+
5
)
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
2
)
/
2
),
new
Point
(
rectGuan
.
Left
-(
this
.
Width
/
8
+
5
)
,
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
/
2
)
/
2
+
rectGuan
.
Width
/
2
),
new
Point
(
rectGuan
.
Left
+
2
,
rectGuan
.
Top
+(
rectGuan
.
Height
-
rectGuan
.
Width
)/
2
+
rectGuan
.
Width
),
new
Point
(
rectGuan
.
Left
+
2
,
rectGuan
.
Top
+(
rectGuan
.
Height
-
rectGuan
.
Width
)/
2
),
};
dzPath
.
AddLines
(
psRight
);
dzPath
.
CloseAllFigures
();
if
(
opened
)
{
bsPath
.
AddLine
(
(
10
+
(
rectGuan
.
Width
/
3
)
/
2
),
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
-
10
)
/
2
,
(
10
+
(
rectGuan
.
Width
/
3
)
/
2
),
rectGuan
.
Top
+
(
rectGuan
.
Height
-
rectGuan
.
Width
-
10
)
/
2
+
rectGuan
.
Width
+
10
);
}
else
{
bsPath
.
AddLine
(
new
Point
(
1
,
rectGuan
.
Top
+
rectGuan
.
Height
/
2
-
3
),
new
Point
(
(
rectGuan
.
Width
+
10
),
rectGuan
.
Top
+
rectGuan
.
Height
/
2
+
4
));
}
break
;
}
Rectangle
rectGuan
=
new
Rectangle
(
0
,
this
.
Height
/
2
-
this
.
Height
/
8
,
this
.
Width
,
this
.
Height
/
2
+
this
.
Height
/
4
);
//管道
g
.
FillRectangle
(
new
SolidBrush
(
Color
.
Red
),
new
Rectangle
(
rectGuan
.
Left
,
rectGuan
.
Top
+
this
.
Height
/
8
,
rectGuan
.
Width
,
this
.
Height
/
2
-
this
.
Height
/
8
)
);
g
.
FillRectangle
(
new
SolidBrush
(
valveColor
),
rectGuan
);
//接口
g
.
FillRectangle
(
new
SolidBrush
(
Color
.
Red
),
new
Rectangle
(
this
.
Height
/
8
,
rectGuan
.
Top
,
rectGuan
.
Height
/
3
,
rectGuan
.
Height
));
g
.
FillRectangle
(
new
SolidBrush
(
Color
.
Red
),
new
Rectangle
(
rectGuan
.
Right
-
this
.
Height
/
8
-
rectGuan
.
Height
/
3
,
rectGuan
.
Top
,
rectGuan
.
Height
/
3
,
rectGuan
.
Height
));
g
.
FillRectangle
(
new
SolidBrush
(
valveColor
),
rectJK1
);
g
.
FillRectangle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)),
rectJK1
);
g
.
FillRectangle
(
new
SolidBrush
(
valveColor
),
rectJK2
);
g
.
FillRectangle
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
)),
rectJK2
);
//高亮
int
intCount
=
rectGuan
.
Height
/
2
/
4
;
int
intSplit
=
(
255
-
100
)
/
intCount
;
int
intCount
=
(
valveStyle
.
ToString
().
StartsWith
(
"H"
)
?
rectGuan
.
Height
:
rectGuan
.
Width
)
/
2
/
4
;
for
(
int
i
=
0
;
i
<
intCount
;
i
++)
{
int
_penWidth
=
rectGuan
.
Height
/
2
-
4
*
i
;
int
_penWidth
=
(
valveStyle
.
ToString
().
StartsWith
(
"H"
)
?
rectGuan
.
Height
:
rectGuan
.
Width
)
/
2
-
4
*
i
;
if
(
_penWidth
<=
0
)
_penWidth
=
1
;
g
.
Draw
Line
(
new
Pen
(
new
SolidBrush
(
Color
.
FromArgb
(
10
,
Color
.
White
)),
_penWidth
),
new
Point
(
rectGuan
.
Left
,
rectGuan
.
Height
/
2
+
rectGuan
.
Top
),
new
Point
(
rectGuan
.
Right
,
rectGuan
.
Height
/
2
+
rectGuan
.
Top
)
);
g
.
Draw
Path
(
new
Pen
(
new
SolidBrush
(
Color
.
FromArgb
(
40
,
Color
.
White
.
R
,
Color
.
White
.
G
,
Color
.
White
.
B
)),
_penWidth
),
linePath
);
if
(
_penWidth
==
1
)
break
;
}
//阀门底座
g
.
SetGDIHigh
();
//轴
g
.
FillRectangle
(
new
SolidBrush
(
axisColor
),
rectZ
);
//阀门底座
g
.
FillPath
(
new
SolidBrush
(
Color
.
FromArgb
(
3
,
169
,
243
)),
dzPath
);
g
.
FillPath
(
new
SolidBrush
(
Color
.
FromArgb
(
50
,
Color
.
White
)),
dzPath
);
//把手
g
.
DrawPath
(
new
Pen
(
new
SolidBrush
(
switchColor
),
(
valveStyle
.
ToString
().
StartsWith
(
"H"
)
?
rectGuan
.
Height
:
rectGuan
.
Width
)
/
3
),
bsPath
);
//液体流动
if
(
opened
)
{
Pen
p
=
new
Pen
(
new
SolidBrush
(
liquidColor
),
4
);
p
.
DashPattern
=
new
float
[]
{
6
,
6
};
p
.
DashOffset
=
intLineLeft
*
(
LiquidDirection
==
Conduit
.
LiquidDirection
.
Forward
?
-
1
:
1
);
g
.
DrawPath
(
p
,
linePath
);
}
}
}
public
enum
ValveDirection
/// <summary>
/// Enum ValveStyle
/// </summary>
public
enum
ValveStyle
{
Horizontal
,
Vertical
/// <summary>
/// 横向,开关在上方
/// </summary>
Horizontal_Top
,
/// <summary>
/// 横向,开关在下方
/// </summary>
Horizontal_Bottom
,
/// <summary>
/// 纵向,开关在左侧
/// </summary>
Vertical_Left
,
/// <summary>
/// 纵向,开关在右侧
/// </summary>
Vertical_Right
,
}
}
HZH_Controls/Test/Form4.Designer.cs
查看文件 @
20cada1
...
...
@@ -29,6 +29,8 @@
private
void
InitializeComponent
()
{
this
.
ucValve1
=
new
HZH_Controls
.
Controls
.
UCValve
();
this
.
ucValve2
=
new
HZH_Controls
.
Controls
.
UCValve
();
this
.
ucValve3
=
new
HZH_Controls
.
Controls
.
UCValve
();
this
.
ucConveyor2
=
new
HZH_Controls
.
Controls
.
UCConveyor
();
this
.
ucConveyor6
=
new
HZH_Controls
.
Controls
.
UCConveyor
();
this
.
ucConveyor4
=
new
HZH_Controls
.
Controls
.
UCConveyor
();
...
...
@@ -65,15 +67,53 @@
this
.
ucConduit10
=
new
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
();
this
.
ucConduit1
=
new
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
();
this
.
ucBottle1
=
new
HZH_Controls
.
Controls
.
UCBottle
();
this
.
ucValve4
=
new
HZH_Controls
.
Controls
.
UCValve
();
this
.
SuspendLayout
();
//
// ucValve1
//
this
.
ucValve1
.
Location
=
new
System
.
Drawing
.
Point
(
563
,
553
);
this
.
ucValve1
.
AxisColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve1
.
LiquidColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve1
.
LiquidDirection
=
HZH_Controls
.
Controls
.
Conduit
.
LiquidDirection
.
Backward
;
this
.
ucValve1
.
LiquidSpeed
=
100
;
this
.
ucValve1
.
Location
=
new
System
.
Drawing
.
Point
(
910
,
12
);
this
.
ucValve1
.
Name
=
"ucValve1"
;
this
.
ucValve1
.
Size
=
new
System
.
Drawing
.
Size
(
145
,
100
);
this
.
ucValve1
.
Opened
=
true
;
this
.
ucValve1
.
Size
=
new
System
.
Drawing
.
Size
(
169
,
106
);
this
.
ucValve1
.
SwitchColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
99
)))));
this
.
ucValve1
.
TabIndex
=
22
;
this
.
ucValve1
.
ValveDirection
=
HZH_Controls
.
Controls
.
ValveDirection
.
Horizontal
;
this
.
ucValve1
.
ValveColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucValve1
.
ValveStyle
=
HZH_Controls
.
Controls
.
ValveStyle
.
Horizontal_Top
;
//
// ucValve2
//
this
.
ucValve2
.
AxisColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve2
.
LiquidColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve2
.
LiquidDirection
=
HZH_Controls
.
Controls
.
Conduit
.
LiquidDirection
.
Backward
;
this
.
ucValve2
.
LiquidSpeed
=
100
;
this
.
ucValve2
.
Location
=
new
System
.
Drawing
.
Point
(
1222
,
307
);
this
.
ucValve2
.
Name
=
"ucValve2"
;
this
.
ucValve2
.
Opened
=
true
;
this
.
ucValve2
.
Size
=
new
System
.
Drawing
.
Size
(
97
,
131
);
this
.
ucValve2
.
SwitchColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
99
)))));
this
.
ucValve2
.
TabIndex
=
22
;
this
.
ucValve2
.
ValveColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucValve2
.
ValveStyle
=
HZH_Controls
.
Controls
.
ValveStyle
.
Vertical_Right
;
//
// ucValve3
//
this
.
ucValve3
.
AxisColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve3
.
LiquidColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve3
.
LiquidDirection
=
HZH_Controls
.
Controls
.
Conduit
.
LiquidDirection
.
Backward
;
this
.
ucValve3
.
LiquidSpeed
=
100
;
this
.
ucValve3
.
Location
=
new
System
.
Drawing
.
Point
(
1259
,
176
);
this
.
ucValve3
.
Name
=
"ucValve3"
;
this
.
ucValve3
.
Opened
=
true
;
this
.
ucValve3
.
Size
=
new
System
.
Drawing
.
Size
(
97
,
131
);
this
.
ucValve3
.
SwitchColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
99
)))));
this
.
ucValve3
.
TabIndex
=
22
;
this
.
ucValve3
.
ValveColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucValve3
.
ValveStyle
=
HZH_Controls
.
Controls
.
ValveStyle
.
Vertical_Left
;
//
// ucConveyor2
//
...
...
@@ -83,7 +123,7 @@
this
.
ucConveyor2
.
ConveyorHeight
=
30
;
this
.
ucConveyor2
.
ConveyorSpeed
=
100
;
this
.
ucConveyor2
.
Inclination
=
30D
;
this
.
ucConveyor2
.
Location
=
new
System
.
Drawing
.
Point
(
850
,
439
);
this
.
ucConveyor2
.
Location
=
new
System
.
Drawing
.
Point
(
753
,
515
);
this
.
ucConveyor2
.
Name
=
"ucConveyor2"
;
this
.
ucConveyor2
.
Size
=
new
System
.
Drawing
.
Size
(
183
,
154
);
this
.
ucConveyor2
.
TabIndex
=
21
;
...
...
@@ -96,7 +136,7 @@
this
.
ucConveyor6
.
ConveyorHeight
=
30
;
this
.
ucConveyor6
.
ConveyorSpeed
=
100
;
this
.
ucConveyor6
.
Inclination
=
90D
;
this
.
ucConveyor6
.
Location
=
new
System
.
Drawing
.
Point
(
1
258
,
396
);
this
.
ucConveyor6
.
Location
=
new
System
.
Drawing
.
Point
(
1
161
,
472
);
this
.
ucConveyor6
.
Name
=
"ucConveyor6"
;
this
.
ucConveyor6
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
197
);
this
.
ucConveyor6
.
TabIndex
=
21
;
...
...
@@ -109,7 +149,7 @@
this
.
ucConveyor4
.
ConveyorHeight
=
30
;
this
.
ucConveyor4
.
ConveyorSpeed
=
100
;
this
.
ucConveyor4
.
Inclination
=
90D
;
this
.
ucConveyor4
.
Location
=
new
System
.
Drawing
.
Point
(
742
,
396
);
this
.
ucConveyor4
.
Location
=
new
System
.
Drawing
.
Point
(
645
,
472
);
this
.
ucConveyor4
.
Name
=
"ucConveyor4"
;
this
.
ucConveyor4
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
197
);
this
.
ucConveyor4
.
TabIndex
=
21
;
...
...
@@ -122,7 +162,7 @@
this
.
ucConveyor5
.
ConveyorHeight
=
30
;
this
.
ucConveyor5
.
ConveyorSpeed
=
100
;
this
.
ucConveyor5
.
Inclination
=
0D
;
this
.
ucConveyor5
.
Location
=
new
System
.
Drawing
.
Point
(
1039
,
380
);
this
.
ucConveyor5
.
Location
=
new
System
.
Drawing
.
Point
(
942
,
456
);
this
.
ucConveyor5
.
Name
=
"ucConveyor5"
;
this
.
ucConveyor5
.
Size
=
new
System
.
Drawing
.
Size
(
213
,
53
);
this
.
ucConveyor5
.
TabIndex
=
21
;
...
...
@@ -135,7 +175,7 @@
this
.
ucConveyor3
.
ConveyorHeight
=
30
;
this
.
ucConveyor3
.
ConveyorSpeed
=
100
;
this
.
ucConveyor3
.
Inclination
=
0D
;
this
.
ucConveyor3
.
Location
=
new
System
.
Drawing
.
Point
(
820
,
380
);
this
.
ucConveyor3
.
Location
=
new
System
.
Drawing
.
Point
(
723
,
456
);
this
.
ucConveyor3
.
Name
=
"ucConveyor3"
;
this
.
ucConveyor3
.
Size
=
new
System
.
Drawing
.
Size
(
213
,
53
);
this
.
ucConveyor3
.
TabIndex
=
21
;
...
...
@@ -148,7 +188,7 @@
this
.
ucConveyor1
.
ConveyorHeight
=
30
;
this
.
ucConveyor1
.
ConveyorSpeed
=
100
;
this
.
ucConveyor1
.
Inclination
=
-
30D
;
this
.
ucConveyor1
.
Location
=
new
System
.
Drawing
.
Point
(
1039
,
428
);
this
.
ucConveyor1
.
Location
=
new
System
.
Drawing
.
Point
(
942
,
504
);
this
.
ucConveyor1
.
Name
=
"ucConveyor1"
;
this
.
ucConveyor1
.
Size
=
new
System
.
Drawing
.
Size
(
183
,
157
);
this
.
ucConveyor1
.
TabIndex
=
21
;
...
...
@@ -552,12 +592,30 @@
0
,
0
});
//
// ucValve4
//
this
.
ucValve4
.
AxisColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve4
.
LiquidColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
3
)))),
((
int
)(((
byte
)(
169
)))),
((
int
)(((
byte
)(
243
)))));
this
.
ucValve4
.
LiquidDirection
=
HZH_Controls
.
Controls
.
Conduit
.
LiquidDirection
.
Backward
;
this
.
ucValve4
.
LiquidSpeed
=
100
;
this
.
ucValve4
.
Location
=
new
System
.
Drawing
.
Point
(
1079
,
52
);
this
.
ucValve4
.
Name
=
"ucValve4"
;
this
.
ucValve4
.
Opened
=
true
;
this
.
ucValve4
.
Size
=
new
System
.
Drawing
.
Size
(
169
,
106
);
this
.
ucValve4
.
SwitchColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
99
)))));
this
.
ucValve4
.
TabIndex
=
22
;
this
.
ucValve4
.
ValveColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucValve4
.
ValveStyle
=
HZH_Controls
.
Controls
.
ValveStyle
.
Horizontal_Bottom
;
//
// Form4
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1368
,
680
);
this
.
Controls
.
Add
(
this
.
ucValve4
);
this
.
Controls
.
Add
(
this
.
ucValve1
);
this
.
Controls
.
Add
(
this
.
ucValve2
);
this
.
Controls
.
Add
(
this
.
ucValve3
);
this
.
Controls
.
Add
(
this
.
ucConveyor2
);
this
.
Controls
.
Add
(
this
.
ucConveyor6
);
this
.
Controls
.
Add
(
this
.
ucConveyor4
);
...
...
@@ -633,11 +691,14 @@
private
HZH_Controls
.
Controls
.
UCConveyor
ucConveyor4
;
private
HZH_Controls
.
Controls
.
UCConveyor
ucConveyor5
;
private
HZH_Controls
.
Controls
.
UCConveyor
ucConveyor6
;
private
HZH_Controls
.
Controls
.
UCValve
ucValve1
;
private
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
ucConduit5
;
private
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
ucConduit26
;
private
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
ucConduit28
;
private
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
ucConduit29
;
private
HZH_Controls
.
Controls
.
Conduit
.
UCConduit
ucConduit30
;
private
HZH_Controls
.
Controls
.
UCValve
ucValve3
;
private
HZH_Controls
.
Controls
.
UCValve
ucValve1
;
private
HZH_Controls
.
Controls
.
UCValve
ucValve2
;
private
HZH_Controls
.
Controls
.
UCValve
ucValve4
;
}
}
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论