Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 3f792581
由
HZH
编写于
2019-09-03 09:52:25 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
滚动文字
1 个父辈
20da8a88
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
251 行增加
和
24 行删除
HZH_Controls/HZH_Controls/Controls/Roll/UCRollText.cs
HZH_Controls/Test/Form2.Designer.cs
HZH_Controls/HZH_Controls/Controls/Roll/UCRollText.cs
查看文件 @
3f79258
...
...
@@ -3,12 +3,224 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.ComponentModel
;
namespace
HZH_Controls.Controls
.Roll
namespace
HZH_Controls.Controls
{
public
class
UCRollText
:
UserControl
{
public
override
Font
Font
{
get
{
return
base
.
Font
;
}
set
{
base
.
Font
=
value
;
if
(!
string
.
IsNullOrEmpty
(
Text
))
{
Graphics
g
=
this
.
CreateGraphics
();
var
size
=
g
.
MeasureString
(
Text
,
this
.
Font
);
rectText
=
new
Rectangle
(
0
,
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
,
(
int
)
size
.
Width
,
(
int
)
size
.
Height
);
rectText
.
Y
=
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
;
}
}
}
public
override
Color
ForeColor
{
get
{
return
base
.
ForeColor
;
}
set
{
base
.
ForeColor
=
value
;
}
}
public
override
string
Text
{
get
{
return
base
.
Text
;
}
set
{
base
.
Text
=
value
;
if
(!
string
.
IsNullOrEmpty
(
value
))
{
Graphics
g
=
this
.
CreateGraphics
();
var
size
=
g
.
MeasureString
(
value
,
this
.
Font
);
rectText
=
new
Rectangle
(
0
,
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
,
(
int
)
size
.
Width
,
(
int
)
size
.
Height
);
}
else
{
rectText
=
Rectangle
.
Empty
;
}
}
}
private
RollStyle
_RollStyle
=
RollStyle
.
LeftToRight
;
[
Description
(
"滚动样式"
),
Category
(
"自定义"
)]
public
RollStyle
RollStyle
{
get
{
return
_RollStyle
;
}
set
{
_RollStyle
=
value
;
switch
(
value
)
{
case
RollStyle
.
LeftToRight
:
m_intdirection
=
1
;
break
;
case
RollStyle
.
RightToLeft
:
m_intdirection
=
-
1
;
break
;
}
}
}
private
int
_moveStep
=
5
;
private
int
_moveSleepTime
=
100
;
[
Description
(
"每次滚动间隔时间,越小速度越快"
),
Category
(
"自定义"
)]
public
int
MoveSleepTime
{
get
{
return
_moveSleepTime
;
}
set
{
if
(
value
<=
0
)
return
;
_moveSleepTime
=
value
;
m_timer
.
Interval
=
value
;
}
}
int
m_intdirection
=
1
;
Rectangle
rectText
;
Timer
m_timer
;
public
UCRollText
()
{
}
{
this
.
SizeChanged
+=
UCRollText_SizeChanged
;
this
.
Size
=
new
Size
(
450
,
30
);
Text
=
"滚动文字"
;
m_timer
=
new
Timer
();
m_timer
.
Interval
=
100
;
m_timer
.
Tick
+=
m_timer_Tick
;
this
.
Load
+=
UCRollText_Load
;
this
.
VisibleChanged
+=
UCRollText_VisibleChanged
;
this
.
ForeColor
=
Color
.
FromArgb
(
255
,
77
,
59
);
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
Y
=
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
;
}
}
void
m_timer_Tick
(
object
sender
,
EventArgs
e
)
{
if
(
rectText
==
Rectangle
.
Empty
)
return
;
if
(
_RollStyle
==
HZH_Controls
.
Controls
.
RollStyle
.
BackAndForth
&&
rectText
.
Width
>=
this
.
Width
)
{
return
;
}
rectText
.
X
=
rectText
.
X
+
_moveStep
*
m_intdirection
;
if
(
_RollStyle
==
HZH_Controls
.
Controls
.
RollStyle
.
BackAndForth
)
{
if
(
rectText
.
X
<=
0
)
{
m_intdirection
=
1
;
}
else
if
(
rectText
.
Right
>=
this
.
Width
)
{
m_intdirection
=
-
1
;
}
}
else
if
(
_RollStyle
==
HZH_Controls
.
Controls
.
RollStyle
.
LeftToRight
)
{
if
(
rectText
.
X
>
this
.
Width
)
{
rectText
.
X
=
-
1
*
rectText
.
Width
-
1
;
}
}
else
{
if
(
rectText
.
Right
<
0
)
{
rectText
.
X
=
this
.
Width
+
rectText
.
Width
+
1
;
}
}
Refresh
();
}
void
UCRollText_VisibleChanged
(
object
sender
,
EventArgs
e
)
{
m_timer
.
Enabled
=
this
.
Visible
;
}
void
UCRollText_Load
(
object
sender
,
EventArgs
e
)
{
if
(
_RollStyle
==
HZH_Controls
.
Controls
.
RollStyle
.
LeftToRight
)
{
m_intdirection
=
1
;
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
X
=
-
1
*
rectText
.
Width
-
1
;
}
}
else
if
(
_RollStyle
==
HZH_Controls
.
Controls
.
RollStyle
.
RightToLeft
)
{
m_intdirection
=
-
1
;
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
X
=
this
.
Width
+
rectText
.
Width
+
1
;
}
}
else
{
m_intdirection
=
1
;
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
X
=
0
;
}
}
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
Y
=
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
;
}
}
void
UCRollText_SizeChanged
(
object
sender
,
EventArgs
e
)
{
if
(
rectText
!=
Rectangle
.
Empty
)
{
rectText
.
Y
=
(
this
.
Height
-
rectText
.
Height
)
/
2
+
1
;
}
}
protected
override
void
OnPaint
(
PaintEventArgs
e
)
{
base
.
OnPaint
(
e
);
if
(
rectText
!=
Rectangle
.
Empty
)
{
e
.
Graphics
.
SetGDIHigh
();
e
.
Graphics
.
DrawString
(
Text
,
Font
,
new
SolidBrush
(
ForeColor
),
rectText
.
Location
);
}
}
}
public
enum
RollStyle
{
LeftToRight
,
RightToLeft
,
BackAndForth
}
}
HZH_Controls/Test/Form2.Designer.cs
查看文件 @
3f79258
...
...
@@ -39,6 +39,8 @@
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
timer2
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
ucRollText1
=
new
HZH_Controls
.
Controls
.
UCRollText
();
this
.
ucWaveChart1
=
new
HZH_Controls
.
Controls
.
UCWaveChart
();
this
.
ucProcessEllipse1
=
new
HZH_Controls
.
Controls
.
UCProcessEllipse
();
this
.
ucProcessEllipse2
=
new
HZH_Controls
.
Controls
.
UCProcessEllipse
();
this
.
ucledNums2
=
new
HZH_Controls
.
Controls
.
LED
.
UCLEDNums
();
...
...
@@ -79,7 +81,6 @@
this
.
ucPanelTitle1
=
new
HZH_Controls
.
Controls
.
UCPanelTitle
();
this
.
ucStep2
=
new
HZH_Controls
.
Controls
.
UCStep
();
this
.
ucStep1
=
new
HZH_Controls
.
Controls
.
UCStep
();
this
.
ucWaveChart1
=
new
HZH_Controls
.
Controls
.
UCWaveChart
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar2
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar3
)).
BeginInit
();
...
...
@@ -172,6 +173,39 @@
this
.
timer2
.
Interval
=
1000
;
this
.
timer2
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer2_Tick
);
//
// ucRollText1
//
this
.
ucRollText1
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucRollText1
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
20F
);
this
.
ucRollText1
.
ForeColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucRollText1
.
Location
=
new
System
.
Drawing
.
Point
(
843
,
554
);
this
.
ucRollText1
.
MoveSleepTime
=
50
;
this
.
ucRollText1
.
Name
=
"ucRollText1"
;
this
.
ucRollText1
.
RollStyle
=
HZH_Controls
.
Controls
.
RollStyle
.
LeftToRight
;
this
.
ucRollText1
.
Size
=
new
System
.
Drawing
.
Size
(
555
,
30
);
this
.
ucRollText1
.
TabIndex
=
23
;
//
// ucWaveChart1
//
this
.
ucWaveChart1
.
ConerRadius
=
10
;
this
.
ucWaveChart1
.
FillColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
50
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
15F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Pixel
);
this
.
ucWaveChart1
.
GridLineColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
50
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
GridLineTextColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
IsRadius
=
true
;
this
.
ucWaveChart1
.
IsShowRect
=
true
;
this
.
ucWaveChart1
.
LineColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
LineTension
=
0.5F
;
this
.
ucWaveChart1
.
Location
=
new
System
.
Drawing
.
Point
(
781
,
14
);
this
.
ucWaveChart1
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
4
,
5
,
4
,
5
);
this
.
ucWaveChart1
.
Name
=
"ucWaveChart1"
;
this
.
ucWaveChart1
.
RectColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucWaveChart1
.
RectWidth
=
1
;
this
.
ucWaveChart1
.
Size
=
new
System
.
Drawing
.
Size
(
374
,
180
);
this
.
ucWaveChart1
.
SleepTime
=
1000
;
this
.
ucWaveChart1
.
TabIndex
=
22
;
this
.
ucWaveChart1
.
WaveWidth
=
50
;
//
// ucProcessEllipse1
//
this
.
ucProcessEllipse1
.
BackEllipseColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
228
)))),
((
int
)(((
byte
)(
231
)))),
((
int
)(((
byte
)(
237
)))));
...
...
@@ -708,32 +742,12 @@
this
.
ucStep1
.
StepWidth
=
35
;
this
.
ucStep1
.
TabIndex
=
0
;
//
// ucWaveChart1
//
this
.
ucWaveChart1
.
ConerRadius
=
10
;
this
.
ucWaveChart1
.
FillColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
50
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
15F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Pixel
);
this
.
ucWaveChart1
.
GridLineColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
50
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
GridLineTextColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
IsRadius
=
true
;
this
.
ucWaveChart1
.
IsShowRect
=
true
;
this
.
ucWaveChart1
.
LineColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucWaveChart1
.
LineTension
=
0.5F
;
this
.
ucWaveChart1
.
Location
=
new
System
.
Drawing
.
Point
(
781
,
14
);
this
.
ucWaveChart1
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
4
,
5
,
4
,
5
);
this
.
ucWaveChart1
.
Name
=
"ucWaveChart1"
;
this
.
ucWaveChart1
.
RectColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucWaveChart1
.
RectWidth
=
1
;
this
.
ucWaveChart1
.
Size
=
new
System
.
Drawing
.
Size
(
374
,
180
);
this
.
ucWaveChart1
.
SleepTime
=
1000
;
this
.
ucWaveChart1
.
TabIndex
=
22
;
this
.
ucWaveChart1
.
WaveWidth
=
50
;
//
// Form2
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1438
,
594
);
this
.
Controls
.
Add
(
this
.
ucRollText1
);
this
.
Controls
.
Add
(
this
.
ucWaveChart1
);
this
.
Controls
.
Add
(
this
.
ucProcessEllipse1
);
this
.
Controls
.
Add
(
this
.
ucProcessEllipse2
);
...
...
@@ -845,6 +859,7 @@
private
HZH_Controls
.
Controls
.
UCProcessEllipse
ucProcessEllipse1
;
private
System
.
Windows
.
Forms
.
Timer
timer2
;
private
HZH_Controls
.
Controls
.
UCWaveChart
ucWaveChart1
;
private
HZH_Controls
.
Controls
.
UCRollText
ucRollText1
;
}
}
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论