Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 44b6ae61
由
HZH
编写于
2019-09-23 17:36:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
折线图
1 个父辈
b59938b4
显示空白字符变更
内嵌
并排
正在显示
35 个修改的文件
包含
2398 行增加
和
5452 行删除
HZH_Controls/HZH_Controls/Controls/Charts/AuxiliaryLable.cs
HZH_Controls/HZH_Controls/Controls/Charts/BarChart/AuxiliaryLine.cs → HZH_Controls/HZH_Controls/Controls/Charts/AuxiliaryLine.cs
HZH_Controls/HZH_Controls/Controls/Charts/Axis.cs
HZH_Controls/HZH_Controls/Controls/Charts/AxisCollection.cs
HZH_Controls/HZH_Controls/Controls/Charts/AxisFormat.cs
HZH_Controls/HZH_Controls/Controls/Charts/AxisPosition.cs
HZH_Controls/HZH_Controls/Controls/Charts/AxisType.cs
HZH_Controls/HZH_Controls/Controls/Charts/ChartPoint.cs
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointCollection.cs
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointEventArgs.cs
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointEventHandler.cs
HZH_Controls/HZH_Controls/Controls/Charts/CurveChart/CurveItem.cs
HZH_Controls/HZH_Controls/Controls/Charts/CurveChart/UCCurve.cs
HZH_Controls/HZH_Controls/Controls/Charts/AxisLabel.cs → HZH_Controls/HZH_Controls/Controls/Charts/MarkText.cs
HZH_Controls/HZH_Controls/Controls/Charts/MarkTextPositionStyle.cs
HZH_Controls/HZH_Controls/Controls/Charts/PieChart/UCPieChart.cs
HZH_Controls/HZH_Controls/Controls/Charts/SelectMode.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/BezierSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/ColumnSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/LabelSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/LineSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/PointSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/Series/StandardLineSeries.cs
HZH_Controls/HZH_Controls/Controls/Charts/SeriesBase.cs
HZH_Controls/HZH_Controls/Controls/Charts/SeriesCollection.cs
HZH_Controls/HZH_Controls/Controls/Charts/SeriesCollectionEditor.cs
HZH_Controls/HZH_Controls/Controls/Charts/SeriesFormat.cs
HZH_Controls/HZH_Controls/Controls/Charts/UCChart.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/Test/FrmMain.Designer.cs
HZH_Controls/Test/FrmMain.cs
HZH_Controls/Test/Test.csproj
HZH_Controls/Test/UC/UCTestCurveChart.Designer.cs
HZH_Controls/Test/UC/UCTestCurveChart.cs
HZH_Controls/Test/UC/UCTestCurveChart.resx
HZH_Controls/HZH_Controls/Controls/Charts/AuxiliaryLable.cs
0 → 100644
查看文件 @
44b6ae6
using
System.Drawing
;
namespace
HZH_Controls.Controls
{
public
class
AuxiliaryLable
{
public
string
Text
{
get
;
set
;
}
public
Brush
TextBrush
{
get
;
set
;
}
public
Brush
TextBack
{
get
;
set
;
}
public
float
LocationX
{
get
;
set
;
}
public
AuxiliaryLable
()
{
TextBrush
=
Brushes
.
Black
;
TextBack
=
Brushes
.
Transparent
;
LocationX
=
0.5f
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/
BarChart/
AuxiliaryLine.cs
→
HZH_Controls/HZH_Controls/Controls/Charts/AuxiliaryLine.cs
查看文件 @
44b6ae6
...
...
@@ -25,110 +25,64 @@ namespace HZH_Controls.Controls
/// <seealso cref="System.IDisposable" />
internal
class
AuxiliaryLine
:
IDisposable
{
private
string
tip
;
/// <summary>
/// Gets or sets the tip.
/// </summary>
/// <value>The tip.</value>
public
string
Tip
{
get
{
return
tip
;
}
set
{
tip
=
value
;
}
}
/// <summary>
/// The disposed value
/// </summary>
private
bool
disposedValue
=
false
;
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
public
float
Value
{
get
;
set
;
}
/// <summary>
/// Gets or sets the paint value.
/// </summary>
/// <value>The paint value.</value>
public
float
PaintValue
{
get
;
set
;
}
/// <summary>
/// Gets or sets the paint value back up.
/// </summary>
/// <value>The paint value back up.</value>
public
float
PaintValueBackUp
{
get
;
set
;
}
/// <summary>
/// Gets or sets the color of the line.
/// </summary>
/// <value>The color of the line.</value>
public
Color
LineColor
{
get
;
set
;
}
/// <summary>
/// Gets or sets the pen dash.
/// </summary>
/// <value>The pen dash.</value>
public
Pen
PenDash
{
get
;
set
;
}
/// <summary>
/// Gets or sets the pen solid.
/// </summary>
/// <value>The pen solid.</value>
public
Pen
PenSolid
{
get
;
set
;
}
/// <summary>
/// Gets or sets the line thickness.
/// </summary>
/// <value>The line thickness.</value>
public
float
LineThickness
{
get
;
set
;
}
/// <summary>
/// Gets or sets the line text brush.
/// </summary>
/// <value>The line text brush.</value>
public
Brush
LineTextBrush
{
get
;
set
;
}
/// <summary>
/// The is dash style
/// </summary>
public
bool
IsLeftFrame
{
get
;
set
;
}
private
bool
isDashStyle
=
true
;
/// <summary>
/// Gets or sets a value indicating whether this instance is dash style.
/// </summary>
/// <value><c>true</c> if this instance is dash style; otherwise, <c>false</c>.</value>
public
bool
IsDashStyle
{
get
{
return
isDashStyle
;
}
...
...
@@ -136,40 +90,30 @@ namespace HZH_Controls.Controls
}
/// <summary>
/// Gets the pen.
/// </summary>
/// <returns>Pen.</returns>
public
Pen
GetPen
()
{
return
IsDashStyle
?
PenDash
:
PenSolid
;
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected
virtual
void
Dispose
(
bool
disposing
)
{
if
(!
disposedValue
)
{
if
(
disposing
)
{
if
(
PenDash
!
=
null
)
if
(
PenDash
=
=
null
)
PenDash
.
Dispose
();
if
(
PenSolid
!
=
null
)
if
(
PenSolid
=
=
null
)
PenSolid
.
Dispose
();
if
(
LineTextBrush
!
=
null
)
if
(
LineTextBrush
=
=
null
)
LineTextBrush
.
Dispose
();
}
disposedValue
=
true
;
}
}
/// <summary>
/// 执行与释放或重置非托管资源相关的应用程序定义的任务。
/// </summary>
public
string
Tip
{
get
;
set
;
}
public
void
Dispose
()
{
Dispose
(
true
);
...
...
HZH_Controls/HZH_Controls/Controls/Charts/Axis.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="Axis.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.ComponentModel
;
using
System.Drawing
;
using
System.Linq
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class Axis.
/// </summary>
[
TypeConverter
(
typeof
(
ExpandableObjectConverter
))]
public
class
Axis
{
/// <summary>
/// The minimum value buf
/// </summary>
private
double
minValBuf
;
/// <summary>
/// The maximum value buf
/// </summary>
private
double
maxValBuf
;
/// <summary>
/// The data step
/// </summary>
private
double
dataStep
;
/// <summary>
/// The location step
/// </summary>
private
float
locationStep
;
/// <summary>
/// The maximum label width
/// </summary>
private
float
maxLabelWidth
;
/// <summary>
/// The maximum label height
/// </summary>
private
float
maxLabelHeight
;
/// <summary>
/// The chart
/// </summary>
private
UCChart
_chart
;
/// <summary>
/// The type
/// </summary>
private
AxisType
_type
;
/// <summary>
/// The maximum value limit
/// </summary>
private
double
_maxValueLimit
=
1.0
;
/// <summary>
/// The minimum value limit
/// </summary>
private
double
_minValueLimit
=
0.0
;
/// <summary>
/// The labels
/// </summary>
private
List
<
AxisLabel
>
_labels
=
new
List
<
AxisLabel
>();
/// <summary>
/// The is custom labels
/// </summary>
private
bool
_isCustomLabels
=
false
;
/// <summary>
/// The visible
/// </summary>
private
bool
_visible
=
true
;
/// <summary>
/// The label visible
/// </summary>
private
bool
_labelVisible
=
true
;
/// <summary>
/// The color
/// </summary>
private
Color
_color
=
Color
.
FromArgb
(
51
,
51
,
51
);
/// <summary>
/// The brush
/// </summary>
private
Brush
_brush
;
/// <summary>
/// The position
/// </summary>
private
AxisPosition
_position
=
AxisPosition
.
LeftBottom
;
/// <summary>
/// The title
/// </summary>
private
string
_title
;
/// <summary>
/// The is reverse
/// </summary>
private
bool
_isReverse
=
false
;
/// <summary>
/// The automatic adapt
/// </summary>
private
bool
_autoAdapt
=
true
;
/// <summary>
/// The zoom enabled
/// </summary>
private
bool
_zoomEnabled
=
true
;
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
[
Browsable
(
false
)]
public
UCChart
Chart
{
get
{
return
_chart
;
}
internal
set
{
_chart
=
value
;
}
}
/// <summary>
/// Gets the type.
/// </summary>
/// <value>The type.</value>
[
Browsable
(
false
)]
public
AxisType
Type
{
get
{
return
_type
;
}
internal
set
{
_type
=
value
;
}
}
/// <summary>
/// Gets or sets the maximum value limit.
/// </summary>
/// <value>The maximum value limit.</value>
[
Category
(
"自定义"
)]
[
Description
(
"最大值极限。"
)]
[
DefaultValue
(
1.0
)]
public
double
MaxValueLimit
{
get
{
return
_maxValueLimit
;
}
set
{
_maxValueLimit
=
value
;
MaxValue
=
value
;
}
}
/// <summary>
/// Gets or sets the minimum value limit.
/// </summary>
/// <value>The minimum value limit.</value>
[
Category
(
"自定义"
)]
[
Description
(
"最小值极限。"
)]
[
DefaultValue
(
0.0
)]
public
double
MinValueLimit
{
get
{
return
_minValueLimit
;
}
set
{
_minValueLimit
=
value
;
MinValue
=
value
;
}
}
/// <summary>
/// Gets the labels.
/// </summary>
/// <value>The labels.</value>
[
Category
(
"自定义"
)]
[
Description
(
"标签。"
)]
[
TypeConverter
(
typeof
(
CollectionConverter
))]
[
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Content
)]
public
List
<
AxisLabel
>
Labels
{
get
{
return
_labels
;
}
private
set
{
_labels
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is custom labels.
/// </summary>
/// <value><c>true</c> if this instance is custom labels; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"是否使用自定义标签。"
)]
[
DefaultValue
(
false
)]
public
bool
IsCustomLabels
{
get
{
return
_isCustomLabels
;
}
set
{
_isCustomLabels
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Axis"/> is visible.
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏。"
)]
[
DefaultValue
(
true
)]
public
bool
Visible
{
get
{
return
_visible
;
}
set
{
_visible
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [label visible].
/// </summary>
/// <value><c>true</c> if [label visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏标签,隐藏的标签不占用布局空间。"
)]
[
DefaultValue
(
true
)]
public
bool
LabelVisible
{
get
{
return
_labelVisible
;
}
set
{
_labelVisible
=
value
;
}
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>The color.</value>
[
Category
(
"自定义"
)]
[
Description
(
"颜色。"
)]
[
DefaultValue
(
true
)]
public
Color
Color
{
get
{
return
_color
;
}
set
{
_color
=
value
;
_brush
=
new
SolidBrush
(
value
);
}
}
/// <summary>
/// Gets or sets the position.
/// </summary>
/// <value>The position.</value>
[
Category
(
"自定义"
)]
[
Description
(
"位置。"
)]
[
DefaultValue
(
AxisPosition
.
LeftBottom
)]
public
AxisPosition
Position
{
get
{
return
_position
;
}
set
{
_position
=
value
;
}
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
[
Category
(
"自定义"
)]
[
Description
(
"标题。"
)]
[
DefaultValue
(
null
)]
public
string
Title
{
get
{
return
_title
;
}
set
{
_title
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is reverse.
/// </summary>
/// <value><c>true</c> if this instance is reverse; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"是否反转方向。"
)]
[
DefaultValue
(
false
)]
public
bool
IsReverse
{
get
{
return
_isReverse
;
}
set
{
_isReverse
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [automatic adapt].
/// </summary>
/// <value><c>true</c> if [automatic adapt]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"是否让数据范围自适应。"
)]
[
DefaultValue
(
true
)]
public
bool
AutoAdapt
{
get
{
return
_autoAdapt
;
}
set
{
_autoAdapt
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [zoom enabled].
/// </summary>
/// <value><c>true</c> if [zoom enabled]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"缩放使能。"
)]
[
DefaultValue
(
true
)]
public
bool
ZoomEnabled
{
get
{
return
_zoomEnabled
;
}
set
{
_zoomEnabled
=
value
;
}
}
/// <summary>
/// Gets the width.
/// </summary>
/// <value>The width.</value>
[
Browsable
(
false
)]
public
float
Width
{
get
;
private
set
;
}
/// <summary>
/// Gets the height.
/// </summary>
/// <value>The height.</value>
[
Browsable
(
false
)]
public
float
Height
{
get
;
private
set
;
}
/// <summary>
/// The maximum value
/// </summary>
private
double
maxValue
=
1.0
;
/// <summary>
/// Gets the maximum value.
/// </summary>
/// <value>The maximum value.</value>
[
Browsable
(
false
)]
public
double
MaxValue
{
get
{
return
maxValue
;
}
private
set
{
maxValue
=
value
;
}
}
/// <summary>
/// The minimum value
/// </summary>
private
double
minValue
=
0.0
;
/// <summary>
/// Gets the minimum value.
/// </summary>
/// <value>The minimum value.</value>
[
Browsable
(
false
)]
public
double
MinValue
{
get
{
return
minValue
;
}
private
set
{
minValue
=
value
;
}
}
/// <summary>
/// Gets the range.
/// </summary>
/// <value>The range.</value>
[
Browsable
(
false
)]
public
double
Range
{
get
{
double
num
=
MaxValue
-
MinValue
;
if
(
num
<=
0.0
)
{
return
1.0
;
}
return
num
;
}
}
/// <summary>
/// The zoom state
/// </summary>
ZoomType
zoomState
=
ZoomType
.
None
;
/// <summary>
/// Gets the state of the zoom.
/// </summary>
/// <value>The state of the zoom.</value>
[
Browsable
(
false
)]
public
ZoomType
ZoomState
{
get
{
return
zoomState
;
}
private
set
{
zoomState
=
value
;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="Axis"/> class.
/// </summary>
public
Axis
()
{
_labels
=
new
List
<
AxisLabel
>();
_brush
=
new
SolidBrush
(
_color
);
maxLabelWidth
=
0f
;
maxLabelHeight
=
0f
;
}
/// <summary>
/// Resets the range.
/// </summary>
internal
void
ResetRange
()
{
MinValue
=
(
minValBuf
=
_minValueLimit
);
MaxValue
=
(
maxValBuf
=
_maxValueLimit
);
}
/// <summary>
/// Updates the range.
/// </summary>
/// <param name="series">The series.</param>
/// <param name="axisType">Type of the axis.</param>
/// <param name="separatorSum">The separator sum.</param>
internal
void
UpdateRange
(
SeriesBase
series
,
AxisType
axisType
,
int
separatorSum
)
{
if
(
_autoAdapt
&&
!
_isCustomLabels
)
{
double
?
num
=
(
axisType
==
AxisType
.
X
)
?
series
.
MinValueX
:
series
.
MinValueY
;
double
?
num2
=
(
axisType
==
AxisType
.
X
)
?
series
.
MaxValueX
:
series
.
MaxValueY
;
bool
flag
=
false
;
if
(
num
.
HasValue
&&
minValBuf
>
num
.
Value
)
{
minValBuf
=
num
.
Value
;
flag
=
true
;
}
if
(
num2
.
HasValue
&&
maxValBuf
<
num2
.
Value
)
{
maxValBuf
=
num2
.
Value
;
flag
=
true
;
}
if
(
flag
)
{
UpdateRange
(
minValBuf
,
maxValBuf
,
separatorSum
);
}
}
}
/// <summary>
/// Updates the zoom.
/// </summary>
/// <param name="times">The times.</param>
internal
void
UpdateZoom
(
double
times
)
{
if
(
_zoomEnabled
)
{
if
(
times
>
0.0
)
{
ZoomState
=
ZoomType
.
Enlarge
;
}
else
if
(
times
<
0.0
)
{
ZoomState
=
ZoomType
.
Reduce
;
}
else
{
ZoomState
=
ZoomType
.
None
;
}
if
(
times
!=
0.0
)
{
double
range
=
Range
;
MinValue
+=
range
*
times
;
MaxValue
-=
range
*
times
;
}
}
}
/// <summary>
/// Updates the label.
/// </summary>
/// <param name="separatorSum">The separator sum.</param>
internal
void
UpdateLabel
(
int
separatorSum
)
{
if
(!
_isCustomLabels
)
{
_labels
.
Clear
();
dataStep
=
Range
/
(
double
)
separatorSum
;
for
(
int
i
=
0
;
i
<=
separatorSum
;
i
++)
{
double
value
=
dataStep
*
(
double
)
i
+
MinValue
;
_labels
.
Add
(
new
AxisLabel
(
value
));
}
}
}
/// <summary>
/// Updates the size1.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="font">The font.</param>
internal
void
UpdateSize1
(
Graphics
g
,
Font
font
)
{
if
(
_type
==
AxisType
.
X
)
{
Height
=
CountAxisXHeight
(
g
,
font
);
}
else
if
(
_type
==
AxisType
.
Y
)
{
Width
=
CountAxisYWidth
(
g
,
font
);
}
}
/// <summary>
/// Updates the size2.
/// </summary>
/// <param name="border">The border.</param>
/// <param name="separatorSum">The separator sum.</param>
internal
void
UpdateSize2
(
Rectangle
border
,
int
separatorSum
)
{
if
(
_type
==
AxisType
.
X
)
{
Width
=
border
.
Width
;
locationStep
=
Width
/
(
float
)
separatorSum
;
}
else
if
(
_type
==
AxisType
.
Y
)
{
Height
=
border
.
Height
;
locationStep
=
Height
/
(
float
)
separatorSum
;
}
}
/// <summary>
/// Updates the offset.
/// </summary>
/// <param name="separatorSum">The separator sum.</param>
/// <param name="offset">The offset.</param>
internal
void
UpdateOffset
(
int
separatorSum
,
int
offset
)
{
if
(
_isCustomLabels
)
{
return
;
}
int
num
=
(
int
)((
float
)
offset
/
locationStep
);
double
num2
=
(
double
)
num
*
dataStep
;
if
(
num2
!=
0.0
)
{
_labels
.
Clear
();
for
(
int
i
=
0
;
i
<=
separatorSum
;
i
++)
{
double
num3
=
dataStep
*
(
double
)
i
+
MinValue
;
num3
=
(
_isReverse
?
(
num3
+
num2
)
:
(
num3
-
num2
));
_labels
.
Add
(
new
AxisLabel
(
num3
));
}
}
}
/// <summary>
/// Draws the axis x.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="font">The font.</param>
/// <param name="border">The border.</param>
/// <param name="offset">The offset.</param>
/// <param name="top">The top.</param>
/// <param name="bottom">The bottom.</param>
internal
void
DrawAxisX
(
Graphics
g
,
Font
font
,
Rectangle
border
,
int
offset
,
ref
float
top
,
ref
float
bottom
)
{
if
(!
_visible
)
{
return
;
}
float
x
=
(
float
)
border
.
Left
+
(
float
)
border
.
Width
/
2f
;
float
num
=
_isCustomLabels
?
((
float
)(
border
.
Left
+
offset
))
:
((
float
)
border
.
Left
+
(
float
)
offset
%
locationStep
);
StringFormat
format
;
StringFormat
format2
;
float
y
;
float
y2
;
if
(
_position
==
AxisPosition
.
RightTop
)
{
format
=
AxisFormat
.
TitleFormatTopAxisX
;
format2
=
AxisFormat
.
LabelFormatTopAxisX
;
y
=
top
;
y2
=
top
+
Height
-
3f
;
top
+=
Height
;
}
else
{
format
=
AxisFormat
.
TitleFormatBottomAxisX
;
format2
=
AxisFormat
.
LabelFormatBottomAxisX
;
y
=
(
float
)
border
.
Bottom
+
bottom
+
Height
;
y2
=
(
float
)
border
.
Bottom
+
bottom
+
3f
;
bottom
+=
Height
;
}
if
(
_labelVisible
)
{
int
count
=
_labels
.
Count
;
if
(
count
>
0
)
{
RectangleF
rectangleF
=
default
(
RectangleF
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
float
num3
;
if
(
_isCustomLabels
)
{
double
num2
=
_isReverse
?
_labels
[
count
-
i
-
1
].
Value
:
_labels
[
i
].
Value
;
num3
=
Convert
.
ToSingle
((
double
)
Width
/
Range
*
(
num2
-
MinValue
));
if
(
_isReverse
)
{
num3
=
Width
-
num3
;
}
}
else
{
num3
=
(
float
)
i
*
locationStep
;
}
num3
+=
num
;
if
(
num3
>=
(
float
)
border
.
Left
&&
num3
<=
(
float
)
border
.
Right
)
{
PointF
pointF
=
new
PointF
(
num3
,
y2
);
if
(!
rectangleF
.
Contains
(
pointF
))
{
string
s
=
_isReverse
?
_labels
[
count
-
i
-
1
].
Content
:
_labels
[
i
].
Content
;
g
.
DrawString
(
s
,
font
,
_brush
,
pointF
,
format2
);
rectangleF
=
new
RectangleF
(
num3
,
y2
,
maxLabelWidth
+
21f
,
maxLabelHeight
);
}
}
}
}
}
if
(!
string
.
IsNullOrEmpty
(
_title
))
{
g
.
DrawString
(
_title
,
font
,
_brush
,
x
,
y
,
format
);
}
}
/// <summary>
/// Draws the axis y.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="font">The font.</param>
/// <param name="border">The border.</param>
/// <param name="offset">The offset.</param>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
internal
void
DrawAxisY
(
Graphics
g
,
Font
font
,
Rectangle
border
,
int
offset
,
ref
float
left
,
ref
float
right
)
{
if
(!
_visible
)
{
return
;
}
float
y
=
border
.
Top
+
border
.
Height
/
2
;
float
num
=
_isCustomLabels
?
((
float
)(
border
.
Top
+
offset
))
:
((
float
)
border
.
Top
+
(
float
)
offset
%
locationStep
);
StringFormat
format
;
StringFormat
format2
;
float
x
;
float
x2
;
if
(
_position
==
AxisPosition
.
RightTop
)
{
format
=
AxisFormat
.
TitleFormatRightAxisY
;
format2
=
AxisFormat
.
LabelFormatRightAxisY
;
x
=
(
float
)
border
.
Right
+
right
+
Width
;
x2
=
(
float
)
border
.
Right
+
right
+
3f
;
right
+=
Width
;
}
else
{
format
=
AxisFormat
.
TitleFormatLeftAxisY
;
format2
=
AxisFormat
.
LabelFormatLeftAxisY
;
x
=
left
;
x2
=
left
+
Width
-
3f
;
left
+=
Width
;
}
if
(
_labelVisible
)
{
int
count
=
_labels
.
Count
;
if
(
count
>
0
)
{
RectangleF
rectangleF
=
default
(
RectangleF
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
float
num3
;
if
(
_isCustomLabels
)
{
double
num2
=
_isReverse
?
_labels
[
i
].
Value
:
_labels
[
count
-
i
-
1
].
Value
;
num3
=
Convert
.
ToSingle
((
double
)
Height
/
Range
*
(
num2
-
MinValue
));
if
(!
_isReverse
)
{
num3
=
Height
-
num3
;
}
}
else
{
num3
=
(
float
)
i
*
locationStep
;
}
num3
+=
num
;
if
(
num3
>=
(
float
)
border
.
Top
&&
num3
<=
(
float
)
border
.
Bottom
)
{
PointF
pointF
=
new
PointF
(
x2
,
num3
);
if
(!
rectangleF
.
Contains
(
pointF
))
{
string
s
=
_isReverse
?
_labels
[
i
].
Content
:
_labels
[
count
-
i
-
1
].
Content
;
g
.
DrawString
(
s
,
font
,
_brush
,
pointF
,
format2
);
rectangleF
=
new
RectangleF
(
x2
,
num3
,
maxLabelWidth
,
maxLabelHeight
+
6f
);
}
}
}
}
}
if
(!
string
.
IsNullOrEmpty
(
_title
))
{
ControlHelper
.
DrawString
(
g
,
_title
,
font
,
_brush
,
new
PointF
(
x
,
y
),
format
,
-
90f
);
}
}
/// <summary>
/// Updates the range.
/// </summary>
/// <param name="min">The minimum.</param>
/// <param name="max">The maximum.</param>
/// <param name="separatorSum">The separator sum.</param>
private
void
UpdateRange
(
double
min
,
double
max
,
int
separatorSum
)
{
double
num
=
max
-
min
;
double
d
=
num
/
(
double
)
separatorSum
;
double
num2
=
Math
.
Pow
(
10.0
,
Math
.
Floor
(
Math
.
Log
(
d
)
/
Math
.
Log
(
10.0
)));
double
num3
=
num
/
(
double
)
separatorSum
;
double
num4
=
num3
/
num2
;
double
num5
=
(
num4
>
5.0
)
?
(
10.0
*
num2
)
:
((
num4
>
2.0
)
?
(
5.0
*
num2
)
:
((!(
num4
>
1.0
))
?
num2
:
(
2.0
*
num2
)));
MinValue
=
Math
.
Floor
(
min
/
num5
)
*
num5
;
MaxValue
=
Math
.
Ceiling
(
max
/
num5
)
*
num5
;
}
/// <summary>
/// Counts the width of the axis y.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="font">The font.</param>
/// <returns>System.Single.</returns>
private
float
CountAxisYWidth
(
Graphics
g
,
Font
font
)
{
if
(!
_visible
)
{
return
0f
;
}
float
num
=
0f
;
if
(!
string
.
IsNullOrEmpty
(
_title
))
{
SizeF
size
=
g
.
MeasureString
(
_title
,
font
);
num
=
ControlHelper
.
ConvertSize
(
size
,
-
90f
).
Width
+
3f
;
}
if
(!
_labelVisible
||
_labels
.
Count
<
1
)
{
return
num
;
}
maxLabelHeight
=
0f
;
maxLabelWidth
=
0f
;
for
(
int
i
=
0
;
i
<
_labels
.
Count
;
i
++)
{
SizeF
sizeF
=
g
.
MeasureString
(
_labels
[
i
].
Content
,
font
);
maxLabelHeight
=
((
sizeF
.
Height
>
maxLabelHeight
)
?
sizeF
.
Height
:
maxLabelHeight
);
maxLabelWidth
=
((
sizeF
.
Width
>
maxLabelWidth
)
?
sizeF
.
Width
:
maxLabelWidth
);
}
return
num
+
maxLabelWidth
+
3f
;
}
/// <summary>
/// Counts the height of the axis x.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="font">The font.</param>
/// <returns>System.Single.</returns>
private
float
CountAxisXHeight
(
Graphics
g
,
Font
font
)
{
if
(!
_visible
)
{
return
0f
;
}
float
num
=
string
.
IsNullOrEmpty
(
_title
)
?
0f
:
(
g
.
MeasureString
(
_title
,
font
).
Height
+
3f
);
if
(!
_labelVisible
||
_labels
.
Count
<
1
)
{
return
num
;
}
maxLabelHeight
=
0f
;
maxLabelWidth
=
0f
;
for
(
int
i
=
0
;
i
<
_labels
.
Count
;
i
++)
{
SizeF
sizeF
=
g
.
MeasureString
(
_labels
[
i
].
Content
,
font
);
maxLabelHeight
=
((
sizeF
.
Height
>
maxLabelHeight
)
?
sizeF
.
Height
:
maxLabelHeight
);
maxLabelWidth
=
((
sizeF
.
Width
>
maxLabelWidth
)
?
sizeF
.
Width
:
maxLabelWidth
);
}
return
num
+
maxLabelHeight
+
3f
;
}
/// <summary>
/// Sets the labels.
/// </summary>
/// <param name="labels">The labels.</param>
/// <param name="startValue">The start value.</param>
/// <param name="valueStep">The value step.</param>
public
void
SetLabels
(
string
[]
labels
,
double
startValue
=
0.0
,
double
valueStep
=
0.1
)
{
if
(
labels
!=
null
)
{
_isCustomLabels
=
true
;
_labels
.
Clear
();
for
(
int
i
=
0
;
i
<
labels
.
Length
;
i
++)
{
_labels
.
Add
(
new
AxisLabel
(
startValue
+
(
double
)
i
*
valueStep
)
{
Content
=
labels
[
i
]
});
}
}
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
}
/// <summary>
/// Sets the labels.
/// </summary>
/// <param name="labels">The labels.</param>
/// <param name="values">The values.</param>
public
void
SetLabels
(
string
[]
labels
,
double
[]
values
)
{
if
(
labels
!=
null
&&
values
!=
null
)
{
_isCustomLabels
=
true
;
_labels
.
Clear
();
for
(
int
i
=
0
;
i
<
labels
.
Length
;
i
++)
{
_labels
.
Add
(
new
AxisLabel
(
values
[
i
])
{
Content
=
labels
[
i
]
});
}
}
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
}
/// <summary>
/// Sets the labels.
/// </summary>
/// <param name="dateTimes">The date times.</param>
/// <param name="format">The format.</param>
/// <param name="startValue">The start value.</param>
/// <param name="valueStep">The value step.</param>
public
void
SetLabels
(
DateTime
[]
dateTimes
,
string
format
=
"yyyy-MM-dd HH:mm:ss"
,
double
startValue
=
0.0
,
double
valueStep
=
0.1
)
{
if
(
dateTimes
!=
null
)
{
_isCustomLabels
=
true
;
_labels
.
Clear
();
for
(
int
i
=
0
;
i
<
dateTimes
.
Length
;
i
++)
{
_labels
.
Add
(
new
AxisLabel
(
startValue
+
(
double
)
i
*
valueStep
)
{
Content
=
dateTimes
[
i
].
ToString
(
format
)
});
}
}
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
}
/// <summary>
/// Sets the labels.
/// </summary>
/// <param name="dateTimes">The date times.</param>
/// <param name="values">The values.</param>
/// <param name="format">The format.</param>
public
void
SetLabels
(
DateTime
[]
dateTimes
,
double
[]
values
,
string
format
=
"yyyy-MM-dd HH:mm:ss"
)
{
if
(
dateTimes
!=
null
&&
values
!=
null
)
{
_isCustomLabels
=
true
;
_labels
.
Clear
();
for
(
int
i
=
0
;
i
<
dateTimes
.
Length
;
i
++)
{
_labels
.
Add
(
new
AxisLabel
(
values
[
i
])
{
Content
=
dateTimes
[
i
].
ToString
(
format
)
});
}
}
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
}
/// <summary>
/// Gets the label.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>System.String.</returns>
public
string
GetLabel
(
double
value
)
{
if
(
_isCustomLabels
)
{
IEnumerable
<
AxisLabel
>
enumerable
=
from
lab
in
_labels
where
lab
.
Value
==
value
select
lab
;
if
(
enumerable
!=
null
&&
enumerable
.
Count
()
>
0
)
{
return
enumerable
.
Last
().
Content
;
}
return
string
.
Empty
;
}
return
value
.
ToString
();
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/AxisCollection.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System.Collections.ObjectModel
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class AxisCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.Axis}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.Axis}" />
public
class
AxisCollection
:
Collection
<
Axis
>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public
UCChart
Chart
{
get
;
internal
set
;
}
/// <summary>
/// Gets the type.
/// </summary>
/// <value>The type.</value>
public
AxisType
Type
{
get
;
internal
set
;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
InsertItem
(
int
index
,
Axis
item
)
{
base
.
InsertItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Type
=
Type
;
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
SetItem
(
int
index
,
Axis
item
)
{
base
.
SetItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Type
=
Type
;
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Clears the items.
/// </summary>
protected
override
void
ClearItems
()
{
base
.
ClearItems
();
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected
override
void
RemoveItem
(
int
index
)
{
base
.
RemoveItem
(
index
);
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/AxisFormat.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisFormat.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.Drawing
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class AxisFormat.
/// </summary>
public
class
AxisFormat
{
/// <summary>
/// The title angle axis y
/// </summary>
public
const
int
TitleAngleAxisY
=
-
90
;
/// <summary>
/// The title format right axis y
/// </summary>
static
StringFormat
titleFormatRightAxisY
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Far
};
/// <summary>
/// Gets or sets the title format right axis y.
/// </summary>
/// <value>The title format right axis y.</value>
public
static
StringFormat
TitleFormatRightAxisY
{
get
{
return
titleFormatRightAxisY
;
}
set
{
titleFormatRightAxisY
=
value
;
}
}
/// <summary>
/// The title format left axis y
/// </summary>
static
StringFormat
titleFormatLeftAxisY
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Near
};
/// <summary>
/// Gets or sets the title format left axis y.
/// </summary>
/// <value>The title format left axis y.</value>
public
static
StringFormat
TitleFormatLeftAxisY
{
get
{
return
titleFormatLeftAxisY
;
}
set
{
titleFormatLeftAxisY
=
value
;
}
}
/// <summary>
/// The label format left axis y
/// </summary>
static
StringFormat
labelFormatLeftAxisY
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Far
,
LineAlignment
=
StringAlignment
.
Center
};
/// <summary>
/// Gets or sets the label format left axis y.
/// </summary>
/// <value>The label format left axis y.</value>
public
static
StringFormat
LabelFormatLeftAxisY
{
get
{
return
labelFormatLeftAxisY
;
}
set
{
labelFormatLeftAxisY
=
value
;
}
}
/// <summary>
/// The label format right axis y
/// </summary>
static
StringFormat
labelFormatRightAxisY
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Near
,
LineAlignment
=
StringAlignment
.
Center
};
/// <summary>
/// Gets or sets the label format right axis y.
/// </summary>
/// <value>The label format right axis y.</value>
public
static
StringFormat
LabelFormatRightAxisY
{
get
{
return
AxisFormat
.
labelFormatRightAxisY
;
}
set
{
AxisFormat
.
labelFormatRightAxisY
=
value
;
}
}
/// <summary>
/// The title format top axis x
/// </summary>
static
StringFormat
titleFormatTopAxisX
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Near
};
/// <summary>
/// Gets or sets the title format top axis x.
/// </summary>
/// <value>The title format top axis x.</value>
public
static
StringFormat
TitleFormatTopAxisX
{
get
{
return
AxisFormat
.
titleFormatTopAxisX
;
}
set
{
AxisFormat
.
titleFormatTopAxisX
=
value
;
}
}
/// <summary>
/// The title format bottom axis x
/// </summary>
static
StringFormat
titleFormatBottomAxisX
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Far
};
/// <summary>
/// Gets or sets the title format bottom axis x.
/// </summary>
/// <value>The title format bottom axis x.</value>
public
static
StringFormat
TitleFormatBottomAxisX
{
get
{
return
AxisFormat
.
titleFormatBottomAxisX
;
}
set
{
AxisFormat
.
titleFormatBottomAxisX
=
value
;
}
}
/// <summary>
/// The label format top axis x
/// </summary>
static
StringFormat
labelFormatTopAxisX
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Far
};
/// <summary>
/// Gets or sets the label format top axis x.
/// </summary>
/// <value>The label format top axis x.</value>
public
static
StringFormat
LabelFormatTopAxisX
{
get
{
return
AxisFormat
.
labelFormatTopAxisX
;
}
set
{
AxisFormat
.
labelFormatTopAxisX
=
value
;
}
}
/// <summary>
/// The label format bottom axis x
/// </summary>
static
StringFormat
labelFormatBottomAxisX
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Near
};
/// <summary>
/// Gets or sets the label format bottom axis x.
/// </summary>
/// <value>The label format bottom axis x.</value>
public
static
StringFormat
LabelFormatBottomAxisX
{
get
{
return
AxisFormat
.
labelFormatBottomAxisX
;
}
set
{
AxisFormat
.
labelFormatBottomAxisX
=
value
;
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/AxisPosition.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisPosition.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace
HZH_Controls.Controls
{
/// <summary>
/// Enum AxisPosition
/// </summary>
public
enum
AxisPosition
{
/// <summary>
/// The left bottom
/// </summary>
LeftBottom
,
/// <summary>
/// The right top
/// </summary>
RightTop
}
}
HZH_Controls/HZH_Controls/Controls/Charts/AxisType.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="AxisType.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace
HZH_Controls.Controls
{
/// <summary>
/// Enum AxisType
/// </summary>
public
enum
AxisType
{
/// <summary>
/// The x
/// </summary>
X
,
/// <summary>
/// The y
/// </summary>
Y
}
}
HZH_Controls/HZH_Controls/Controls/Charts/ChartPoint.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPoint.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.ComponentModel
;
using
System.Drawing
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class ChartPoint.
/// </summary>
[
TypeConverter
(
typeof
(
ExpandableObjectConverter
))]
public
class
ChartPoint
{
/// <summary>
/// The chart
/// </summary>
private
UCChart
_chart
;
/// <summary>
/// The series
/// </summary>
private
SeriesBase
_series
;
/// <summary>
/// The x
/// </summary>
private
double
_x
;
/// <summary>
/// The y
/// </summary>
private
double
_y
;
/// <summary>
/// The label
/// </summary>
private
string
_label
;
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
[
Browsable
(
false
)]
public
UCChart
Chart
{
get
{
return
_chart
;
}
internal
set
{
_chart
=
value
;
}
}
/// <summary>
/// Gets the series.
/// </summary>
/// <value>The series.</value>
[
Browsable
(
false
)]
public
SeriesBase
Series
{
get
{
return
_series
;
}
internal
set
{
_series
=
value
;
}
}
/// <summary>
/// Gets the parent axis x.
/// </summary>
/// <value>The parent axis x.</value>
[
Browsable
(
false
)]
public
Axis
ParentAxisX
{
get
{
if
(
_series
!=
null
)
{
return
_series
.
ParentAxisX
;
}
return
null
;
}
}
/// <summary>
/// Gets the parent axis y.
/// </summary>
/// <value>The parent axis y.</value>
[
Browsable
(
false
)]
public
Axis
ParentAxisY
{
get
{
if
(
_series
!=
null
)
{
return
_series
.
ParentAxisY
;
}
return
null
;
}
}
/// <summary>
/// Gets or sets the x.
/// </summary>
/// <value>The x.</value>
public
double
X
{
get
{
return
_x
;
}
set
{
if
(
_x
!=
value
)
{
_x
=
value
;
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
OnValueChanged
(
new
EventArgs
());
}
}
}
/// <summary>
/// Gets or sets the y.
/// </summary>
/// <value>The y.</value>
public
double
Y
{
get
{
return
_y
;
}
set
{
if
(
_y
!=
value
)
{
_y
=
value
;
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
OnValueChanged
(
new
EventArgs
());
}
}
}
/// <summary>
/// Gets or sets the label.
/// </summary>
/// <value>The label.</value>
public
string
Label
{
get
{
return
_label
;
}
set
{
if
(
_label
!=
value
)
{
_label
=
value
;
if
(
_chart
!=
null
)
_chart
.
Invalidate
();
OnLabelChanged
(
new
EventArgs
());
}
}
}
/// <summary>
/// Gets the left.
/// </summary>
/// <value>The left.</value>
[
Browsable
(
false
)]
public
int
Left
{
get
{
int
num
=
(
_chart
!=
null
)
?
_chart
.
OffsetX
:
0
;
return
(
int
)(
Series
.
CountLeft
(
X
)
+
(
float
)
num
);
}
}
/// <summary>
/// Gets the top.
/// </summary>
/// <value>The top.</value>
[
Browsable
(
false
)]
public
int
Top
{
get
{
int
num
=
(
_chart
!=
null
)
?
_chart
.
OffsetY
:
0
;
return
(
int
)(
Series
.
CountTop
(
Y
)
+
(
float
)
num
);
}
}
/// <summary>
/// Gets the location.
/// </summary>
/// <value>The location.</value>
[
Browsable
(
false
)]
public
Point
Location
{
get
{
return
new
Point
(
Left
,
Top
);
}
}
/// <summary>
/// Occurs when [value changed].
/// </summary>
public
event
EventHandler
ValueChanged
;
/// <summary>
/// Occurs when [label changed].
/// </summary>
public
event
EventHandler
LabelChanged
;
/// <summary>
/// Initializes a new instance of the <see cref="ChartPoint"/> class.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
public
ChartPoint
(
double
x
,
double
y
)
{
_x
=
x
;
_y
=
y
;
}
/// <summary>
/// Initializes a new instance of the <see cref="ChartPoint"/> class.
/// </summary>
public
ChartPoint
()
:
this
(
0.0
,
0.0
)
{
}
/// <summary>
/// Handles the <see cref="E:ValueChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected
void
OnValueChanged
(
EventArgs
e
)
{
if
(
this
.
ValueChanged
!=
null
)
this
.
ValueChanged
.
Invoke
(
this
,
e
);
}
/// <summary>
/// Handles the <see cref="E:LabelChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected
void
OnLabelChanged
(
EventArgs
e
)
{
if
(
this
.
LabelChanged
!=
null
)
this
.
LabelChanged
.
Invoke
(
this
,
e
);
}
/// <summary>
/// Gets the label from axis x.
/// </summary>
/// <returns>System.String.</returns>
public
string
GetLabelFromAxisX
()
{
if
(
ParentAxisX
!=
null
)
{
return
ParentAxisX
.
GetLabel
(
_x
);
}
return
null
;
}
/// <summary>
/// Gets the label from axis y.
/// </summary>
/// <returns>System.String.</returns>
public
string
GetLabelFromAxisY
()
{
if
(
ParentAxisY
!=
null
)
{
return
ParentAxisY
.
GetLabel
(
_y
);
}
return
null
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointCollection.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System.Collections.ObjectModel
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class ChartPointCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.ChartPoint}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.ChartPoint}" />
public
class
ChartPointCollection
:
Collection
<
ChartPoint
>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public
UCChart
Chart
{
get
;
internal
set
;
}
/// <summary>
/// Gets the series.
/// </summary>
/// <value>The series.</value>
public
SeriesBase
Series
{
get
;
internal
set
;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
InsertItem
(
int
index
,
ChartPoint
item
)
{
base
.
InsertItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Series
=
Series
;
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
SetItem
(
int
index
,
ChartPoint
item
)
{
base
.
SetItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Series
=
Series
;
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Clears the items.
/// </summary>
protected
override
void
ClearItems
()
{
base
.
ClearItems
();
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected
override
void
RemoveItem
(
int
index
)
{
base
.
RemoveItem
(
index
);
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointEventArgs.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointEventArgs.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
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class ChartPointEventArgs.
/// Implements the <see cref="System.EventArgs" />
/// </summary>
/// <seealso cref="System.EventArgs" />
public
class
ChartPointEventArgs
:
EventArgs
{
/// <summary>
/// Gets the point.
/// </summary>
/// <value>The point.</value>
public
ChartPoint
[]
Point
{
get
;
private
set
;
}
/// <summary>
/// Gets or sets the content.
/// </summary>
/// <value>The content.</value>
public
string
Content
{
get
;
set
;
}
/// <summary>
/// Initializes a new instance of the <see cref="ChartPointEventArgs"/> class.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="content">The content.</param>
public
ChartPointEventArgs
(
ChartPoint
[]
point
=
null
,
string
content
=
null
)
{
Point
=
point
;
Content
=
content
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/ChartPointEventHandler.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ChartPointEventHandler.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace
HZH_Controls.Controls
{
/// <summary>
/// Delegate ChartPointEventHandler
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="ChartPointEventArgs"/> instance containing the event data.</param>
public
delegate
void
ChartPointEventHandler
(
object
sender
,
ChartPointEventArgs
e
);
}
HZH_Controls/HZH_Controls/Controls/Charts/CurveChart/CurveItem.cs
0 → 100644
查看文件 @
44b6ae6
using
System.Drawing
;
namespace
HZH_Controls.Controls
{
public
class
CurveItem
{
public
float
[]
Data
=
null
;
public
string
[]
MarkText
=
null
;
public
float
LineThickness
{
get
;
set
;
}
public
bool
IsSmoothCurve
{
get
;
set
;
}
public
Color
LineColor
{
get
;
set
;
}
public
bool
IsLeftFrame
{
get
;
set
;
}
public
bool
Visible
{
get
;
set
;
}
public
bool
LineRenderVisiable
{
get
;
set
;
}
public
RectangleF
TitleRegion
{
get
;
set
;
}
private
string
renderFormat
=
"{0}"
;
public
string
RenderFormat
{
get
{
return
renderFormat
;
}
set
{
renderFormat
=
value
;
}
}
public
CurveItem
()
{
LineThickness
=
1f
;
IsLeftFrame
=
true
;
Visible
=
true
;
LineRenderVisiable
=
true
;
TitleRegion
=
new
RectangleF
(
0f
,
0f
,
0f
,
0f
);
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/CurveChart/UCCurve.cs
0 → 100644
查看文件 @
44b6ae6
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-23
//
// ***********************************************************************
// <copyright file="UCCurve.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Text
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class UCCurve.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public
class
UCCurve
:
UserControl
{
/// <summary>
/// The value count maximum
/// </summary>
private
const
int
value_count_max
=
4096
;
/// <summary>
/// The value maximum left
/// </summary>
private
float
value_max_left
=
100f
;
/// <summary>
/// The value minimum left
/// </summary>
private
float
value_min_left
=
0f
;
/// <summary>
/// The value maximum right
/// </summary>
private
float
value_max_right
=
100f
;
/// <summary>
/// The value minimum right
/// </summary>
private
float
value_min_right
=
0f
;
/// <summary>
/// The value segment
/// </summary>
private
int
value_Segment
=
5
;
/// <summary>
/// The value is abscissa strech
/// </summary>
private
bool
value_IsAbscissaStrech
=
false
;
/// <summary>
/// The value strech data count maximum
/// </summary>
private
int
value_StrechDataCountMax
=
300
;
/// <summary>
/// The value is render dash line
/// </summary>
private
bool
value_IsRenderDashLine
=
true
;
/// <summary>
/// The text format
/// </summary>
private
string
textFormat
=
"HH:mm"
;
/// <summary>
/// The value interval abscissa text
/// </summary>
private
int
value_IntervalAbscissaText
=
100
;
/// <summary>
/// The random
/// </summary>
private
Random
random
=
null
;
/// <summary>
/// The value title
/// </summary>
private
string
value_title
=
""
;
/// <summary>
/// The left right
/// </summary>
private
int
leftRight
=
50
;
/// <summary>
/// Up dowm
/// </summary>
private
int
upDowm
=
50
;
/// <summary>
/// The data list
/// </summary>
private
Dictionary
<
string
,
CurveItem
>
data_list
=
null
;
/// <summary>
/// The data text
/// </summary>
private
string
[]
data_text
=
null
;
/// <summary>
/// The auxiliary lines
/// </summary>
private
List
<
AuxiliaryLine
>
auxiliary_lines
;
/// <summary>
/// The auxiliary labels
/// </summary>
private
List
<
AuxiliaryLable
>
auxiliary_Labels
;
/// <summary>
/// The mark texts
/// </summary>
private
List
<
MarkText
>
MarkTexts
;
/// <summary>
/// The font size9
/// </summary>
private
Font
font_size9
=
null
;
/// <summary>
/// The font size12
/// </summary>
private
Font
font_size12
=
null
;
/// <summary>
/// The brush deep
/// </summary>
private
Brush
brush_deep
=
null
;
/// <summary>
/// The pen normal
/// </summary>
private
Pen
pen_normal
=
null
;
/// <summary>
/// The pen dash
/// </summary>
private
Pen
pen_dash
=
null
;
/// <summary>
/// The color normal
/// </summary>
private
Color
color_normal
=
Color
.
DeepPink
;
/// <summary>
/// The color deep
/// </summary>
private
Color
color_deep
=
Color
.
DimGray
;
/// <summary>
/// The color dash
/// </summary>
private
Color
color_dash
=
Color
.
FromArgb
(
232
,
232
,
232
);
/// <summary>
/// The color mark font
/// </summary>
private
Color
color_mark_font
=
Color
.
DodgerBlue
;
/// <summary>
/// The brush mark font
/// </summary>
private
Brush
brush_mark_font
=
Brushes
.
DodgerBlue
;
/// <summary>
/// The format left
/// </summary>
private
StringFormat
format_left
=
null
;
/// <summary>
/// The format right
/// </summary>
private
StringFormat
format_right
=
null
;
/// <summary>
/// The format center
/// </summary>
private
StringFormat
format_center
=
null
;
/// <summary>
/// The is render right coordinate
/// </summary>
private
bool
isRenderRightCoordinate
=
true
;
/// <summary>
/// The curve name width
/// </summary>
private
int
curveNameWidth
=
100
;
/// <summary>
/// The components
/// </summary>
private
IContainer
components
=
null
;
/// <summary>
/// 获取或设置控件的背景色。
/// </summary>
/// <value>The color of the back.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[
Browsable
(
true
)]
[
Description
(
"获取或设置控件的背景色"
)]
[
Category
(
"自定义"
)]
[
DefaultValue
(
typeof
(
Color
),
"Transparent"
)]
[
EditorBrowsable
(
EditorBrowsableState
.
Always
)]
public
override
Color
BackColor
{
get
{
return
base
.
BackColor
;
}
set
{
base
.
BackColor
=
value
;
}
}
/// <summary>
/// Gets or sets the value maximum left.
/// </summary>
/// <value>The value maximum left.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图形的左纵坐标的最大值,该值必须大于最小值"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
100f
)]
public
float
ValueMaxLeft
{
get
{
return
value_max_left
;
}
set
{
value_max_left
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the value minimum left.
/// </summary>
/// <value>The value minimum left.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图形的左纵坐标的最小值,该值必须小于最大值"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
0f
)]
public
float
ValueMinLeft
{
get
{
return
value_min_left
;
}
set
{
value_min_left
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the value maximum right.
/// </summary>
/// <value>The value maximum right.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图形的右纵坐标的最大值,该值必须大于最小值"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
100f
)]
public
float
ValueMaxRight
{
get
{
return
value_max_right
;
}
set
{
value_max_right
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the value minimum right.
/// </summary>
/// <value>The value minimum right.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图形的右纵坐标的最小值,该值必须小于最大值"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
0f
)]
public
float
ValueMinRight
{
get
{
return
value_min_right
;
}
set
{
value_min_right
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the value segment.
/// </summary>
/// <value>The value segment.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图形的纵轴分段数"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
5
)]
public
int
ValueSegment
{
get
{
return
value_Segment
;
}
set
{
value_Segment
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is abscissa strech.
/// </summary>
/// <value><c>true</c> if this instance is abscissa strech; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置所有的数据是否强制在一个界面里显示"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
false
)]
public
bool
IsAbscissaStrech
{
get
{
return
value_IsAbscissaStrech
;
}
set
{
value_IsAbscissaStrech
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the strech data count maximum.
/// </summary>
/// <value>The strech data count maximum.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置拉伸模式下的最大数据量"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
300
)]
public
int
StrechDataCountMax
{
get
{
return
value_StrechDataCountMax
;
}
set
{
value_StrechDataCountMax
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is render dash line.
/// </summary>
/// <value><c>true</c> if this instance is render dash line; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置虚线是否进行显示"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
true
)]
public
bool
IsRenderDashLine
{
get
{
return
value_IsRenderDashLine
;
}
set
{
value_IsRenderDashLine
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the color lines and text.
/// </summary>
/// <value>The color lines and text.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置坐标轴及相关信息文本的颜色"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
typeof
(
Color
),
"DimGray"
)]
public
Color
ColorLinesAndText
{
get
{
return
color_deep
;
}
set
{
color_deep
=
value
;
InitializationColor
();
Invalidate
();
}
}
/// <summary>
/// Gets or sets the color dash lines.
/// </summary>
/// <value>The color dash lines.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置虚线的颜色"
)]
[
Browsable
(
true
)]
public
Color
ColorDashLines
{
get
{
return
color_dash
;
}
set
{
color_dash
=
value
;
if
(
pen_dash
!=
null
)
pen_dash
.
Dispose
();
pen_dash
=
new
Pen
(
color_dash
);
pen_dash
.
DashStyle
=
DashStyle
.
Custom
;
pen_dash
.
DashPattern
=
new
float
[
2
]
{
5f
,
5f
};
Invalidate
();
}
}
/// <summary>
/// Gets or sets the interval abscissa text.
/// </summary>
/// <value>The interval abscissa text.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置纵向虚线的分隔情况,单位为多少个数据"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
100
)]
public
int
IntervalAbscissaText
{
get
{
return
value_IntervalAbscissaText
;
}
set
{
value_IntervalAbscissaText
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the text add format.
/// </summary>
/// <value>The text add format.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置实时数据新增时文本相对应于时间的格式化字符串,默认HH:mm"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
"HH:mm"
)]
public
string
TextAddFormat
{
get
{
return
textFormat
;
}
set
{
textFormat
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置图标的标题信息"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
""
)]
public
string
Title
{
get
{
return
value_title
;
}
set
{
value_title
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether this instance is render right coordinate.
/// </summary>
/// <value><c>true</c> if this instance is render right coordinate; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"获取或设置是否显示右侧的坐标系信息"
)]
[
Browsable
(
true
)]
[
DefaultValue
(
true
)]
public
bool
IsRenderRightCoordinate
{
get
{
return
isRenderRightCoordinate
;
}
set
{
isRenderRightCoordinate
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the width of the curve name.
/// </summary>
/// <value>The width of the curve name.</value>
[
Browsable
(
true
)]
[
Description
(
"获取或设置曲线名称的布局宽度"
)]
[
Category
(
"自定义"
)]
[
DefaultValue
(
100
)]
public
int
CurveNameWidth
{
get
{
return
curveNameWidth
;
}
set
{
if
(
value
>
10
)
{
curveNameWidth
=
value
;
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="UCCurve" /> class.
/// </summary>
public
UCCurve
()
{
InitializeComponent
();
random
=
new
Random
();
data_list
=
new
Dictionary
<
string
,
CurveItem
>();
auxiliary_lines
=
new
List
<
AuxiliaryLine
>();
MarkTexts
=
new
List
<
MarkText
>();
auxiliary_Labels
=
new
List
<
AuxiliaryLable
>();
format_left
=
new
StringFormat
{
LineAlignment
=
StringAlignment
.
Center
,
Alignment
=
StringAlignment
.
Near
};
format_right
=
new
StringFormat
{
LineAlignment
=
StringAlignment
.
Center
,
Alignment
=
StringAlignment
.
Far
};
format_center
=
new
StringFormat
{
LineAlignment
=
StringAlignment
.
Center
,
Alignment
=
StringAlignment
.
Center
};
font_size9
=
new
Font
(
"微软雅黑"
,
9f
);
font_size12
=
new
Font
(
"微软雅黑"
,
12f
);
InitializationColor
();
pen_dash
=
new
Pen
(
color_deep
);
pen_dash
.
DashStyle
=
DashStyle
.
Custom
;
pen_dash
.
DashPattern
=
new
float
[
2
]
{
5f
,
5f
};
SetStyle
(
ControlStyles
.
UserPaint
|
ControlStyles
.
SupportsTransparentBackColor
,
true
);
SetStyle
(
ControlStyles
.
ResizeRedraw
,
true
);
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
,
true
);
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
}
/// <summary>
/// Initializations the color.
/// </summary>
private
void
InitializationColor
()
{
if
(
pen_normal
!=
null
)
pen_normal
.
Dispose
();
if
(
brush_deep
!=
null
)
brush_deep
.
Dispose
();
pen_normal
=
new
Pen
(
color_deep
);
brush_deep
=
new
SolidBrush
(
color_deep
);
}
/// <summary>
/// Sets the curve text.
/// </summary>
/// <param name="descriptions">The descriptions.</param>
public
void
SetCurveText
(
string
[]
descriptions
)
{
data_text
=
descriptions
;
Invalidate
();
}
/// <summary>
/// Sets the left curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
public
void
SetLeftCurve
(
string
key
,
float
[]
data
,
Color
?
lineColor
=
null
)
{
SetCurve
(
key
,
true
,
data
,
lineColor
,
1f
,
false
);
}
/// <summary>
/// Sets the left curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public
void
SetLeftCurve
(
string
key
,
float
[]
data
,
Color
?
lineColor
,
bool
isSmooth
=
false
)
{
SetCurve
(
key
,
true
,
data
,
lineColor
,
1f
,
isSmooth
);
}
/// <summary>
/// Sets the right curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
public
void
SetRightCurve
(
string
key
,
float
[]
data
,
Color
?
lineColor
=
null
)
{
SetCurve
(
key
,
false
,
data
,
lineColor
,
1f
,
false
);
}
/// <summary>
/// Sets the right curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public
void
SetRightCurve
(
string
key
,
float
[]
data
,
Color
?
lineColor
,
bool
isSmooth
=
false
)
{
SetCurve
(
key
,
false
,
data
,
lineColor
,
1f
,
isSmooth
);
}
/// <summary>
/// Sets the curve.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="isLeft">if set to <c>true</c> [is left].</param>
/// <param name="data">The data.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="isSmooth">if set to <c>true</c> [is smooth].</param>
public
void
SetCurve
(
string
key
,
bool
isLeft
,
float
[]
data
,
Color
?
lineColor
,
float
thickness
,
bool
isSmooth
)
{
if
(
data_list
.
ContainsKey
(
key
))
{
if
(
data
==
null
)
{
data
=
new
float
[
0
];
}
data_list
[
key
].
Data
=
data
;
}
else
{
if
(
data
==
null
)
{
data
=
new
float
[
0
];
}
data_list
.
Add
(
key
,
new
CurveItem
{
Data
=
data
,
MarkText
=
new
string
[
data
.
Length
],
LineThickness
=
thickness
,
LineColor
=
lineColor
??
ControlHelper
.
Colors
[
data_list
.
Count
+
13
],
IsLeftFrame
=
isLeft
,
IsSmoothCurve
=
isSmooth
});
if
(
data_text
==
null
)
{
data_text
=
new
string
[
data
.
Length
];
}
}
Invalidate
();
}
/// <summary>
/// Removes the curve.
/// </summary>
/// <param name="key">The key.</param>
public
void
RemoveCurve
(
string
key
)
{
if
(
data_list
.
ContainsKey
(
key
))
{
data_list
.
Remove
(
key
);
}
if
(
data_list
.
Count
==
0
)
{
data_text
=
new
string
[
0
];
}
Invalidate
();
}
/// <summary>
/// Removes all curve.
/// </summary>
public
void
RemoveAllCurve
()
{
int
count
=
data_list
.
Count
;
data_list
.
Clear
();
if
(
data_list
.
Count
==
0
)
{
data_text
=
new
string
[
0
];
}
if
(
count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Removes all curve data.
/// </summary>
public
void
RemoveAllCurveData
()
{
int
count
=
data_list
.
Count
;
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item
in
data_list
)
{
item
.
Value
.
Data
=
new
float
[
0
];
item
.
Value
.
MarkText
=
new
string
[
0
];
}
data_text
=
new
string
[
0
];
if
(
count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Gets the curve item.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>CurveItem.</returns>
public
CurveItem
GetCurveItem
(
string
key
)
{
if
(
data_list
.
ContainsKey
(
key
))
{
return
data_list
[
key
];
}
return
null
;
}
/// <summary>
/// Saves to bitmap.
/// </summary>
/// <returns>Bitmap.</returns>
public
Bitmap
SaveToBitmap
()
{
return
SaveToBitmap
(
base
.
Width
,
base
.
Height
);
}
/// <summary>
/// Saves to bitmap.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <returns>Bitmap.</returns>
public
Bitmap
SaveToBitmap
(
int
width
,
int
height
)
{
Bitmap
bitmap
=
new
Bitmap
(
width
,
height
);
Graphics
graphics
=
Graphics
.
FromImage
(
bitmap
);
OnPaint
(
new
PaintEventArgs
(
graphics
,
new
Rectangle
(
0
,
0
,
width
,
height
)));
return
bitmap
;
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <param name="isUpdateUI">if set to <c>true</c> [is update UI].</param>
private
void
AddCurveData
(
string
key
,
float
[]
values
,
string
[]
markTexts
,
bool
isUpdateUI
)
{
if
((
values
!=
null
&&
values
.
Length
<
1
)
||
!
data_list
.
ContainsKey
(
key
))
{
return
;
}
CurveItem
CurveItem
=
data_list
[
key
];
if
(
CurveItem
.
Data
!=
null
)
{
if
(
value_IsAbscissaStrech
)
{
ControlHelper
.
AddArrayData
(
ref
CurveItem
.
Data
,
values
,
value_StrechDataCountMax
);
ControlHelper
.
AddArrayData
(
ref
CurveItem
.
MarkText
,
markTexts
,
value_StrechDataCountMax
);
}
else
{
ControlHelper
.
AddArrayData
(
ref
CurveItem
.
Data
,
values
,
4096
);
ControlHelper
.
AddArrayData
(
ref
CurveItem
.
MarkText
,
markTexts
,
4096
);
}
if
(
isUpdateUI
)
{
Invalidate
();
}
}
}
/// <summary>
/// Adds the curve time.
/// </summary>
/// <param name="count">The count.</param>
private
void
AddCurveTime
(
int
count
)
{
AddCurveTime
(
count
,
DateTime
.
Now
.
ToString
(
textFormat
));
}
/// <summary>
/// Adds the curve time.
/// </summary>
/// <param name="count">The count.</param>
/// <param name="text">The text.</param>
private
void
AddCurveTime
(
int
count
,
string
text
)
{
if
(
data_text
!=
null
)
{
string
[]
array
=
new
string
[
count
];
for
(
int
i
=
0
;
i
<
array
.
Length
;
i
++)
{
array
[
i
]
=
text
;
}
if
(
value_IsAbscissaStrech
)
{
ControlHelper
.
AddArrayData
(
ref
data_text
,
array
,
value_StrechDataCountMax
);
}
else
{
ControlHelper
.
AddArrayData
(
ref
data_text
,
array
,
4096
);
}
}
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
public
void
AddCurveData
(
string
key
,
float
value
)
{
AddCurveData
(
key
,
new
float
[
1
]
{
value
});
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
/// <param name="markText">The mark text.</param>
public
void
AddCurveData
(
string
key
,
float
value
,
string
markText
)
{
AddCurveData
(
key
,
new
float
[
1
]
{
value
},
new
string
[
1
]
{
markText
});
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
public
void
AddCurveData
(
string
key
,
float
[]
values
)
{
AddCurveData
(
key
,
values
,
null
);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
public
void
AddCurveData
(
string
key
,
float
[]
values
,
string
[]
markTexts
)
{
if
(
markTexts
==
null
)
{
markTexts
=
new
string
[
values
.
Length
];
}
AddCurveData
(
key
,
values
,
markTexts
,
false
);
if
(
values
!=
null
&&
values
.
Length
!=
0
)
{
AddCurveTime
(
values
.
Length
);
}
Invalidate
();
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
public
void
AddCurveData
(
string
[]
keys
,
float
[]
values
)
{
AddCurveData
(
keys
,
values
,
null
);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="axisText">The axis text.</param>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
public
void
AddCurveData
(
string
axisText
,
string
[]
keys
,
float
[]
values
)
{
AddCurveData
(
axisText
,
keys
,
values
,
null
);
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <exception cref="ArgumentNullException">keys
/// or
/// values</exception>
/// <exception cref="Exception">两个参数的数组长度不一致。
/// or
/// 两个参数的数组长度不一致。</exception>
public
void
AddCurveData
(
string
[]
keys
,
float
[]
values
,
string
[]
markTexts
)
{
if
(
keys
==
null
)
{
throw
new
ArgumentNullException
(
"keys"
);
}
if
(
values
==
null
)
{
throw
new
ArgumentNullException
(
"values"
);
}
if
(
markTexts
==
null
)
{
markTexts
=
new
string
[
keys
.
Length
];
}
if
(
keys
.
Length
!=
values
.
Length
)
{
throw
new
Exception
(
"两个参数的数组长度不一致。"
);
}
if
(
keys
.
Length
!=
markTexts
.
Length
)
{
throw
new
Exception
(
"两个参数的数组长度不一致。"
);
}
for
(
int
i
=
0
;
i
<
keys
.
Length
;
i
++)
{
AddCurveData
(
keys
[
i
],
new
float
[
1
]
{
values
[
i
]
},
new
string
[
1
]
{
markTexts
[
i
]
},
false
);
}
AddCurveTime
(
1
);
Invalidate
();
}
/// <summary>
/// Adds the curve data.
/// </summary>
/// <param name="axisText">The axis text.</param>
/// <param name="keys">The keys.</param>
/// <param name="values">The values.</param>
/// <param name="markTexts">The mark texts.</param>
/// <exception cref="ArgumentNullException">keys
/// or
/// values</exception>
/// <exception cref="Exception">两个参数的数组长度不一致。
/// or
/// 两个参数的数组长度不一致。</exception>
public
void
AddCurveData
(
string
axisText
,
string
[]
keys
,
float
[]
values
,
string
[]
markTexts
)
{
if
(
keys
==
null
)
{
throw
new
ArgumentNullException
(
"keys"
);
}
if
(
values
==
null
)
{
throw
new
ArgumentNullException
(
"values"
);
}
if
(
markTexts
==
null
)
{
markTexts
=
new
string
[
keys
.
Length
];
}
if
(
keys
.
Length
!=
values
.
Length
)
{
throw
new
Exception
(
"两个参数的数组长度不一致。"
);
}
if
(
keys
.
Length
!=
markTexts
.
Length
)
{
throw
new
Exception
(
"两个参数的数组长度不一致。"
);
}
for
(
int
i
=
0
;
i
<
keys
.
Length
;
i
++)
{
AddCurveData
(
keys
[
i
],
new
float
[
1
]
{
values
[
i
]
},
new
string
[
1
]
{
markTexts
[
i
]
},
false
);
}
AddCurveTime
(
1
,
axisText
);
Invalidate
();
}
/// <summary>
/// Sets the curve visible.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="visible">if set to <c>true</c> [visible].</param>
public
void
SetCurveVisible
(
string
key
,
bool
visible
)
{
if
(
data_list
.
ContainsKey
(
key
))
{
CurveItem
CurveItem
=
data_list
[
key
];
CurveItem
.
Visible
=
visible
;
Invalidate
();
}
}
/// <summary>
/// Sets the curve visible.
/// </summary>
/// <param name="keys">The keys.</param>
/// <param name="visible">if set to <c>true</c> [visible].</param>
public
void
SetCurveVisible
(
string
[]
keys
,
bool
visible
)
{
foreach
(
string
key
in
keys
)
{
if
(
data_list
.
ContainsKey
(
key
))
{
CurveItem
CurveItem
=
data_list
[
key
];
CurveItem
.
Visible
=
visible
;
}
}
Invalidate
();
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public
void
AddLeftAuxiliary
(
float
value
)
{
AddLeftAuxiliary
(
value
,
ColorLinesAndText
);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
public
void
AddLeftAuxiliary
(
float
value
,
Color
lineColor
)
{
AddLeftAuxiliary
(
value
,
lineColor
,
1f
,
true
);
}
/// <summary>
/// Adds the left auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
public
void
AddLeftAuxiliary
(
float
value
,
Color
lineColor
,
float
lineThickness
,
bool
isDashLine
)
{
AddAuxiliary
(
value
,
lineColor
,
lineThickness
,
isDashLine
,
true
);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public
void
AddRightAuxiliary
(
float
value
)
{
AddRightAuxiliary
(
value
,
ColorLinesAndText
);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
public
void
AddRightAuxiliary
(
float
value
,
Color
lineColor
)
{
AddRightAuxiliary
(
value
,
lineColor
,
1f
,
true
);
}
/// <summary>
/// Adds the right auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
public
void
AddRightAuxiliary
(
float
value
,
Color
lineColor
,
float
lineThickness
,
bool
isDashLine
)
{
AddAuxiliary
(
value
,
lineColor
,
lineThickness
,
isDashLine
,
false
);
}
/// <summary>
/// Adds the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="lineColor">Color of the line.</param>
/// <param name="lineThickness">The line thickness.</param>
/// <param name="isDashLine">if set to <c>true</c> [is dash line].</param>
/// <param name="isLeft">if set to <c>true</c> [is left].</param>
private
void
AddAuxiliary
(
float
value
,
Color
lineColor
,
float
lineThickness
,
bool
isDashLine
,
bool
isLeft
)
{
auxiliary_lines
.
Add
(
new
AuxiliaryLine
{
Value
=
value
,
LineColor
=
lineColor
,
PenDash
=
new
Pen
(
lineColor
)
{
DashStyle
=
DashStyle
.
Custom
,
DashPattern
=
new
float
[
2
]
{
5f
,
5f
}
},
PenSolid
=
new
Pen
(
lineColor
),
IsDashStyle
=
isDashLine
,
IsLeftFrame
=
isLeft
,
LineThickness
=
lineThickness
,
LineTextBrush
=
new
SolidBrush
(
lineColor
)
});
Invalidate
();
}
/// <summary>
/// Removes the auxiliary.
/// </summary>
/// <param name="value">The value.</param>
public
void
RemoveAuxiliary
(
float
value
)
{
int
num
=
0
;
for
(
int
num2
=
auxiliary_lines
.
Count
-
1
;
num2
>=
0
;
num2
--)
{
if
(
auxiliary_lines
[
num2
].
Value
==
value
)
{
auxiliary_lines
[
num2
].
Dispose
();
auxiliary_lines
.
RemoveAt
(
num2
);
num
++;
}
}
if
(
num
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Removes all auxiliary.
/// </summary>
public
void
RemoveAllAuxiliary
()
{
int
count
=
auxiliary_lines
.
Count
;
auxiliary_lines
.
Clear
();
if
(
count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Adds the auxiliary label.
/// </summary>
/// <param name="auxiliaryLable">The auxiliary lable.</param>
public
void
AddAuxiliaryLabel
(
AuxiliaryLable
auxiliaryLable
)
{
auxiliary_Labels
.
Add
(
auxiliaryLable
);
}
/// <summary>
/// Removes the auxiliary lable.
/// </summary>
/// <param name="auxiliaryLable">The auxiliary lable.</param>
public
void
RemoveAuxiliaryLable
(
AuxiliaryLable
auxiliaryLable
)
{
if
(
auxiliary_Labels
.
Remove
(
auxiliaryLable
))
{
Invalidate
();
}
}
/// <summary>
/// Removes all auxiliary lable.
/// </summary>
public
void
RemoveAllAuxiliaryLable
()
{
int
count
=
auxiliary_Labels
.
Count
;
auxiliary_Labels
.
Clear
();
if
(
count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Adds the mark text.
/// </summary>
/// <param name="markText">The mark text.</param>
public
void
AddMarkText
(
MarkText
markText
)
{
MarkTexts
.
Add
(
markText
);
if
(
data_list
.
Count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Adds the mark text.
/// </summary>
/// <param name="strCurveKey">The string curve key.</param>
/// <param name="intValueIndex">Index of the int value.</param>
/// <param name="strText">The string text.</param>
/// <param name="textColor">Color of the text.</param>
public
void
AddMarkText
(
string
strCurveKey
,
int
intValueIndex
,
string
strText
,
Color
?
textColor
=
null
)
{
AddMarkText
(
new
MarkText
()
{
CurveKey
=
strCurveKey
,
PositionStyle
=
MarkTextPositionStyle
.
Auto
,
Text
=
strText
,
TextColor
=
textColor
,
Index
=
intValueIndex
});
}
/// <summary>
/// Removes the mark text.
/// </summary>
/// <param name="markText">The mark text.</param>
public
void
RemoveMarkText
(
MarkText
markText
)
{
MarkTexts
.
Remove
(
markText
);
if
(
data_list
.
Count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// Removes all mark text.
/// </summary>
public
void
RemoveAllMarkText
()
{
MarkTexts
.
Clear
();
if
(
data_list
.
Count
>
0
)
{
Invalidate
();
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseMove" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
{
base
.
OnMouseMove
(
e
);
bool
flag
=
false
;
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item
in
data_list
)
{
if
(
item
.
Value
.
TitleRegion
.
Contains
(
e
.
Location
))
{
flag
=
true
;
break
;
}
}
Cursor
=
(
flag
?
Cursors
.
Hand
:
Cursors
.
Arrow
);
}
/// <summary>
/// Handles the <see cref="E:MouseDown" /> event.
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseDown
(
MouseEventArgs
e
)
{
base
.
OnMouseDown
(
e
);
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item
in
data_list
)
{
if
(
item
.
Value
.
TitleRegion
.
Contains
(
e
.
Location
))
{
item
.
Value
.
LineRenderVisiable
=
!
item
.
Value
.
LineRenderVisiable
;
Invalidate
();
break
;
}
}
}
/// <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
)
{
try
{
Graphics
graphics
=
e
.
Graphics
;
graphics
.
SetGDIHigh
();
if
(
BackColor
!=
Color
.
Transparent
)
{
graphics
.
Clear
(
BackColor
);
}
int
width
=
base
.
Width
;
int
height
=
base
.
Height
;
if
(
width
<
120
||
height
<
60
)
{
return
;
}
Point
[]
array
=
new
Point
[
4
]
{
new
Point
(
leftRight
-
1
,
upDowm
-
8
),
new
Point
(
leftRight
-
1
,
height
-
upDowm
),
new
Point
(
width
-
leftRight
,
height
-
upDowm
),
new
Point
(
width
-
leftRight
,
upDowm
-
8
)
};
graphics
.
DrawLine
(
pen_normal
,
array
[
0
],
array
[
1
]);
graphics
.
DrawLine
(
pen_normal
,
array
[
1
],
array
[
2
]);
if
(
isRenderRightCoordinate
)
{
graphics
.
DrawLine
(
pen_normal
,
array
[
2
],
array
[
3
]);
}
if
(!
string
.
IsNullOrEmpty
(
value_title
))
{
graphics
.
DrawString
(
value_title
,
font_size9
,
brush_deep
,
new
Rectangle
(
0
,
0
,
width
-
1
,
20
),
format_center
);
}
if
(
data_list
.
Count
>
0
)
{
float
num
=
leftRight
+
10
;
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item
in
data_list
)
{
if
(
item
.
Value
.
Visible
)
{
var
titleSize
=
graphics
.
MeasureString
(
item
.
Key
,
Font
);
SolidBrush
solidBrush
=
item
.
Value
.
LineRenderVisiable
?
new
SolidBrush
(
item
.
Value
.
LineColor
)
:
new
SolidBrush
(
Color
.
FromArgb
(
80
,
item
.
Value
.
LineColor
));
graphics
.
FillRectangle
(
solidBrush
,
num
+
8f
,
24f
,
20f
,
14f
);
graphics
.
DrawString
(
item
.
Key
,
Font
,
solidBrush
,
new
PointF
(
num
+
30f
,
24f
+(
14
-
titleSize
.
Height
)
/
2
));
item
.
Value
.
TitleRegion
=
new
RectangleF
(
num
,
24f
,
60f
,
18f
);
solidBrush
.
Dispose
();
num
+=
titleSize
.
Width
+
30
;
}
}
}
for
(
int
i
=
0
;
i
<
auxiliary_Labels
.
Count
;
i
++)
{
if
(!
string
.
IsNullOrEmpty
(
auxiliary_Labels
[
i
].
Text
))
{
int
num2
=
(
auxiliary_Labels
[
i
].
LocationX
>
1f
)
?
((
int
)
auxiliary_Labels
[
i
].
LocationX
)
:
((
int
)(
auxiliary_Labels
[
i
].
LocationX
*
(
float
)
width
));
int
num3
=
(
int
)
graphics
.
MeasureString
(
auxiliary_Labels
[
i
].
Text
,
Font
).
Width
+
3
;
Point
[]
points
=
new
Point
[
6
]
{
new
Point
(
num2
,
11
),
new
Point
(
num2
+
10
,
20
),
new
Point
(
num2
+
num3
+
10
,
20
),
new
Point
(
num2
+
num3
+
10
,
0
),
new
Point
(
num2
+
10
,
0
),
new
Point
(
num2
,
11
)
};
graphics
.
FillPolygon
(
auxiliary_Labels
[
i
].
TextBack
,
points
);
graphics
.
DrawString
(
auxiliary_Labels
[
i
].
Text
,
Font
,
auxiliary_Labels
[
i
].
TextBrush
,
new
Rectangle
(
num2
+
7
,
0
,
num3
+
3
,
20
),
format_center
);
}
}
ControlHelper
.
PaintTriangle
(
graphics
,
brush_deep
,
new
Point
(
leftRight
-
1
,
upDowm
-
8
),
4
,
GraphDirection
.
Upward
);
if
(
isRenderRightCoordinate
)
{
ControlHelper
.
PaintTriangle
(
graphics
,
brush_deep
,
new
Point
(
width
-
leftRight
,
upDowm
-
8
),
4
,
GraphDirection
.
Upward
);
}
for
(
int
j
=
0
;
j
<
auxiliary_lines
.
Count
;
j
++)
{
if
(
auxiliary_lines
[
j
].
IsLeftFrame
)
{
auxiliary_lines
[
j
].
PaintValue
=
ControlHelper
.
ComputePaintLocationY
(
value_max_left
,
value_min_left
,
height
-
upDowm
-
upDowm
,
auxiliary_lines
[
j
].
Value
)
+
(
float
)
upDowm
;
}
else
{
auxiliary_lines
[
j
].
PaintValue
=
ControlHelper
.
ComputePaintLocationY
(
value_max_right
,
value_min_right
,
height
-
upDowm
-
upDowm
,
auxiliary_lines
[
j
].
Value
)
+
(
float
)
upDowm
;
}
}
for
(
int
k
=
0
;
k
<=
value_Segment
;
k
++)
{
float
value
=
(
float
)((
double
)
k
*
(
double
)(
value_max_left
-
value_min_left
)
/
(
double
)
value_Segment
+
(
double
)
value_min_left
);
float
num4
=
ControlHelper
.
ComputePaintLocationY
(
value_max_left
,
value_min_left
,
height
-
upDowm
-
upDowm
,
value
)
+
(
float
)
upDowm
;
if
(
IsNeedPaintDash
(
num4
))
{
graphics
.
DrawLine
(
pen_normal
,
leftRight
-
4
,
num4
,
leftRight
-
1
,
num4
);
RectangleF
layoutRectangle
=
new
RectangleF
(
0f
,
num4
-
9f
,
leftRight
-
4
,
20f
);
graphics
.
DrawString
(
value
.
ToString
(),
font_size9
,
brush_deep
,
layoutRectangle
,
format_right
);
if
(
isRenderRightCoordinate
)
{
float
num5
=
(
float
)
k
*
(
value_max_right
-
value_min_right
)
/
(
float
)
value_Segment
+
value_min_right
;
graphics
.
DrawLine
(
pen_normal
,
width
-
leftRight
+
1
,
num4
,
width
-
leftRight
+
4
,
num4
);
layoutRectangle
.
Location
=
new
PointF
(
width
-
leftRight
+
4
,
num4
-
9f
);
graphics
.
DrawString
(
num5
.
ToString
(),
font_size9
,
brush_deep
,
layoutRectangle
,
format_left
);
}
if
(
k
>
0
&&
value_IsRenderDashLine
)
{
graphics
.
DrawLine
(
pen_dash
,
leftRight
,
num4
,
width
-
leftRight
,
num4
);
}
}
}
if
(
value_IsRenderDashLine
)
{
if
(
value_IsAbscissaStrech
)
{
float
num6
=
(
float
)(
width
-
leftRight
*
2
)
*
1f
/
(
float
)(
value_StrechDataCountMax
-
1
);
int
num7
=
CalculateDataCountByOffect
(
num6
);
for
(
int
l
=
0
;
l
<
value_StrechDataCountMax
;
l
+=
num7
)
{
if
(
l
>
0
&&
l
<
value_StrechDataCountMax
-
1
)
{
graphics
.
DrawLine
(
pen_dash
,
(
float
)
l
*
num6
+
(
float
)
leftRight
,
upDowm
,
(
float
)
l
*
num6
+
(
float
)
leftRight
,
height
-
upDowm
-
1
);
}
if
(
data_text
!=
null
&&
l
<
data_text
.
Length
&&
(
float
)
l
*
num6
+
(
float
)
leftRight
<
(
float
)(
data_text
.
Length
-
1
)
*
num6
+
(
float
)
leftRight
-
40f
)
{
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
((
int
)((
float
)
l
*
num6
),
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
l
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
}
string
[]
array2
=
data_text
;
if
(
array2
!=
null
&&
array2
.
Length
>
1
)
{
if
(
data_text
.
Length
<
value_StrechDataCountMax
)
{
graphics
.
DrawLine
(
pen_dash
,
(
float
)(
data_text
.
Length
-
1
)
*
num6
+
(
float
)
leftRight
,
upDowm
,
(
float
)(
data_text
.
Length
-
1
)
*
num6
+
(
float
)
leftRight
,
height
-
upDowm
-
1
);
}
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
((
int
)((
float
)(
data_text
.
Length
-
1
)
*
num6
+
(
float
)
leftRight
)
-
leftRight
,
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
data_text
.
Length
-
1
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
}
else
if
(
value_IntervalAbscissaText
>
0
)
{
int
num8
=
width
-
2
*
leftRight
+
1
;
for
(
int
m
=
leftRight
;
m
<
width
-
leftRight
;
m
+=
value_IntervalAbscissaText
)
{
if
(
m
!=
leftRight
)
{
graphics
.
DrawLine
(
pen_dash
,
m
,
upDowm
,
m
,
height
-
upDowm
-
1
);
}
if
(
data_text
==
null
)
{
continue
;
}
int
num9
=
(
num8
>
data_text
.
Length
)
?
data_text
.
Length
:
num8
;
if
(
m
-
leftRight
<
data_text
.
Length
&&
num9
-
(
m
-
leftRight
)
>
40
)
{
if
(
data_text
.
Length
<=
num8
)
{
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
(
m
-
leftRight
,
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
m
-
leftRight
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
else
{
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
(
m
-
leftRight
,
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
m
-
leftRight
+
data_text
.
Length
-
num8
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
}
}
string
[]
array3
=
data_text
;
if
(
array3
!=
null
&&
array3
.
Length
>
1
)
{
if
(
data_text
.
Length
>=
num8
)
{
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
(
width
-
leftRight
-
leftRight
,
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
data_text
.
Length
-
1
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
else
{
graphics
.
DrawLine
(
pen_dash
,
data_text
.
Length
+
leftRight
-
1
,
upDowm
,
data_text
.
Length
+
leftRight
-
1
,
height
-
upDowm
-
1
);
graphics
.
DrawString
(
layoutRectangle
:
new
Rectangle
(
data_text
.
Length
+
leftRight
-
1
-
leftRight
,
height
-
upDowm
+
1
,
leftRight
*
2
,
upDowm
),
s
:
data_text
[
data_text
.
Length
-
1
],
font
:
font_size9
,
brush
:
brush_deep
,
format
:
format_center
);
}
}
}
}
for
(
int
n
=
0
;
n
<
auxiliary_lines
.
Count
;
n
++)
{
if
(
auxiliary_lines
[
n
].
IsLeftFrame
)
{
graphics
.
DrawLine
(
auxiliary_lines
[
n
].
GetPen
(),
leftRight
-
4
,
auxiliary_lines
[
n
].
PaintValue
,
leftRight
-
1
,
auxiliary_lines
[
n
].
PaintValue
);
graphics
.
DrawString
(
layoutRectangle
:
new
RectangleF
(
0f
,
auxiliary_lines
[
n
].
PaintValue
-
9f
,
leftRight
-
4
,
20f
),
s
:
auxiliary_lines
[
n
].
Value
.
ToString
(),
font
:
font_size9
,
brush
:
auxiliary_lines
[
n
].
LineTextBrush
,
format
:
format_right
);
}
else
{
graphics
.
DrawLine
(
auxiliary_lines
[
n
].
GetPen
(),
width
-
leftRight
+
1
,
auxiliary_lines
[
n
].
PaintValue
,
width
-
leftRight
+
4
,
auxiliary_lines
[
n
].
PaintValue
);
graphics
.
DrawString
(
layoutRectangle
:
new
RectangleF
(
width
-
leftRight
+
4
,
auxiliary_lines
[
n
].
PaintValue
-
9f
,
leftRight
-
4
,
20f
),
s
:
auxiliary_lines
[
n
].
Value
.
ToString
(),
font
:
font_size9
,
brush
:
auxiliary_lines
[
n
].
LineTextBrush
,
format
:
format_left
);
}
graphics
.
DrawLine
(
auxiliary_lines
[
n
].
GetPen
(),
leftRight
,
auxiliary_lines
[
n
].
PaintValue
,
width
-
leftRight
,
auxiliary_lines
[
n
].
PaintValue
);
}
if
(
value_IsAbscissaStrech
)
{
foreach
(
MarkText
MarkText
in
MarkTexts
)
{
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item2
in
data_list
)
{
if
(
item2
.
Value
.
Visible
&&
item2
.
Value
.
LineRenderVisiable
&&
!(
item2
.
Key
!=
MarkText
.
CurveKey
))
{
float
[]
data
=
item2
.
Value
.
Data
;
if
(
data
!=
null
&&
data
.
Length
>
1
)
{
float
num10
=
(
float
)(
width
-
leftRight
*
2
)
*
1f
/
(
float
)(
value_StrechDataCountMax
-
1
);
if
(
MarkText
.
Index
>=
0
&&
MarkText
.
Index
<
item2
.
Value
.
Data
.
Length
)
{
PointF
pointF
=
new
PointF
((
float
)
leftRight
+
(
float
)
MarkText
.
Index
*
num10
,
ControlHelper
.
ComputePaintLocationY
(
item2
.
Value
.
IsLeftFrame
?
value_max_left
:
value_max_right
,
item2
.
Value
.
IsLeftFrame
?
value_min_left
:
value_min_right
,
height
-
upDowm
-
upDowm
,
item2
.
Value
.
Data
[
MarkText
.
Index
])
+
(
float
)
upDowm
);
graphics
.
FillEllipse
(
new
SolidBrush
(
MarkText
.
TextColor
??
item2
.
Value
.
LineColor
),
new
RectangleF
(
pointF
.
X
-
3f
,
pointF
.
Y
-
3f
,
6f
,
6f
));
switch
((
MarkText
.
PositionStyle
==
MarkTextPositionStyle
.
Auto
)
?
MarkText
.
CalculateDirectionFromDataIndex
(
item2
.
Value
.
Data
,
MarkText
.
Index
)
:
MarkText
.
PositionStyle
)
{
case
MarkTextPositionStyle
.
Left
:
graphics
.
DrawString
(
MarkText
.
Text
,
Font
,
new
SolidBrush
(
MarkText
.
TextColor
??
item2
.
Value
.
LineColor
),
new
RectangleF
(
pointF
.
X
-
100f
,
pointF
.
Y
-
(
float
)
Font
.
Height
,
100
-
MarkText
.
MarkTextOffect
,
Font
.
Height
*
2
),
format_right
);
break
;
case
MarkTextPositionStyle
.
Up
:
graphics
.
DrawString
(
MarkText
.
Text
,
Font
,
new
SolidBrush
(
MarkText
.
TextColor
??
item2
.
Value
.
LineColor
),
new
RectangleF
(
pointF
.
X
-
100f
,
pointF
.
Y
-
(
float
)
Font
.
Height
-
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
case
MarkTextPositionStyle
.
Right
:
graphics
.
DrawString
(
MarkText
.
Text
,
Font
,
new
SolidBrush
(
MarkText
.
TextColor
??
item2
.
Value
.
LineColor
),
new
RectangleF
(
pointF
.
X
+
(
float
)
MarkText
.
MarkTextOffect
,
pointF
.
Y
-
(
float
)
Font
.
Height
,
100f
,
Font
.
Height
*
2
),
format_left
);
break
;
case
MarkTextPositionStyle
.
Down
:
graphics
.
DrawString
(
MarkText
.
Text
,
Font
,
new
SolidBrush
(
MarkText
.
TextColor
??
item2
.
Value
.
LineColor
),
new
RectangleF
(
pointF
.
X
-
100f
,
pointF
.
Y
+
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
}
}
}
}
}
}
foreach
(
CurveItem
value2
in
data_list
.
Values
)
{
if
(
value2
.
Visible
&&
value2
.
LineRenderVisiable
)
{
float
[]
data2
=
value2
.
Data
;
if
(
data2
!=
null
&&
data2
.
Length
>
1
)
{
float
num11
=
(
float
)(
width
-
leftRight
*
2
)
*
1f
/
(
float
)(
value_StrechDataCountMax
-
1
);
PointF
[]
array4
=
new
PointF
[
value2
.
Data
.
Length
];
for
(
int
num12
=
0
;
num12
<
value2
.
Data
.
Length
;
num12
++)
{
array4
[
num12
].
X
=
(
float
)
leftRight
+
(
float
)
num12
*
num11
;
array4
[
num12
].
Y
=
ControlHelper
.
ComputePaintLocationY
(
value2
.
IsLeftFrame
?
value_max_left
:
value_max_right
,
value2
.
IsLeftFrame
?
value_min_left
:
value_min_right
,
height
-
upDowm
-
upDowm
,
value2
.
Data
[
num12
])
+
(
float
)
upDowm
;
if
(!
string
.
IsNullOrEmpty
(
value2
.
MarkText
[
num12
]))
{
using
(
Brush
brush
=
new
SolidBrush
(
value2
.
LineColor
))
{
graphics
.
FillEllipse
(
brush
,
new
RectangleF
(
array4
[
num12
].
X
-
3f
,
array4
[
num12
].
Y
-
3f
,
6f
,
6f
));
switch
(
MarkText
.
CalculateDirectionFromDataIndex
(
value2
.
Data
,
num12
))
{
case
MarkTextPositionStyle
.
Left
:
graphics
.
DrawString
(
value2
.
MarkText
[
num12
],
Font
,
brush
,
new
RectangleF
(
array4
[
num12
].
X
-
100f
,
array4
[
num12
].
Y
-
(
float
)
Font
.
Height
,
100
-
MarkText
.
MarkTextOffect
,
Font
.
Height
*
2
),
format_right
);
break
;
case
MarkTextPositionStyle
.
Up
:
graphics
.
DrawString
(
value2
.
MarkText
[
num12
],
Font
,
brush
,
new
RectangleF
(
array4
[
num12
].
X
-
100f
,
array4
[
num12
].
Y
-
(
float
)
Font
.
Height
-
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
case
MarkTextPositionStyle
.
Right
:
graphics
.
DrawString
(
value2
.
MarkText
[
num12
],
Font
,
brush
,
new
RectangleF
(
array4
[
num12
].
X
+
(
float
)
MarkText
.
MarkTextOffect
,
array4
[
num12
].
Y
-
(
float
)
Font
.
Height
,
100f
,
Font
.
Height
*
2
),
format_left
);
break
;
case
MarkTextPositionStyle
.
Down
:
graphics
.
DrawString
(
value2
.
MarkText
[
num12
],
Font
,
brush
,
new
RectangleF
(
array4
[
num12
].
X
-
100f
,
array4
[
num12
].
Y
+
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
}
}
}
}
using
(
Pen
pen2
=
new
Pen
(
value2
.
LineColor
,
value2
.
LineThickness
))
{
if
(
value2
.
IsSmoothCurve
)
{
graphics
.
DrawCurve
(
pen2
,
array4
);
}
else
{
graphics
.
DrawLines
(
pen2
,
array4
);
}
}
}
}
}
}
else
{
foreach
(
MarkText
MarkText2
in
MarkTexts
)
{
foreach
(
KeyValuePair
<
string
,
CurveItem
>
item3
in
data_list
)
{
if
(
item3
.
Value
.
Visible
&&
item3
.
Value
.
LineRenderVisiable
&&
!(
item3
.
Key
!=
MarkText2
.
CurveKey
))
{
float
[]
data3
=
item3
.
Value
.
Data
;
if
(
data3
!=
null
&&
data3
.
Length
>
1
&&
MarkText2
.
Index
>=
0
&&
MarkText2
.
Index
<
item3
.
Value
.
Data
.
Length
)
{
PointF
pointF2
=
new
PointF
(
leftRight
+
MarkText2
.
Index
,
ControlHelper
.
ComputePaintLocationY
(
item3
.
Value
.
IsLeftFrame
?
value_max_left
:
value_max_right
,
item3
.
Value
.
IsLeftFrame
?
value_min_left
:
value_min_right
,
height
-
upDowm
-
upDowm
,
item3
.
Value
.
Data
[
MarkText2
.
Index
])
+
(
float
)
upDowm
);
graphics
.
FillEllipse
(
new
SolidBrush
(
MarkText2
.
TextColor
??
item3
.
Value
.
LineColor
),
new
RectangleF
(
pointF2
.
X
-
3f
,
pointF2
.
Y
-
3f
,
6f
,
6f
));
switch
((
MarkText2
.
PositionStyle
==
MarkTextPositionStyle
.
Auto
)
?
MarkText
.
CalculateDirectionFromDataIndex
(
item3
.
Value
.
Data
,
MarkText2
.
Index
)
:
MarkText2
.
PositionStyle
)
{
case
MarkTextPositionStyle
.
Left
:
graphics
.
DrawString
(
MarkText2
.
Text
,
Font
,
new
SolidBrush
(
MarkText2
.
TextColor
??
item3
.
Value
.
LineColor
),
new
RectangleF
(
pointF2
.
X
-
100f
,
pointF2
.
Y
-
(
float
)
Font
.
Height
,
100
-
MarkText
.
MarkTextOffect
,
Font
.
Height
*
2
),
format_right
);
break
;
case
MarkTextPositionStyle
.
Up
:
graphics
.
DrawString
(
MarkText2
.
Text
,
Font
,
new
SolidBrush
(
MarkText2
.
TextColor
??
item3
.
Value
.
LineColor
),
new
RectangleF
(
pointF2
.
X
-
100f
,
pointF2
.
Y
-
(
float
)
Font
.
Height
-
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
case
MarkTextPositionStyle
.
Right
:
graphics
.
DrawString
(
MarkText2
.
Text
,
Font
,
new
SolidBrush
(
MarkText2
.
TextColor
??
item3
.
Value
.
LineColor
),
new
RectangleF
(
pointF2
.
X
+
(
float
)
MarkText
.
MarkTextOffect
,
pointF2
.
Y
-
(
float
)
Font
.
Height
,
100f
,
Font
.
Height
*
2
),
format_left
);
break
;
case
MarkTextPositionStyle
.
Down
:
graphics
.
DrawString
(
MarkText2
.
Text
,
Font
,
new
SolidBrush
(
MarkText2
.
TextColor
??
item3
.
Value
.
LineColor
),
new
RectangleF
(
pointF2
.
X
-
100f
,
pointF2
.
Y
+
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
}
}
}
}
}
foreach
(
CurveItem
value3
in
data_list
.
Values
)
{
if
(
value3
.
Visible
&&
value3
.
LineRenderVisiable
)
{
float
[]
data4
=
value3
.
Data
;
if
(
data4
!=
null
&&
data4
.
Length
>
1
)
{
int
num13
=
width
-
2
*
leftRight
+
1
;
PointF
[]
array5
;
if
(
value3
.
Data
.
Length
<=
num13
)
{
array5
=
new
PointF
[
value3
.
Data
.
Length
];
for
(
int
num14
=
0
;
num14
<
value3
.
Data
.
Length
;
num14
++)
{
array5
[
num14
].
X
=
leftRight
+
num14
;
array5
[
num14
].
Y
=
ControlHelper
.
ComputePaintLocationY
(
value3
.
IsLeftFrame
?
value_max_left
:
value_max_right
,
value3
.
IsLeftFrame
?
value_min_left
:
value_min_right
,
height
-
upDowm
-
upDowm
,
value3
.
Data
[
num14
])
+
(
float
)
upDowm
;
DrawMarkPoint
(
graphics
,
value3
.
MarkText
[
num14
],
array5
[
num14
],
value3
.
LineColor
,
MarkText
.
CalculateDirectionFromDataIndex
(
value3
.
Data
,
num14
));
}
}
else
{
array5
=
new
PointF
[
num13
];
for
(
int
num15
=
0
;
num15
<
array5
.
Length
;
num15
++)
{
int
num16
=
num15
+
value3
.
Data
.
Length
-
num13
;
array5
[
num15
].
X
=
leftRight
+
num15
;
array5
[
num15
].
Y
=
ControlHelper
.
ComputePaintLocationY
(
value3
.
IsLeftFrame
?
value_max_left
:
value_max_right
,
value3
.
IsLeftFrame
?
value_min_left
:
value_min_right
,
height
-
upDowm
-
upDowm
,
value3
.
Data
[
num16
])
+
(
float
)
upDowm
;
DrawMarkPoint
(
graphics
,
value3
.
MarkText
[
num16
],
array5
[
num15
],
value3
.
LineColor
,
MarkText
.
CalculateDirectionFromDataIndex
(
value3
.
Data
,
num16
));
}
}
using
(
Pen
pen3
=
new
Pen
(
value3
.
LineColor
,
value3
.
LineThickness
))
{
if
(
value3
.
IsSmoothCurve
)
{
graphics
.
DrawCurve
(
pen3
,
array5
);
}
else
{
graphics
.
DrawLines
(
pen3
,
array5
);
}
}
}
}
}
}
base
.
OnPaint
(
e
);
}
catch
(
Exception
exc
)
{
e
.
Graphics
.
DrawString
(
exc
.
Message
,
this
.
Font
,
Brushes
.
Black
,
10
,
10
);
}
}
/// <summary>
/// Draws the mark point.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="markText">The mark text.</param>
/// <param name="center">The center.</param>
/// <param name="color">The color.</param>
/// <param name="markTextPosition">The mark text position.</param>
private
void
DrawMarkPoint
(
Graphics
g
,
string
markText
,
PointF
center
,
Color
color
,
MarkTextPositionStyle
markTextPosition
)
{
if
(!
string
.
IsNullOrEmpty
(
markText
))
{
using
(
Brush
brush
=
new
SolidBrush
(
color
))
{
DrawMarkPoint
(
g
,
markText
,
center
,
brush
,
markTextPosition
);
}
}
}
/// <summary>
/// Draws the mark point.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="markText">The mark text.</param>
/// <param name="center">The center.</param>
/// <param name="brush">The brush.</param>
/// <param name="markTextPosition">The mark text position.</param>
private
void
DrawMarkPoint
(
Graphics
g
,
string
markText
,
PointF
center
,
Brush
brush
,
MarkTextPositionStyle
markTextPosition
)
{
if
(!
string
.
IsNullOrEmpty
(
markText
))
{
g
.
FillEllipse
(
brush
,
new
RectangleF
(
center
.
X
-
3f
,
center
.
Y
-
3f
,
6f
,
6f
));
switch
(
markTextPosition
)
{
case
MarkTextPositionStyle
.
Left
:
g
.
DrawString
(
markText
,
Font
,
brush
,
new
RectangleF
(
center
.
X
-
100f
,
center
.
Y
-
(
float
)
Font
.
Height
,
100
-
MarkText
.
MarkTextOffect
,
Font
.
Height
*
2
),
format_right
);
break
;
case
MarkTextPositionStyle
.
Up
:
g
.
DrawString
(
markText
,
Font
,
brush
,
new
RectangleF
(
center
.
X
-
100f
,
center
.
Y
-
(
float
)
Font
.
Height
-
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
case
MarkTextPositionStyle
.
Right
:
g
.
DrawString
(
markText
,
Font
,
brush
,
new
RectangleF
(
center
.
X
+
(
float
)
MarkText
.
MarkTextOffect
,
center
.
Y
-
(
float
)
Font
.
Height
,
100f
,
Font
.
Height
*
2
),
format_left
);
break
;
case
MarkTextPositionStyle
.
Down
:
g
.
DrawString
(
markText
,
Font
,
brush
,
new
RectangleF
(
center
.
X
-
100f
,
center
.
Y
+
(
float
)
MarkText
.
MarkTextOffect
,
200f
,
Font
.
Height
+
2
),
format_center
);
break
;
}
}
}
/// <summary>
/// Determines whether [is need paint dash] [the specified paint value].
/// </summary>
/// <param name="paintValue">The paint value.</param>
/// <returns><c>true</c> if [is need paint dash] [the specified paint value]; otherwise, <c>false</c>.</returns>
private
bool
IsNeedPaintDash
(
float
paintValue
)
{
for
(
int
i
=
0
;
i
<
auxiliary_lines
.
Count
;
i
++)
{
if
(
Math
.
Abs
(
auxiliary_lines
[
i
].
PaintValue
-
paintValue
)
<
(
float
)
font_size9
.
Height
)
{
return
false
;
}
}
return
true
;
}
/// <summary>
/// Calculates the data count by offect.
/// </summary>
/// <param name="offect">The offect.</param>
/// <returns>System.Int32.</returns>
private
int
CalculateDataCountByOffect
(
float
offect
)
{
if
(
value_IntervalAbscissaText
>
0
)
{
return
value_IntervalAbscissaText
;
}
if
(
offect
>
40f
)
{
return
1
;
}
offect
=
40f
/
offect
;
return
(
int
)
Math
.
Ceiling
(
offect
);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">为 true 则释放托管资源和非托管资源;为 false 则仅释放非托管资源。</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
components
!=
null
)
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
/// <summary>
/// Initializes the component.
/// </summary>
private
void
InitializeComponent
()
{
SuspendLayout
();
base
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
base
.
Name
=
"HslCurve"
;
base
.
Size
=
new
System
.
Drawing
.
Size
(
417
,
205
);
ResumeLayout
(
false
);
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/
AxisLabel
.cs
→
HZH_Controls/HZH_Controls/Controls/Charts/
MarkText
.cs
查看文件 @
44b6ae6
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-
17
// Created : 2019-09-
23
//
// ***********************************************************************
// <copyright file="
AxisLabel
.cs">
// <copyright file="
MarkText
.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
...
...
@@ -13,74 +13,101 @@
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System.
ComponentModel
;
using
System.
Drawing
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class
AxisLabel
.
/// Class
MarkText
.
/// </summary>
[
TypeConverter
(
typeof
(
ExpandableObjectConverter
))]
public
class
AxisLabel
public
class
MarkText
{
/// <summary>
/// The
conten
t
/// The
mark text offec
t
/// </summary>
private
string
_content
;
public
static
readonly
int
MarkTextOffect
=
5
;
/// <summary>
///
The value
///
Gets or sets the curve key.
/// </summary>
private
double
_value
;
/// <value>The curve key.</value>
public
string
CurveKey
{
get
;
set
;
}
/// <summary>
/// Gets or sets the
content
.
/// Gets or sets the
index
.
/// </summary>
/// <value>The content.</value>
public
string
Content
{
get
/// <value>The index.</value>
public
int
Index
{
return
_content
;
}
set
{
_content
=
value
;
}
get
;
set
;
}
/// <summary>
/// Gets or sets the
value
.
/// Gets or sets the
mark text
.
/// </summary>
/// <value>The
value
.</value>
public
double
Value
/// <value>The
mark text
.</value>
public
string
Text
{
get
{
return
_value
;
get
;
set
;
}
set
private
Color
?
textColor
=
null
;
public
Color
?
TextColor
{
_value
=
value
;
}
get
{
return
textColor
;
}
set
{
textColor
=
value
;
}
}
/// <summary>
///
Initializes a new instance of the <see cref="AxisLabel"/> class.
///
The position style
/// </summary>
/// <param name="value">The value.</param>
public
AxisLabel
(
double
value
)
private
MarkTextPositionStyle
positionStyle
=
MarkTextPositionStyle
.
Auto
;
/// <summary>
/// Gets or sets the position style.
/// </summary>
/// <value>The position style.</value>
public
MarkTextPositionStyle
PositionStyle
{
_value
=
value
;
_content
=
_value
.
ToString
();
get
{
return
positionStyle
;
}
set
{
positionStyle
=
value
;
}
}
/// <summary>
///
Initializes a new instance of the <see cref="AxisLabel"/> class
.
///
Calculates the index of the direction from data
.
/// </summary>
public
AxisLabel
()
:
this
(
0.0
)
/// <param name="data">The data.</param>
/// <param name="Index">The index.</param>
/// <returns>MarkTextPositionStyle.</returns>
public
static
MarkTextPositionStyle
CalculateDirectionFromDataIndex
(
float
[]
data
,
int
Index
)
{
float
num
=
(
Index
==
0
)
?
data
[
Index
]
:
data
[
Index
-
1
];
float
num2
=
(
Index
==
data
.
Length
-
1
)
?
data
[
Index
]
:
data
[
Index
+
1
];
if
(
num
<
data
[
Index
]
&&
data
[
Index
]
<
num2
)
{
return
MarkTextPositionStyle
.
Left
;
}
if
(
num
>
data
[
Index
]
&&
data
[
Index
]
>
num2
)
{
return
MarkTextPositionStyle
.
Right
;
}
if
(
num
<=
data
[
Index
]
&&
data
[
Index
]
>=
num2
)
{
return
MarkTextPositionStyle
.
Up
;
}
if
(
num
>=
data
[
Index
]
&&
data
[
Index
]
<=
num2
)
{
return
MarkTextPositionStyle
.
Down
;
}
return
MarkTextPositionStyle
.
Up
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/MarkTextPositionStyle.cs
0 → 100644
查看文件 @
44b6ae6
namespace
HZH_Controls.Controls
{
public
enum
MarkTextPositionStyle
{
Up
=
1
,
Right
=
2
,
Down
=
4
,
Left
=
8
,
Auto
=
16
}
}
HZH_Controls/HZH_Controls/Controls/Charts/PieChart/UCPieChart.cs
查看文件 @
44b6ae6
...
...
@@ -32,11 +32,6 @@ namespace HZH_Controls.Controls
public
class
UCPieChart
:
UserControl
{
/// <summary>
/// The percent color
/// </summary>
private
Color
percentColor
=
Color
.
DodgerBlue
;
/// <summary>
/// The pie items
/// </summary>
private
PieItem
[]
pieItems
=
new
PieItem
[
0
];
...
...
@@ -312,25 +307,7 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// Sets the margin paint.
/// </summary>
/// <param name="value">The value.</param>
private
void
SetMarginPaint
(
int
value
)
{
if
(
value
>
500
)
{
margin
=
80
;
}
else
if
(
value
>
300
)
{
margin
=
60
;
}
else
{
margin
=
40
;
}
}
/// <summary>
/// Gets the center point.
...
...
@@ -343,17 +320,6 @@ namespace HZH_Controls.Controls
return
new
Point
(
base
.
Width
/
2
-
1
,
base
.
Height
/
2
+
(
titleSize
!=
SizeF
.
Empty
?
((
int
)
titleSize
.
Height
)
:
0
)
-
1
);
}
/// <summary>
/// Gets the random color.
/// </summary>
/// <returns>Color.</returns>
private
Color
GetRandomColor
()
{
int
num
=
random
.
Next
(
256
);
int
num2
=
random
.
Next
(
256
);
int
blue
=
(
num
+
num2
>
430
)
?
random
.
Next
(
100
)
:
random
.
Next
(
200
);
return
Color
.
FromArgb
(
num
,
num2
,
blue
);
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
...
...
@@ -370,12 +336,9 @@ namespace HZH_Controls.Controls
{
if
(!
string
.
IsNullOrEmpty
(
title
))
e
.
Graphics
.
DrawString
(
title
,
titleFont
,
new
SolidBrush
(
titleFroeColor
),
new
PointF
((
this
.
Width
-
titleSize
.
Width
)
/
2
,
5
));
//e.Graphics.FillEllipse(Brushes.AliceBlue, rectangle);
//e.Graphics.DrawEllipse(Pens.DodgerBlue, rectangle);
Rectangle
rect
=
new
Rectangle
(
rectangle
.
X
-
centerPoint
.
X
,
rectangle
.
Y
-
centerPoint
.
Y
,
rectangle
.
Width
,
rectangle
.
Height
);
e
.
Graphics
.
TranslateTransform
(
centerPoint
.
X
,
centerPoint
.
Y
);
e
.
Graphics
.
RotateTransform
(
90f
);
e
.
Graphics
.
DrawLine
(
Pens
.
DimGray
,
0
,
0
,
width
,
0
);
int
num
=
pieItems
.
Sum
((
PieItem
item
)
=>
item
.
Value
);
float
num2
=
0f
;
float
num3
=
-
90f
;
...
...
@@ -460,7 +423,7 @@ namespace HZH_Controls.Controls
{
e
.
Graphics
.
FillEllipse
(
Brushes
.
AliceBlue
,
rectangle
);
e
.
Graphics
.
DrawEllipse
(
Pens
.
DodgerBlue
,
rectangle
);
e
.
Graphics
.
DrawString
(
"
空
"
,
Font
,
Brushes
.
DimGray
,
rectangle
,
formatCenter
);
e
.
Graphics
.
DrawString
(
"
无数据
"
,
Font
,
Brushes
.
DimGray
,
rectangle
,
formatCenter
);
}
base
.
OnPaint
(
e
);
}
...
...
HZH_Controls/HZH_Controls/Controls/Charts/SelectMode.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SelectMode.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace
HZH_Controls.Controls
{
/// <summary>
/// Enum SelectMode
/// </summary>
public
enum
SelectMode
{
/// <summary>
/// The both
/// </summary>
Both
,
/// <summary>
/// The x
/// </summary>
X
,
/// <summary>
/// The y
/// </summary>
Y
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/BezierSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="BezierSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Linq
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class BezierSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
BezierSeries
:
SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private
float
_thickness
=
1.8f
;
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
1.8f
)]
public
float
Thickness
{
get
{
return
_thickness
;
}
set
{
_thickness
=
value
;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
override
void
Draw
(
Graphics
g
)
{
PointF
[]
locationArray
=
GetLocationArray
();
if
(
locationArray
!=
null
&&
locationArray
.
Length
>
3
)
{
int
num
=
locationArray
.
Length
%
3
;
int
num2
=
locationArray
.
Length
/
3
;
int
num3
=
(
num
!=
0
)
?
1
:
(-
2
);
PointF
[]
points
=
locationArray
.
Take
(
3
*
num2
+
num3
).
ToArray
();
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
Thickness
))
{
g
.
DrawBeziers
(
pen
,
points
);
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
PointF
[]
points
=
new
PointF
[
4
]
{
new
PointF
(
0f
,
(
float
)
base
.
Legend
.
Height
/
2f
),
new
PointF
(
3f
,
0f
),
new
PointF
(
9f
,
base
.
Legend
.
Height
),
new
PointF
(
12f
,
(
float
)
base
.
Legend
.
Height
/
2f
)
};
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
_thickness
))
{
e
.
Graphics
.
DrawBeziers
(
pen
,
points
);
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/ColumnSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="ColumnSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Linq
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class ColumnSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
ColumnSeries
:
SeriesBase
{
/// <summary>
/// The width
/// </summary>
private
int
_width
=
24
;
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
24
)]
public
int
Width
{
get
{
return
_width
;
}
set
{
_width
=
value
;
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
using
(
SolidBrush
brush
=
new
SolidBrush
(
base
.
Color
))
{
e
.
Graphics
.
FillRectangle
(
brush
,
2f
,
((
float
)
base
.
Legend
.
Height
-
16f
)
/
2f
,
12f
,
16f
);
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="border">The border.</param>
/// <param name="sum">The sum.</param>
/// <param name="series">The series.</param>
internal
static
void
Draw
(
Graphics
g
,
Rectangle
border
,
int
sum
,
ColumnSeries
[]
series
)
{
int
num
=
series
.
Count
();
float
num2
=
0f
;
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
num2
+=
(
float
)
series
[
i
].
Width
;
}
if
(!(
num2
>
0f
))
{
return
;
}
num2
+=
(
float
)(
num
-
1
)
*
3f
;
float
num3
=
border
.
Width
;
float
num4
=
num3
/
(
float
)
sum
;
float
num5
=
(
float
)
border
.
Left
+
num4
-
num2
/
2f
;
for
(
int
j
=
0
;
j
<
num
;
j
++)
{
if
(
series
[
j
].
Visible
)
{
PointF
[]
locationArray
=
series
[
j
].
GetLocationArray
();
if
(
locationArray
!=
null
&&
locationArray
.
Length
!=
0
)
{
using
(
SolidBrush
brush
=
new
SolidBrush
(
series
[
j
].
Color
))
{
for
(
int
k
=
0
;
k
<
locationArray
.
Length
;
k
++)
{
float
x
=
num5
+
num4
*
(
float
)
k
;
float
y
=
locationArray
[
k
].
Y
;
float
width
=
series
[
j
].
Width
;
float
height
=
(
float
)
border
.
Bottom
-
locationArray
[
k
].
Y
-
1f
;
RectangleF
rect
=
new
RectangleF
(
x
,
y
,
width
,
height
);
g
.
FillRectangle
(
brush
,
rect
);
}
}
}
num5
+=
(
float
)
series
[
j
].
Width
+
3f
;
}
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/LabelSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="LabelSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class LabelSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
LabelSeries
:
SeriesBase
{
/// <summary>
/// The width
/// </summary>
private
int
_width
=
12
;
/// <summary>
/// The height
/// </summary>
private
int
_height
=
12
;
/// <summary>
/// The font
/// </summary>
private
Font
_font
=
new
Font
(
"微软雅黑"
,
10f
);
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
12
)]
public
int
Width
{
get
{
return
_width
;
}
set
{
_width
=
value
;
}
}
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形高度。"
)]
[
DefaultValue
(
12
)]
public
int
Height
{
get
{
return
_height
;
}
set
{
_height
=
value
;
}
}
/// <summary>
/// Gets or sets the font.
/// </summary>
/// <value>The font.</value>
[
Category
(
"自定义"
)]
[
Description
(
"字体。"
)]
public
Font
Font
{
get
{
return
_font
;
}
set
{
_font
=
value
;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
override
void
Draw
(
Graphics
g
)
{
if
(
base
.
Points
.
Count
>
0
)
{
using
(
SolidBrush
brush
=
new
SolidBrush
(
base
.
Color
))
{
foreach
(
ChartPoint
point2
in
base
.
Points
)
{
int
left
=
point2
.
Left
;
int
top
=
point2
.
Top
;
Point
[]
points
=
new
Point
[
3
]
{
new
Point
(
left
,
top
),
new
Point
(
left
-
_width
/
2
,
top
-
_height
),
new
Point
(
left
+
_width
/
2
,
top
-
_height
)
};
g
.
FillPolygon
(
brush
,
points
);
if
(!
string
.
IsNullOrEmpty
(
point2
.
Label
))
{
g
.
DrawString
(
point
:
new
Point
(
left
,
top
-
_height
),
s
:
point2
.
Label
,
font
:
_font
,
brush
:
brush
,
format
:
SeriesFormat
.
LabelFormat
);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
float
num
=
((
float
)
base
.
Legend
.
Height
-
12f
)
/
2f
;
PointF
[]
points
=
new
PointF
[
3
]
{
new
PointF
(
0f
,
num
),
new
PointF
(
12f
,
num
),
new
PointF
(
6f
,
num
+
12f
)
};
using
(
SolidBrush
brush
=
new
SolidBrush
(
base
.
Color
))
{
e
.
Graphics
.
FillPolygon
(
brush
,
points
);
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/LineSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="LineSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Linq
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class LineSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
LineSeries
:
SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private
float
_thickness
=
1.8f
;
/// <summary>
/// The curve tension
/// </summary>
private
float
_curveTension
=
0f
;
/// <summary>
/// The fill graph
/// </summary>
private
bool
_fillGraph
=
true
;
/// <summary>
/// The point visible
/// </summary>
private
bool
_pointVisible
=
false
;
/// <summary>
/// The value visible
/// </summary>
private
bool
_valueVisible
=
false
;
/// <summary>
/// The font
/// </summary>
private
Font
_font
=
new
Font
(
"微软雅黑"
,
10f
);
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
1.8f
)]
public
float
Thickness
{
get
{
return
_thickness
;
}
set
{
_thickness
=
value
;
}
}
/// <summary>
/// Gets or sets the curve tension.
/// </summary>
/// <value>The curve tension.</value>
[
Category
(
"自定义"
)]
[
Description
(
"曲线张力。"
)]
[
DefaultValue
(
0f
)]
public
float
CurveTension
{
get
{
return
_curveTension
;
}
set
{
_curveTension
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [fill graph].
/// </summary>
/// <value><c>true</c> if [fill graph]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"是否填充图形。"
)]
[
DefaultValue
(
true
)]
public
bool
FillGraph
{
get
{
return
_fillGraph
;
}
set
{
_fillGraph
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [point visible].
/// </summary>
/// <value><c>true</c> if [point visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏点状图形。"
)]
[
DefaultValue
(
false
)]
public
bool
PointVisible
{
get
{
return
_pointVisible
;
}
set
{
_pointVisible
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [value visible].
/// </summary>
/// <value><c>true</c> if [value visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏当前值。"
)]
[
DefaultValue
(
false
)]
public
bool
ValueVisible
{
get
{
return
_valueVisible
;
}
set
{
_valueVisible
=
value
;
}
}
/// <summary>
/// Gets or sets the font.
/// </summary>
/// <value>The font.</value>
[
Category
(
"自定义"
)]
[
Description
(
"字体。"
)]
public
Font
Font
{
get
{
return
_font
;
}
set
{
_font
=
value
;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
override
void
Draw
(
Graphics
g
)
{
PointF
[]
locationArray
=
GetLocationArray
();
if
(
locationArray
!=
null
&&
locationArray
.
Length
>
1
)
{
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
Thickness
))
{
if
(
CurveTension
>
0f
)
{
g
.
DrawCurve
(
pen
,
locationArray
,
CurveTension
);
}
else
{
g
.
DrawLines
(
pen
,
locationArray
);
}
}
if
(
FillGraph
&&
base
.
ParentAxisY
!=
null
)
{
double
yValue
=
base
.
ParentAxisY
.
IsReverse
?
base
.
ParentAxisY
.
MaxValue
:
base
.
ParentAxisY
.
MinValue
;
int
num
=
(
int
)
Math
.
Round
(
CountTop
(
yValue
));
PointF
[]
array
=
new
PointF
[
locationArray
.
Length
+
2
];
locationArray
.
CopyTo
(
array
,
0
);
array
[
array
.
Length
-
1
]
=
new
PointF
(
locationArray
[
0
].
X
,
num
);
array
[
array
.
Length
-
2
]
=
new
PointF
(
locationArray
[
locationArray
.
Length
-
1
].
X
,
num
);
using
(
SolidBrush
brush
=
new
SolidBrush
(
Color
.
FromArgb
(
50
,
base
.
Color
)))
{
g
.
FillPolygon
(
brush
,
array
);
}
}
}
if
(
base
.
Points
.
Count
>
0
&&
(
_pointVisible
||
_valueVisible
))
{
using
(
SolidBrush
brush2
=
new
SolidBrush
(
base
.
Color
))
{
if
(
_pointVisible
)
{
float
num2
=
4f
*
_thickness
;
foreach
(
ChartPoint
point
in
base
.
Points
)
{
int
num3
=
(
int
)
Math
.
Round
((
float
)
point
.
Left
-
2f
*
_thickness
);
int
num4
=
(
int
)
Math
.
Round
((
float
)
point
.
Top
-
2f
*
_thickness
);
g
.
FillEllipse
(
brush2
,
num3
,
num4
,
num2
,
num2
);
}
}
if
(
_valueVisible
)
{
ChartPoint
chartPoint
=
base
.
Points
.
Last
();
string
text
=
chartPoint
.
Y
.
ToString
();
if
(!
string
.
IsNullOrEmpty
(
text
))
{
g
.
DrawString
(
text
,
_font
,
brush2
,
new
Point
(
chartPoint
.
Left
,
chartPoint
.
Top
),
SeriesFormat
.
LabelFormat
);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
float
num
=
((
float
)
base
.
Legend
.
Height
-
_thickness
)
/
2f
;
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
_thickness
))
{
e
.
Graphics
.
DrawLine
(
pen
,
0f
,
num
,
12f
,
num
);
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/PointSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="PointSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class PointSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
PointSeries
:
SeriesBase
{
/// <summary>
/// The width
/// </summary>
private
int
_width
=
8
;
/// <summary>
/// The height
/// </summary>
private
int
_height
=
8
;
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
8
)]
public
int
Width
{
get
{
return
_width
;
}
set
{
_width
=
value
;
}
}
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形高度。"
)]
[
DefaultValue
(
8
)]
public
int
Height
{
get
{
return
_height
;
}
set
{
_height
=
value
;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
override
void
Draw
(
Graphics
g
)
{
if
(
base
.
Points
.
Count
>
0
)
{
using
(
SolidBrush
brush
=
new
SolidBrush
(
base
.
Color
))
{
foreach
(
ChartPoint
point
in
base
.
Points
)
{
float
x
=
(
float
)
point
.
Left
-
(
float
)
_width
/
2f
;
float
y
=
(
float
)
point
.
Top
-
(
float
)
_height
/
2f
;
g
.
FillEllipse
(
brush
,
x
,
y
,
_width
,
_height
);
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
using
(
SolidBrush
brush
=
new
SolidBrush
(
base
.
Color
))
{
e
.
Graphics
.
FillEllipse
(
brush
,
2f
,
(
float
)(
base
.
Legend
.
Height
-
8
)
/
2f
,
8f
,
8f
);
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/Series/StandardLineSeries.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="StandardLineSeries.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.ComponentModel
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class StandardLineSeries.
/// Implements the <see cref="HZH_Controls.Controls.SeriesBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.SeriesBase" />
public
class
StandardLineSeries
:
SeriesBase
{
/// <summary>
/// The thickness
/// </summary>
private
float
_thickness
=
1f
;
/// <summary>
/// The horizontat line visible
/// </summary>
private
bool
_horizontatLineVisible
=
true
;
/// <summary>
/// The vertical line visible
/// </summary>
private
bool
_verticalLineVisible
=
true
;
/// <summary>
/// Gets or sets the thickness.
/// </summary>
/// <value>The thickness.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图形宽度。"
)]
[
DefaultValue
(
1f
)]
public
float
Thickness
{
get
{
return
_thickness
;
}
set
{
_thickness
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [horizontat line visible].
/// </summary>
/// <value><c>true</c> if [horizontat line visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏横向基准线。"
)]
[
DefaultValue
(
true
)]
public
bool
HorizontatLineVisible
{
get
{
return
_horizontatLineVisible
;
}
set
{
_horizontatLineVisible
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [vertical line visible].
/// </summary>
/// <value><c>true</c> if [vertical line visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏纵向基准线。"
)]
[
DefaultValue
(
true
)]
public
bool
VerticalLineVisible
{
get
{
return
_verticalLineVisible
;
}
set
{
_verticalLineVisible
=
value
;
}
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
override
void
Draw
(
Graphics
g
)
{
PointF
[]
locationArray
=
GetLocationArray
();
if
(
locationArray
!=
null
&&
locationArray
.
Length
!=
0
)
{
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
Thickness
))
{
if
(
_horizontatLineVisible
&&
base
.
ParentAxisX
!=
null
)
{
float
x
=
CountLeft
(
base
.
ParentAxisX
.
MinValue
);
float
x2
=
CountLeft
(
base
.
ParentAxisX
.
MaxValue
);
PointF
[]
array
=
locationArray
;
for
(
int
i
=
0
;
i
<
array
.
Length
;
i
++)
{
PointF
pointF
=
array
[
i
];
g
.
DrawLine
(
pen
,
x
,
pointF
.
Y
,
x2
,
pointF
.
Y
);
}
}
if
(
_verticalLineVisible
&&
base
.
ParentAxisY
!=
null
)
{
float
y
=
CountTop
(
base
.
ParentAxisY
.
MinValue
);
float
y2
=
CountTop
(
base
.
ParentAxisY
.
MaxValue
);
PointF
[]
array2
=
locationArray
;
for
(
int
j
=
0
;
j
<
array2
.
Length
;
j
++)
{
PointF
pointF2
=
array2
[
j
];
g
.
DrawLine
(
pen
,
pointF2
.
X
,
y
,
pointF2
.
X
,
y2
);
}
}
}
}
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
override
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
e
.
Graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
float
num
=
((
float
)
base
.
Legend
.
Height
-
_thickness
)
/
2f
;
using
(
Pen
pen
=
new
Pen
(
base
.
Color
,
_thickness
))
{
e
.
Graphics
.
DrawLine
(
pen
,
0f
,
num
,
12f
,
num
);
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/SeriesBase.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesBase.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.ComponentModel
;
using
System.Drawing
;
using
System.Linq
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class SeriesBase.
/// </summary>
[
TypeConverter
(
typeof
(
ExpandableObjectConverter
))]
public
abstract
class
SeriesBase
{
/// <summary>
/// The chart
/// </summary>
private
UCChart
_chart
;
/// <summary>
/// The title
/// </summary>
private
string
_title
=
"Series"
;
/// <summary>
/// The points
/// </summary>
private
ChartPointCollection
_points
=
new
ChartPointCollection
();
/// <summary>
/// The scales x at
/// </summary>
private
int
_scalesXAt
=
0
;
/// <summary>
/// The scales y at
/// </summary>
private
int
_scalesYAt
=
0
;
/// <summary>
/// The color
/// </summary>
private
Color
_color
=
Color
.
FromArgb
(
232
,
17
,
35
);
/// <summary>
/// The visible
/// </summary>
private
bool
_visible
=
true
;
/// <summary>
/// The legend
/// </summary>
private
Label
_legend
;
/// <summary>
/// The legend visible
/// </summary>
private
bool
_legendVisible
=
true
;
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
[
Browsable
(
false
)]
public
UCChart
Chart
{
get
{
return
_chart
;
}
internal
set
{
_chart
=
value
;
}
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
[
Category
(
"自定义"
)]
[
Description
(
"标题。"
)]
[
DefaultValue
(
"Series"
)]
public
string
Title
{
get
{
return
_title
;
}
set
{
_title
=
value
;
_legend
.
Text
=
_title
;
}
}
/// <summary>
/// Gets the points.
/// </summary>
/// <value>The points.</value>
[
Category
(
"自定义"
)]
[
Description
(
"数据点。"
)]
[
TypeConverter
(
typeof
(
CollectionConverter
))]
[
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Content
)]
public
ChartPointCollection
Points
{
get
{
return
_points
;
}
private
set
{
_points
=
value
;
}
}
/// <summary>
/// Gets the maximum value x.
/// </summary>
/// <value>The maximum value x.</value>
[
Browsable
(
false
)]
public
double
?
MaxValueX
{
get
{
if
(
_points
==
null
||
_points
.
Count
<
1
)
{
return
null
;
}
IEnumerable
<
double
>
source
=
from
cp
in
_points
select
cp
.
X
;
return
source
.
Max
();
}
}
/// <summary>
/// Gets the minimum value x.
/// </summary>
/// <value>The minimum value x.</value>
[
Browsable
(
false
)]
public
double
?
MinValueX
{
get
{
if
(
_points
==
null
||
_points
.
Count
<
1
)
{
return
null
;
}
IEnumerable
<
double
>
source
=
from
cp
in
_points
select
cp
.
X
;
return
source
.
Min
();
}
}
/// <summary>
/// Gets the maximum value y.
/// </summary>
/// <value>The maximum value y.</value>
[
Browsable
(
false
)]
public
double
?
MaxValueY
{
get
{
if
(
_points
==
null
||
_points
.
Count
<
1
)
{
return
null
;
}
IEnumerable
<
double
>
source
=
from
cp
in
_points
select
cp
.
Y
;
return
source
.
Max
();
}
}
/// <summary>
/// Gets the minimum value y.
/// </summary>
/// <value>The minimum value y.</value>
[
Browsable
(
false
)]
public
double
?
MinValueY
{
get
{
if
(
_points
==
null
||
_points
.
Count
<
1
)
{
return
null
;
}
IEnumerable
<
double
>
source
=
from
cp
in
_points
select
cp
.
Y
;
return
source
.
Min
();
}
}
/// <summary>
/// Gets or sets the scales x at.
/// </summary>
/// <value>The scales x at.</value>
[
Category
(
"自定义"
)]
[
Description
(
"附着的X轴序号。"
)]
[
DefaultValue
(
0
)]
public
int
ScalesXAt
{
get
{
return
_scalesXAt
;
}
set
{
if
(
value
<
0
)
{
_scalesXAt
=
0
;
}
else
{
_scalesXAt
=
value
;
}
}
}
/// <summary>
/// Gets the parent axis x.
/// </summary>
/// <value>The parent axis x.</value>
[
Browsable
(
false
)]
public
Axis
ParentAxisX
{
get
{
if
(
_chart
!=
null
&&
_scalesXAt
<
_chart
.
AxisX
.
Count
)
{
return
_chart
.
AxisX
[
_scalesXAt
];
}
return
null
;
}
}
/// <summary>
/// Gets or sets the scales y at.
/// </summary>
/// <value>The scales y at.</value>
[
Category
(
"自定义"
)]
[
Description
(
"附着的Y轴序号。"
)]
[
DefaultValue
(
0
)]
public
int
ScalesYAt
{
get
{
return
_scalesYAt
;
}
set
{
if
(
value
<
0
)
{
_scalesYAt
=
0
;
}
else
{
_scalesYAt
=
value
;
}
}
}
/// <summary>
/// Gets the parent axis y.
/// </summary>
/// <value>The parent axis y.</value>
[
Browsable
(
false
)]
public
Axis
ParentAxisY
{
get
{
if
(
_chart
!=
null
&&
_scalesYAt
<
_chart
.
AxisY
.
Count
)
{
return
_chart
.
AxisY
[
_scalesYAt
];
}
return
null
;
}
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>The color.</value>
[
Category
(
"自定义"
)]
[
Description
(
"颜色。"
)]
public
Color
Color
{
get
{
return
_color
;
}
set
{
_color
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether this <see cref="SeriesBase"/> is visible.
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏。"
)]
[
DefaultValue
(
true
)]
public
bool
Visible
{
get
{
return
_visible
;
}
set
{
_visible
=
value
;
}
}
/// <summary>
/// Gets or sets the legend.
/// </summary>
/// <value>The legend.</value>
[
Browsable
(
false
)]
internal
Label
Legend
{
get
{
return
_legend
;
}
set
{
_legend
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [legend visible].
/// </summary>
/// <value><c>true</c> if [legend visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏图例。"
)]
[
DefaultValue
(
true
)]
public
bool
LegendVisible
{
get
{
return
_legendVisible
;
}
set
{
_legendVisible
=
value
;
_legend
.
Visible
=
_legendVisible
;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="SeriesBase"/> class.
/// </summary>
public
SeriesBase
()
{
_color
=
GetColorByIndex
(
UCChart
.
ColorIndex
);
UCChart
.
ColorIndex
++;
_legend
=
new
Label
{
AutoSize
=
true
,
Padding
=
new
Padding
(
12
,
0
,
0
,
0
),
Text
=
Title
};
_legend
.
Paint
+=
PaintLegend
;
}
/// <summary>
/// Gets the index of the color by.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>Color.</returns>
public
static
Color
GetColorByIndex
(
int
index
)
{
return
UCChart
.
Colors
[
index
-
UCChart
.
Colors
.
Count
*
(
index
/
UCChart
.
Colors
.
Count
)];
}
/// <summary>
/// Counts the left.
/// </summary>
/// <param name="xValue">The x value.</param>
/// <returns>System.Single.</returns>
public
float
CountLeft
(
double
xValue
)
{
double
num
=
_chart
.
Border
.
Width
;
double
num2
=
num
/
ParentAxisX
.
Range
;
double
num3
=
(
xValue
-
ParentAxisX
.
MinValue
)
*
num2
;
if
(
ParentAxisX
.
IsReverse
)
{
num3
=
num
-
num3
;
}
num3
+=
(
double
)
_chart
.
Border
.
Left
;
return
Convert
.
ToSingle
(
num3
);
}
/// <summary>
/// Counts the top.
/// </summary>
/// <param name="yValue">The y value.</param>
/// <returns>System.Single.</returns>
public
float
CountTop
(
double
yValue
)
{
double
num
=
_chart
.
Border
.
Height
;
double
num2
=
num
/
ParentAxisY
.
Range
;
double
num3
=
(
yValue
-
ParentAxisY
.
MinValue
)
*
num2
;
if
(!
ParentAxisY
.
IsReverse
)
{
num3
=
num
-
num3
;
}
num3
+=
(
double
)
_chart
.
Border
.
Top
;
return
Convert
.
ToSingle
(
num3
);
}
/// <summary>
/// Gets the location array.
/// </summary>
/// <returns>PointF[].</returns>
public
PointF
[]
GetLocationArray
()
{
if
(
_points
!=
null
||
_points
.
Count
>
0
)
{
PointF
[]
array
=
new
PointF
[
_points
.
Count
];
for
(
int
i
=
0
;
i
<
array
.
Length
;
i
++)
{
array
[
i
]
=
new
PointF
(
_points
[
i
].
Left
,
_points
[
i
].
Top
);
}
return
array
;
}
return
null
;
}
/// <summary>
/// Sets the values y.
/// </summary>
/// <param name="values">The values.</param>
/// <param name="startValue">The start value.</param>
/// <param name="valueStep">The value step.</param>
public
void
SetValuesY
(
double
[]
values
,
double
startValue
=
0.0
,
double
valueStep
=
0.1
)
{
_points
.
Clear
();
if
(
values
!=
null
&&
values
.
Length
!=
0
)
{
_chart
.
BeginUpdate
();
for
(
int
i
=
0
;
i
<
values
.
Length
;
i
++)
{
_points
.
Add
(
new
ChartPoint
((
double
)
i
*
valueStep
+
startValue
,
values
[
i
]));
}
_chart
.
EndUpdate
();
}
}
/// <summary>
/// Sets the values x.
/// </summary>
/// <param name="values">The values.</param>
/// <param name="startValue">The start value.</param>
/// <param name="valueStep">The value step.</param>
public
void
SetValuesX
(
double
[]
values
,
double
startValue
=
0.0
,
double
valueStep
=
0.1
)
{
_points
.
Clear
();
if
(
values
!=
null
&&
values
.
Length
!=
0
)
{
_chart
.
BeginUpdate
();
for
(
int
i
=
0
;
i
<
values
.
Length
;
i
++)
{
_points
.
Add
(
new
ChartPoint
(
values
[
i
],
(
double
)
i
*
valueStep
+
startValue
));
}
_chart
.
EndUpdate
();
}
}
/// <summary>
/// Selects all by x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectAllByX
(
int
x
,
float
range
=
0f
)
{
var
lst
=(
from
cp
in
_points
where
(
float
)
cp
.
Left
>=
(
float
)
x
-
range
&&
(
float
)
cp
.
Left
<=
(
float
)
x
+
range
select
cp
);
if
(
lst
!=
null
)
return
lst
.
ToArray
();
else
return
null
;
}
/// <summary>
/// Selects the by x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint.</returns>
public
ChartPoint
SelectByX
(
int
x
,
float
range
=
0f
)
{
ChartPoint
[]
array
=
SelectAllByX
(
x
,
range
);
if
(
array
==
null
)
{
return
null
;
}
int
num
=
int
.
MaxValue
;
ChartPoint
result
=
null
;
ChartPoint
[]
array2
=
array
;
foreach
(
ChartPoint
chartPoint
in
array2
)
{
int
num2
=
Math
.
Abs
(
x
-
chartPoint
.
Left
);
if
(
num2
<
num
)
{
result
=
chartPoint
;
num
=
num2
;
}
}
return
result
;
}
/// <summary>
/// Selects all by y.
/// </summary>
/// <param name="y">The y.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectAllByY
(
int
y
,
float
range
=
0f
)
{
var
lst
=(
from
cp
in
_points
where
(
float
)
cp
.
Top
>=
(
float
)
y
-
range
&&
(
float
)
cp
.
Top
<=
(
float
)
y
+
range
select
cp
);
if
(
lst
!=
null
)
return
lst
.
ToArray
();
else
return
null
;
}
/// <summary>
/// Selects the by y.
/// </summary>
/// <param name="y">The y.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint.</returns>
public
ChartPoint
SelectByY
(
int
y
,
float
range
=
0f
)
{
ChartPoint
[]
array
=
SelectAllByY
(
y
,
range
);
if
(
array
==
null
)
{
return
null
;
}
int
num
=
int
.
MaxValue
;
ChartPoint
result
=
null
;
ChartPoint
[]
array2
=
array
;
foreach
(
ChartPoint
chartPoint
in
array2
)
{
int
num2
=
Math
.
Abs
(
y
-
chartPoint
.
Top
);
if
(
num2
<
num
)
{
result
=
chartPoint
;
num
=
num2
;
}
}
return
result
;
}
/// <summary>
/// Selects all.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectAll
(
int
x
,
int
y
,
float
range
=
0f
)
{
var
lst
=(
from
cp
in
_points
where
(
float
)
cp
.
Left
>=
(
float
)
x
-
range
&&
(
float
)
cp
.
Left
<=
(
float
)
x
+
range
&&
(
float
)
cp
.
Top
>=
(
float
)
y
-
range
&&
(
float
)
cp
.
Top
<=
(
float
)
y
+
range
select
cp
);
if
(
lst
!=
null
)
return
lst
.
ToArray
();
else
return
null
;
}
/// <summary>
/// Selects the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint.</returns>
public
ChartPoint
Select
(
int
x
,
int
y
,
float
range
=
0f
)
{
ChartPoint
[]
array
=
SelectAll
(
x
,
y
,
range
);
if
(
array
==
null
)
{
return
null
;
}
int
num
=
int
.
MaxValue
;
ChartPoint
result
=
null
;
ChartPoint
[]
array2
=
array
;
foreach
(
ChartPoint
chartPoint
in
array2
)
{
int
num2
=
Math
.
Abs
(
x
-
chartPoint
.
Left
)
+
Math
.
Abs
(
y
-
chartPoint
.
Top
);
if
(
num2
<
num
)
{
result
=
chartPoint
;
num
=
num2
;
}
}
return
result
;
}
/// <summary>
/// Draws the specified g.
/// </summary>
/// <param name="g">The g.</param>
internal
virtual
void
Draw
(
Graphics
g
)
{
}
/// <summary>
/// Paints the legend.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
protected
virtual
void
PaintLegend
(
object
sender
,
PaintEventArgs
e
)
{
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/SeriesCollection.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesCollection.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System.Collections.ObjectModel
;
using
System.ComponentModel
;
using
System.Drawing.Design
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class SeriesCollection.
/// Implements the <see cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.SeriesBase}" />
/// </summary>
/// <seealso cref="System.Collections.ObjectModel.Collection{HZH_Controls.Controls.SeriesBase}" />
[
Editor
(
typeof
(
SeriesCollectionEditor
),
typeof
(
UITypeEditor
))]
public
class
SeriesCollection
:
Collection
<
SeriesBase
>
{
/// <summary>
/// Gets the chart.
/// </summary>
/// <value>The chart.</value>
public
UCChart
Chart
{
get
;
internal
set
;
}
/// <summary>
/// Inserts the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
InsertItem
(
int
index
,
SeriesBase
item
)
{
base
.
InsertItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Points
.
Chart
=
Chart
;
item
.
Points
.
Series
=
item
;
if
(
Chart
!=
null
)
{
Chart
.
LegendPanel
.
Controls
.
Add
(
item
.
Legend
);
}
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Sets the item.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="item">The item.</param>
protected
override
void
SetItem
(
int
index
,
SeriesBase
item
)
{
if
(
Chart
!=
null
)
{
Chart
.
LegendPanel
.
Controls
.
Remove
(
base
[
index
].
Legend
);
}
base
.
SetItem
(
index
,
item
);
item
.
Chart
=
Chart
;
item
.
Points
.
Chart
=
Chart
;
item
.
Points
.
Series
=
item
;
if
(
Chart
!=
null
)
{
Chart
.
LegendPanel
.
Controls
.
Add
(
item
.
Legend
);
}
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Clears the items.
/// </summary>
protected
override
void
ClearItems
()
{
if
(
Chart
!=
null
)
{
Chart
.
LegendPanel
.
Controls
.
Clear
();
}
base
.
ClearItems
();
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
/// <summary>
/// Removes the item.
/// </summary>
/// <param name="index">The index.</param>
protected
override
void
RemoveItem
(
int
index
)
{
if
(
Chart
!=
null
)
{
Chart
.
LegendPanel
.
Controls
.
Remove
(
base
[
index
].
Legend
);
}
base
.
RemoveItem
(
index
);
if
(
Chart
!=
null
)
Chart
.
Invalidate
();
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/SeriesCollectionEditor.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesCollectionEditor.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.ComponentModel.Design
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class SeriesCollectionEditor.
/// Implements the <see cref="System.ComponentModel.Design.CollectionEditor" />
/// </summary>
/// <seealso cref="System.ComponentModel.Design.CollectionEditor" />
public
class
SeriesCollectionEditor
:
CollectionEditor
{
/// <summary>
/// Initializes a new instance of the <see cref="SeriesCollectionEditor"/> class.
/// </summary>
/// <param name="type">此编辑器要编辑的集合的类型。</param>
public
SeriesCollectionEditor
(
Type
type
)
:
base
(
type
)
{
}
/// <summary>
/// 指示是否可一次选择多个集合项。
/// </summary>
/// <returns>如果可以同时选择多个集合成员,则为 true;否则,为 false。默认情况下,它将返回 true。</returns>
protected
override
bool
CanSelectMultipleInstances
()
{
return
true
;
}
/// <summary>
/// 获取此集合编辑器可包含的数据类型。
/// </summary>
/// <returns>此集合可包含的数据类型数组。</returns>
protected
override
Type
[]
CreateNewItemTypes
()
{
return
new
Type
[
6
]
{
typeof
(
BezierSeries
),
typeof
(
ColumnSeries
),
typeof
(
LabelSeries
),
typeof
(
LineSeries
),
typeof
(
PointSeries
),
typeof
(
StandardLineSeries
)
};
}
/// <summary>
/// 创建指定的集合项类型的新实例。
/// </summary>
/// <param name="itemType">要创建的项类型。</param>
/// <returns>指定对象的新实例。</returns>
protected
override
object
CreateInstance
(
Type
itemType
)
{
if
(
itemType
==
typeof
(
BezierSeries
))
{
return
new
BezierSeries
();
}
if
(
itemType
==
typeof
(
ColumnSeries
))
{
return
new
ColumnSeries
();
}
if
(
itemType
==
typeof
(
LabelSeries
))
{
return
new
LabelSeries
();
}
if
(
itemType
==
typeof
(
LineSeries
))
{
return
new
LineSeries
();
}
if
(
itemType
==
typeof
(
PointSeries
))
{
return
new
PointSeries
();
}
if
(
itemType
==
typeof
(
StandardLineSeries
))
{
return
new
StandardLineSeries
();
}
return
null
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/SeriesFormat.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="SeriesFormat.cs">
// Copyright by Huang Zhenghui() All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHubhttps://github.com/kwwwvagaa/NetWinformControl
// giteehttps://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System.Drawing
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class SeriesFormat.
/// </summary>
public
class
SeriesFormat
{
/// <summary>
/// The label format
/// </summary>
static
StringFormat
labelFormat
=
new
StringFormat
{
Alignment
=
StringAlignment
.
Center
,
LineAlignment
=
StringAlignment
.
Far
};
/// <summary>
/// Gets or sets the label format.
/// </summary>
/// <value>The label format.</value>
public
static
StringFormat
LabelFormat
{
get
{
return
labelFormat
;
}
set
{
labelFormat
=
value
;
}
}
}
}
HZH_Controls/HZH_Controls/Controls/Charts/UCChart.cs
deleted
100644 → 0
查看文件 @
b59938b
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-17
//
// ***********************************************************************
// <copyright file="UCChart.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.ComponentModel
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Linq
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class UCChart.
/// Implements the <see cref="System.Windows.Forms.Control" />
/// </summary>
/// <seealso cref="System.Windows.Forms.Control" />
public
class
UCChart
:
Control
{
/// <summary>
/// The axis margin
/// </summary>
public
const
int
AxisMargin
=
3
;
/// <summary>
/// The mini grid sum
/// </summary>
public
const
int
MiniGridSum
=
5
;
/// <summary>
/// The is draging
/// </summary>
private
bool
isDraging
=
false
;
/// <summary>
/// The mark line location
/// </summary>
private
Point
markLineLocation
;
/// <summary>
/// The drag location
/// </summary>
private
Point
dragLocation
;
/// <summary>
/// The zoom times
/// </summary>
private
double
zoomTimes
=
0.0
;
/// <summary>
/// The update flag
/// </summary>
private
bool
updateFlag
=
true
;
/// <summary>
/// The mark line pen
/// </summary>
private
Pen
_markLinePen
;
/// <summary>
/// The need draw mark line
/// </summary>
private
bool
needDrawMarkLine
;
/// <summary>
/// The horizontal separator sum
/// </summary>
private
int
_horizontalSeparatorSum
=
10
;
/// <summary>
/// The vertical separator sum
/// </summary>
private
int
_verticalSeparatorSum
=
10
;
/// <summary>
/// The axis x
/// </summary>
private
AxisCollection
_axisX
=
new
AxisCollection
();
/// <summary>
/// The axis y
/// </summary>
private
AxisCollection
_axisY
=
new
AxisCollection
();
/// <summary>
/// The series
/// </summary>
private
SeriesCollection
_series
=
new
SeriesCollection
();
/// <summary>
/// The border
/// </summary>
private
Rectangle
_border
;
/// <summary>
/// The offset x
/// </summary>
private
int
_offsetX
;
/// <summary>
/// The offset y
/// </summary>
private
int
_offsetY
;
/// <summary>
/// The horizontal grid visible
/// </summary>
private
bool
_horizontalGridVisible
=
true
;
/// <summary>
/// The vertical grid visible
/// </summary>
private
bool
_verticalGridVisible
=
true
;
/// <summary>
/// The mini grid visible
/// </summary>
private
bool
_miniGridVisible
=
false
;
/// <summary>
/// The mini grid dash style
/// </summary>
private
DashStyle
_miniGridDashStyle
=
DashStyle
.
Dot
;
/// <summary>
/// The legend visible
/// </summary>
private
bool
_legendVisible
=
true
;
/// <summary>
/// The zoom enabled
/// </summary>
private
bool
_zoomEnabled
=
true
;
/// <summary>
/// The allow drag
/// </summary>
private
bool
_allowDrag
=
true
;
/// <summary>
/// The mark line visible
/// </summary>
private
bool
_markLineVisible
=
false
;
/// <summary>
/// The mark line color
/// </summary>
private
Color
_markLineColor
=
Color
.
FromArgb
(
80
,
126
,
211
);
/// <summary>
/// The select point enabled
/// </summary>
private
bool
_selectPointEnabled
=
true
;
/// <summary>
/// Gets or sets the colors.
/// </summary>
/// <value>The colors.</value>
public
static
List
<
Color
>
Colors
{
get
;
set
;
}
/// <summary>
/// Gets or sets the index of the color.
/// </summary>
/// <value>The index of the color.</value>
public
static
int
ColorIndex
{
get
;
set
;
}
/// <summary>
/// Gets the main tool tip.
/// </summary>
/// <value>The main tool tip.</value>
internal
ToolTip
MainToolTip
{
get
;
private
set
;
}
/// <summary>
/// Gets the legend panel.
/// </summary>
/// <value>The legend panel.</value>
internal
FlowLayoutPanel
LegendPanel
{
get
;
private
set
;
}
/// <summary>
/// Gets or sets the horizontal separator sum.
/// </summary>
/// <value>The horizontal separator sum.</value>
[
Category
(
"自定义"
)]
[
Description
(
"横向分隔器个数。"
)]
[
DefaultValue
(
10
)]
public
int
HorizontalSeparatorSum
{
get
{
return
_horizontalSeparatorSum
;
}
set
{
_horizontalSeparatorSum
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the vertical separator sum.
/// </summary>
/// <value>The vertical separator sum.</value>
[
Category
(
"自定义"
)]
[
Description
(
"垂直分隔器个数。"
)]
[
DefaultValue
(
10
)]
public
int
VerticalSeparatorSum
{
get
{
return
_verticalSeparatorSum
;
}
set
{
_verticalSeparatorSum
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the axis x.
/// </summary>
/// <value>The axis x.</value>
[
Category
(
"自定义"
)]
[
Description
(
"X轴集合。"
)]
[
TypeConverter
(
typeof
(
CollectionConverter
))]
[
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Content
)]
public
AxisCollection
AxisX
{
get
{
return
_axisX
;
}
set
{
_axisX
=
value
;
}
}
/// <summary>
/// Gets or sets the axis y.
/// </summary>
/// <value>The axis y.</value>
[
Category
(
"自定义"
)]
[
Description
(
"Y轴集合。"
)]
[
TypeConverter
(
typeof
(
CollectionConverter
))]
[
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Content
)]
public
AxisCollection
AxisY
{
get
{
return
_axisY
;
}
set
{
_axisY
=
value
;
}
}
/// <summary>
/// Gets or sets the series.
/// </summary>
/// <value>The series.</value>
[
Category
(
"自定义"
)]
[
Description
(
"数据串集合。"
)]
[
TypeConverter
(
typeof
(
CollectionConverter
))]
[
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Content
)]
public
SeriesCollection
Series
{
get
{
return
_series
;
}
set
{
_series
=
value
;
}
}
/// <summary>
/// Gets or sets the border.
/// </summary>
/// <value>The border.</value>
[
Browsable
(
false
)]
public
Rectangle
Border
{
get
{
return
_border
;
}
set
{
_border
=
value
;
}
}
/// <summary>
/// Gets or sets the offset x.
/// </summary>
/// <value>The offset x.</value>
[
Browsable
(
false
)]
public
int
OffsetX
{
get
{
return
_offsetX
;
}
set
{
_offsetX
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the offset y.
/// </summary>
/// <value>The offset y.</value>
[
Browsable
(
false
)]
public
int
OffsetY
{
get
{
return
_offsetY
;
}
set
{
_offsetY
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether [horizontal grid visible].
/// </summary>
/// <value><c>true</c> if [horizontal grid visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏横向网格线。"
)]
[
DefaultValue
(
true
)]
public
bool
HorizontalGridVisible
{
get
{
return
_horizontalGridVisible
;
}
set
{
_horizontalGridVisible
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether [vertical grid visible].
/// </summary>
/// <value><c>true</c> if [vertical grid visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏垂直网格线。"
)]
[
DefaultValue
(
true
)]
public
bool
VerticalGridVisible
{
get
{
return
_verticalGridVisible
;
}
set
{
_verticalGridVisible
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether [mini grid visible].
/// </summary>
/// <value><c>true</c> if [mini grid visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏小网格线。"
)]
[
DefaultValue
(
false
)]
public
bool
MiniGridVisible
{
get
{
return
_miniGridVisible
;
}
set
{
_miniGridVisible
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the mini grid dash style.
/// </summary>
/// <value>The mini grid dash style.</value>
[
Category
(
"自定义"
)]
[
Description
(
"小网格线的样式。"
)]
[
DefaultValue
(
DashStyle
.
Dot
)]
public
DashStyle
MiniGridDashStyle
{
get
{
return
_miniGridDashStyle
;
}
set
{
_miniGridDashStyle
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether [legend visible].
/// </summary>
/// <value><c>true</c> if [legend visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏图例。"
)]
[
DefaultValue
(
true
)]
public
bool
LegendVisible
{
get
{
return
_legendVisible
;
}
set
{
_legendVisible
=
value
;
LegendPanel
.
Visible
=
_legendVisible
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets the legend dock.
/// </summary>
/// <value>The legend dock.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图例停靠位置。"
)]
[
DefaultValue
(
DockStyle
.
Top
)]
public
DockStyle
LegendDock
{
get
{
return
LegendPanel
.
Dock
;
}
set
{
if
(
value
!=
0
&&
value
!=
DockStyle
.
Fill
)
{
if
(
value
==
DockStyle
.
Top
||
value
==
DockStyle
.
Bottom
)
{
LegendPanel
.
FlowDirection
=
FlowDirection
.
LeftToRight
;
}
else
if
(
value
==
DockStyle
.
Left
||
value
==
DockStyle
.
Right
)
{
LegendPanel
.
FlowDirection
=
FlowDirection
.
TopDown
;
}
LegendPanel
.
Dock
=
value
;
Invalidate
();
}
}
}
/// <summary>
/// Gets or sets the legend font.
/// </summary>
/// <value>The legend font.</value>
[
Category
(
"自定义"
)]
[
Description
(
"图例字体。"
)]
public
Font
LegendFont
{
get
{
return
LegendPanel
.
Font
;
}
set
{
LegendPanel
.
Font
=
value
;
Invalidate
();
}
}
/// <summary>
/// Gets or sets a value indicating whether [zoom enabled].
/// </summary>
/// <value><c>true</c> if [zoom enabled]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"缩放使能。"
)]
[
DefaultValue
(
true
)]
public
bool
ZoomEnabled
{
get
{
return
_zoomEnabled
;
}
set
{
_zoomEnabled
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [allow drag].
/// </summary>
/// <value><c>true</c> if [allow drag]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"是否允许鼠标拖动"
)]
[
DefaultValue
(
true
)]
public
bool
AllowDrag
{
get
{
return
_allowDrag
;
}
set
{
_allowDrag
=
value
;
}
}
/// <summary>
/// Gets or sets a value indicating whether [mark line visible].
/// </summary>
/// <value><c>true</c> if [mark line visible]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"显示/隐藏标记线。"
)]
[
DefaultValue
(
false
)]
public
bool
MarkLineVisible
{
get
{
return
_markLineVisible
;
}
set
{
_markLineVisible
=
value
;
}
}
/// <summary>
/// Gets or sets the color of the mark line.
/// </summary>
/// <value>The color of the mark line.</value>
[
Category
(
"自定义"
)]
[
Description
(
"标记线颜色。"
)]
[
DefaultValue
(
typeof
(
Color
),
"80, 126, 211"
)]
public
Color
MarkLineColor
{
get
{
return
_markLineColor
;
}
set
{
_markLineColor
=
value
;
_markLinePen
=
new
Pen
(
_markLineColor
);
}
}
/// <summary>
/// Gets or sets a value indicating whether [select point enabled].
/// </summary>
/// <value><c>true</c> if [select point enabled]; otherwise, <c>false</c>.</value>
[
Category
(
"自定义"
)]
[
Description
(
"查找数据点使能。"
)]
[
DefaultValue
(
true
)]
public
bool
SelectPointEnabled
{
get
{
return
_selectPointEnabled
;
}
set
{
_selectPointEnabled
=
value
;
}
}
/// <summary>
/// The select mode
/// </summary>
SelectMode
selectMode
=
SelectMode
.
Both
;
/// <summary>
/// Gets or sets the select mode.
/// </summary>
/// <value>The select mode.</value>
[
Category
(
"自定义"
)]
[
Description
(
"查找数据点的模式。"
)]
[
DefaultValue
(
SelectMode
.
Both
)]
public
SelectMode
SelectMode
{
get
{
return
selectMode
;
}
set
{
selectMode
=
value
;
}
}
/// <summary>
/// Gets or sets the axis x index for select.
/// </summary>
/// <value>The axis x index for select.</value>
[
Browsable
(
false
)]
public
int
AxisXIndexForSelect
{
get
;
set
;
}
/// <summary>
/// Gets or sets the axis y index for select.
/// </summary>
/// <value>The axis y index for select.</value>
[
Browsable
(
false
)]
public
int
AxisYIndexForSelect
{
get
;
set
;
}
/// <summary>
/// 获取或设置在控件中显示的背景图像。
/// </summary>
/// <value>The background image.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[
Bindable
(
false
)]
[
Browsable
(
false
)]
[
EditorBrowsable
(
EditorBrowsableState
.
Never
)]
public
override
Image
BackgroundImage
{
get
{
return
base
.
BackgroundImage
;
}
set
{
base
.
BackgroundImage
=
value
;
}
}
/// <summary>
/// 获取或设置在 <see cref="T:System.Windows.Forms.ImageLayout" /> 枚举中定义的背景图像布局。
/// </summary>
/// <value>The background image layout.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[
Bindable
(
false
)]
[
Browsable
(
false
)]
[
EditorBrowsable
(
EditorBrowsableState
.
Never
)]
public
override
ImageLayout
BackgroundImageLayout
{
get
{
return
base
.
BackgroundImageLayout
;
}
set
{
base
.
BackgroundImageLayout
=
value
;
}
}
/// <summary>
/// 获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。
/// </summary>
/// <value>The right to left.</value>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[
Bindable
(
false
)]
[
Browsable
(
false
)]
[
EditorBrowsable
(
EditorBrowsableState
.
Never
)]
public
override
RightToLeft
RightToLeft
{
get
{
return
base
.
RightToLeft
;
}
set
{
base
.
RightToLeft
=
value
;
}
}
/// <summary>
/// Occurs when [got chart point].
/// </summary>
public
event
ChartPointEventHandler
GotChartPoint
;
/// <summary>
/// Initializes static members of the <see cref="UCChart"/> class.
/// </summary>
static
UCChart
()
{
Colors
=
new
List
<
Color
>
{
Color
.
FromArgb
(
41
,
127
,
184
),
Color
.
FromArgb
(
230
,
76
,
60
),
Color
.
FromArgb
(
240
,
195
,
15
),
Color
.
FromArgb
(
26
,
187
,
155
),
Color
.
FromArgb
(
87
,
213
,
140
),
Color
.
FromArgb
(
154
,
89
,
181
),
Color
.
FromArgb
(
92
,
109
,
126
),
Color
.
FromArgb
(
22
,
159
,
132
),
Color
.
FromArgb
(
39
,
173
,
96
),
Color
.
FromArgb
(
92
,
171
,
225
),
Color
.
FromArgb
(
141
,
68
,
172
),
Color
.
FromArgb
(
229
,
126
,
34
),
Color
.
FromArgb
(
210
,
84
,
0
),
Color
.
FromArgb
(
191
,
57
,
43
)
};
}
/// <summary>
/// Initializes a new instance of the <see cref="UCChart"/> class.
/// </summary>
public
UCChart
()
{
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
,
true
);
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
BackColor
=
Color
.
White
;
Font
=
new
Font
(
"微软雅黑"
,
12f
);
ForeColor
=
Color
.
FromArgb
(
51
,
51
,
51
);
base
.
Padding
=
new
Padding
(
6
);
base
.
Size
=
new
Size
(
400
,
300
);
base
.
TabStop
=
false
;
_axisX
.
Chart
=
this
;
_axisX
.
Type
=
AxisType
.
X
;
_axisY
.
Chart
=
this
;
_axisY
.
Type
=
AxisType
.
Y
;
_series
.
Chart
=
this
;
_markLinePen
=
new
Pen
(
_markLineColor
);
MainToolTip
=
new
ToolTip
();
LegendPanel
=
new
FlowLayoutPanel
{
AutoSize
=
true
,
Dock
=
DockStyle
.
Top
};
base
.
Controls
.
Add
(
LegendPanel
);
base
.
PaddingChanged
+=
delegate
{
Invalidate
();
};
}
/// <summary>
/// Handles the <see cref="E:GotChartPoint" /> event.
/// </summary>
/// <param name="e">The <see cref="ChartPointEventArgs"/> instance containing the event data.</param>
private
void
OnGotChartPoint
(
ChartPointEventArgs
e
)
{
if
(
this
.
GotChartPoint
!=
null
)
{
this
.
GotChartPoint
.
Invoke
(
this
,
e
);
}
}
/// <summary>
/// 引发 <see cref="M:System.Windows.Forms.Control.CreateControl" /> 方法。
/// </summary>
protected
override
void
OnCreateControl
()
{
base
.
OnCreateControl
();
InitializeChart
();
}
/// <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
);
if
(
updateFlag
)
{
Stopwatch
stopwatch
=
new
Stopwatch
();
stopwatch
.
Start
();
Graphics
graphics
=
e
.
Graphics
;
graphics
.
Clear
(
BackColor
);
UpdateAxisRange
();
UpdateChartBorder
(
graphics
,
base
.
Size
);
UpdateAxisSize
();
graphics
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
DrawFrame
(
graphics
);
DrawAxis
(
graphics
);
graphics
.
Clip
=
new
Region
(
_border
);
DrawSeries
(
graphics
);
DrawMarkLine
(
graphics
);
stopwatch
.
Stop
();
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.SizeChanged" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
protected
override
void
OnSizeChanged
(
EventArgs
e
)
{
base
.
OnSizeChanged
(
e
);
Invalidate
();
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseDown" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseDown
(
MouseEventArgs
e
)
{
base
.
OnMouseDown
(
e
);
if
(
_allowDrag
&&
e
.
Button
==
MouseButtons
.
Left
)
{
dragLocation
=
e
.
Location
;
isDraging
=
true
;
Cursor
=
Cursors
.
Hand
;
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseMove" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseMove
(
MouseEventArgs
e
)
{
base
.
OnMouseMove
(
e
);
bool
flag
=
false
;
if
(
_allowDrag
&&
isDraging
)
{
int
num
=
e
.
X
-
dragLocation
.
X
;
int
num2
=
e
.
Y
-
dragLocation
.
Y
;
dragLocation
=
e
.
Location
;
if
(
num
!=
0
||
num2
!=
0
)
{
_offsetX
+=
num
;
_offsetY
+=
num2
;
flag
=
true
;
}
}
if
(
_markLineVisible
)
{
if
(
_border
.
Contains
(
e
.
Location
))
{
if
(
markLineLocation
!=
e
.
Location
)
{
markLineLocation
=
e
.
Location
;
needDrawMarkLine
=
true
;
flag
=
true
;
}
}
else
if
(
needDrawMarkLine
)
{
needDrawMarkLine
=
false
;
flag
=
true
;
}
}
if
(
flag
)
{
Invalidate
();
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseUp" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseUp
(
MouseEventArgs
e
)
{
base
.
OnMouseUp
(
e
);
if
(
_selectPointEnabled
&&
_border
.
Contains
(
e
.
Location
)
&&
e
.
Button
==
MouseButtons
.
Left
)
{
SelectPoints
(
e
.
Location
);
}
if
(
_allowDrag
&&
e
.
Button
==
MouseButtons
.
Left
)
{
isDraging
=
false
;
Cursor
=
Cursors
.
Default
;
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseWheel" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.MouseEventArgs" />。</param>
protected
override
void
OnMouseWheel
(
MouseEventArgs
e
)
{
base
.
OnMouseWheel
(
e
);
if
(
_zoomEnabled
&&
_border
.
Contains
(
e
.
Location
))
{
if
(
e
.
Delta
>
0
&&
zoomTimes
>
-
1.95
)
{
zoomTimes
-=
0.05
;
}
else
if
(
e
.
Delta
<
0
&&
zoomTimes
<
0.45
)
{
zoomTimes
+=
0.05
;
}
zoomTimes
=
Math
.
Round
(
zoomTimes
,
2
);
Invalidate
();
}
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.MouseLeave" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
protected
override
void
OnMouseLeave
(
EventArgs
e
)
{
base
.
OnMouseLeave
(
e
);
MainToolTip
.
SetToolTip
(
this
,
null
);
if
(
needDrawMarkLine
)
{
needDrawMarkLine
=
false
;
Invalidate
();
}
}
/// <summary>
/// Initializes the chart.
/// </summary>
private
void
InitializeChart
()
{
foreach
(
SeriesBase
item
in
_series
)
{
item
.
Chart
=
this
;
item
.
Points
.
Chart
=
this
;
item
.
Points
.
Series
=
item
;
foreach
(
ChartPoint
point
in
item
.
Points
)
{
point
.
Chart
=
this
;
point
.
Series
=
item
;
}
}
foreach
(
Axis
item2
in
_axisX
)
{
item2
.
Chart
=
this
;
item2
.
Type
=
AxisType
.
X
;
}
foreach
(
Axis
item3
in
_axisY
)
{
item3
.
Chart
=
this
;
item3
.
Type
=
AxisType
.
Y
;
}
}
/// <summary>
/// Updates the axis range.
/// </summary>
private
void
UpdateAxisRange
()
{
foreach
(
Axis
item
in
_axisX
)
{
item
.
ResetRange
();
}
foreach
(
Axis
item2
in
_axisY
)
{
item2
.
ResetRange
();
}
foreach
(
SeriesBase
item3
in
_series
)
{
if
(
item3
.
ScalesXAt
>=
0
&&
item3
.
ScalesXAt
<
_axisX
.
Count
)
{
Axis
axis
=
_axisX
[
item3
.
ScalesXAt
];
axis
.
UpdateRange
(
item3
,
AxisType
.
X
,
_verticalSeparatorSum
);
}
if
(
item3
.
ScalesYAt
>=
0
&&
item3
.
ScalesYAt
<
_axisY
.
Count
)
{
Axis
axis2
=
_axisY
[
item3
.
ScalesYAt
];
axis2
.
UpdateRange
(
item3
,
AxisType
.
Y
,
_horizontalSeparatorSum
);
}
}
foreach
(
Axis
item4
in
_axisX
)
{
item4
.
UpdateZoom
(
zoomTimes
);
}
foreach
(
Axis
item5
in
_axisY
)
{
item5
.
UpdateZoom
(
zoomTimes
);
}
}
/// <summary>
/// Updates the chart border.
/// </summary>
/// <param name="g">The g.</param>
/// <param name="size">The size.</param>
private
void
UpdateChartBorder
(
Graphics
g
,
Size
size
)
{
float
num
=
0f
;
float
num2
=
0f
;
float
num3
=
0f
;
float
num4
=
0f
;
foreach
(
Axis
item
in
_axisX
)
{
item
.
UpdateLabel
(
_verticalSeparatorSum
);
item
.
UpdateSize1
(
g
,
Font
);
if
(
item
.
Position
==
AxisPosition
.
LeftBottom
)
{
num2
+=
item
.
Height
;
}
else
{
num
+=
item
.
Height
;
}
}
foreach
(
Axis
item2
in
_axisY
)
{
item2
.
UpdateLabel
(
_horizontalSeparatorSum
);
item2
.
UpdateSize1
(
g
,
Font
);
if
(
item2
.
Position
==
AxisPosition
.
LeftBottom
)
{
num3
+=
item2
.
Width
;
}
else
{
num4
+=
item2
.
Width
;
}
}
num
+=
(
float
)
base
.
Padding
.
Top
;
num2
+=
(
float
)
base
.
Padding
.
Bottom
;
num3
+=
(
float
)
base
.
Padding
.
Left
;
num4
+=
(
float
)
base
.
Padding
.
Right
;
int
num5
=
(
int
)
num3
;
int
num6
=
(
int
)
num
;
int
num7
=
(
int
)((
float
)
size
.
Width
-
num3
-
num4
);
int
num8
=
(
int
)((
float
)
size
.
Height
-
num
-
num2
);
if
(
LegendPanel
.
Visible
)
{
switch
(
LegendPanel
.
Dock
)
{
case
DockStyle
.
Top
:
LegendPanel
.
Padding
=
new
Padding
(
num5
+
3
,
base
.
Padding
.
Top
,
(
int
)
num4
+
3
,
0
);
num6
+=
LegendPanel
.
Height
+
3
;
num8
-=
LegendPanel
.
Height
+
3
;
break
;
case
DockStyle
.
Bottom
:
LegendPanel
.
Padding
=
new
Padding
(
num5
+
3
,
0
,
(
int
)
num4
+
3
,
base
.
Padding
.
Bottom
);
num8
-=
LegendPanel
.
Height
+
3
;
break
;
case
DockStyle
.
Left
:
LegendPanel
.
Padding
=
new
Padding
(
base
.
Padding
.
Left
,
num6
+
3
,
0
,
(
int
)
num2
+
3
);
num5
+=
LegendPanel
.
Width
+
3
;
num7
-=
LegendPanel
.
Width
+
3
;
break
;
case
DockStyle
.
Right
:
LegendPanel
.
Padding
=
new
Padding
(
0
,
num6
+
3
,
base
.
Padding
.
Right
,
(
int
)
num2
+
3
);
num7
-=
LegendPanel
.
Width
+
3
;
break
;
}
}
_border
=
new
Rectangle
(
num5
,
num6
,
num7
,
num8
);
}
/// <summary>
/// Updates the size of the axis.
/// </summary>
private
void
UpdateAxisSize
()
{
foreach
(
Axis
item
in
_axisX
)
{
item
.
UpdateSize2
(
_border
,
_verticalSeparatorSum
);
item
.
UpdateOffset
(
_verticalSeparatorSum
,
_offsetX
);
}
foreach
(
Axis
item2
in
_axisY
)
{
item2
.
UpdateSize2
(
_border
,
_horizontalSeparatorSum
);
item2
.
UpdateOffset
(
_horizontalSeparatorSum
,
-
_offsetY
);
}
}
/// <summary>
/// Draws the frame.
/// </summary>
/// <param name="g">The g.</param>
internal
void
DrawFrame
(
Graphics
g
)
{
Pen
pen
=
new
Pen
(
Color
.
FromArgb
(
111
,
ForeColor
));
Pen
pen2
=
new
Pen
(
Color
.
FromArgb
(
58
,
ForeColor
));
Pen
pen3
=
new
Pen
(
Color
.
FromArgb
(
53
,
ForeColor
))
{
DashStyle
=
_miniGridDashStyle
};
g
.
DrawRectangle
(
pen
,
_border
);
pen
.
Dispose
();
if
(
_horizontalGridVisible
)
{
int
left
=
_border
.
Left
;
int
right
=
_border
.
Right
;
float
num
=
_border
.
Height
;
float
num2
=
num
/
(
float
)
_horizontalSeparatorSum
;
float
num3
=
(
float
)
_offsetY
%
num2
;
float
num4
=
(
float
)
_border
.
Top
+
num3
;
for
(
int
i
=
0
;
i
<
_horizontalSeparatorSum
+
1
;
i
++)
{
if
(
_border
.
Contains
(
_border
.
Left
,
(
int
)
num4
))
{
g
.
DrawLine
(
pen2
,
left
,
num4
,
right
,
num4
);
}
num4
+=
num2
;
}
if
(
_miniGridVisible
)
{
float
num5
=
num2
/
5f
;
num3
=
(
float
)
_offsetY
%
num5
;
num4
=
(
float
)
_border
.
Top
+
num3
;
for
(
int
j
=
0
;
j
<
_horizontalSeparatorSum
*
5
+
1
;
j
++)
{
if
(
_border
.
Contains
(
_border
.
Left
,
(
int
)
num4
))
{
g
.
DrawLine
(
pen3
,
left
,
num4
,
right
,
num4
);
}
num4
+=
num5
;
}
}
}
if
(
_verticalGridVisible
)
{
int
top
=
_border
.
Top
;
int
bottom
=
_border
.
Bottom
;
float
num6
=
_border
.
Width
;
float
num7
=
num6
/
(
float
)
_verticalSeparatorSum
;
float
num8
=
(
float
)
_offsetX
%
num7
;
float
num9
=
(
float
)
_border
.
Left
+
num8
;
for
(
int
k
=
0
;
k
<
_verticalSeparatorSum
+
1
;
k
++)
{
if
(
_border
.
Contains
((
int
)
num9
,
_border
.
Top
))
{
g
.
DrawLine
(
pen2
,
num9
,
top
,
num9
,
bottom
);
}
num9
+=
num7
;
}
if
(
_miniGridVisible
)
{
float
num10
=
num7
/
5f
;
num8
=
(
float
)
_offsetX
%
num10
;
num9
=
(
float
)
_border
.
Left
+
num8
;
for
(
int
l
=
0
;
l
<
_verticalSeparatorSum
*
5
+
1
;
l
++)
{
if
(
_border
.
Contains
((
int
)
num9
,
_border
.
Top
))
{
g
.
DrawLine
(
pen3
,
num9
,
top
,
num9
,
bottom
);
}
num9
+=
num10
;
}
}
}
pen2
.
Dispose
();
pen3
.
Dispose
();
}
/// <summary>
/// Draws the axis.
/// </summary>
/// <param name="g">The g.</param>
private
void
DrawAxis
(
Graphics
g
)
{
DrawAxisX
(
g
);
DrawAxisY
(
g
);
}
/// <summary>
/// Draws the axis x.
/// </summary>
/// <param name="g">The g.</param>
private
void
DrawAxisX
(
Graphics
g
)
{
float
top
=
base
.
Padding
.
Top
;
float
bottom
=
0f
;
if
(
LegendPanel
.
Visible
)
{
switch
(
LegendPanel
.
Dock
)
{
case
DockStyle
.
Top
:
top
+=
(
float
)
LegendPanel
.
Height
+
3f
;
break
;
}
}
foreach
(
Axis
item
in
_axisX
)
{
item
.
DrawAxisX
(
g
,
Font
,
_border
,
_offsetX
,
ref
top
,
ref
bottom
);
}
}
/// <summary>
/// Draws the axis y.
/// </summary>
/// <param name="g">The g.</param>
private
void
DrawAxisY
(
Graphics
g
)
{
float
left
=
base
.
Padding
.
Left
;
float
right
=
0f
;
if
(
LegendPanel
.
Visible
)
{
switch
(
LegendPanel
.
Dock
)
{
case
DockStyle
.
Left
:
left
+=
(
float
)
LegendPanel
.
Width
+
3f
;
break
;
}
}
foreach
(
Axis
item
in
_axisY
)
{
item
.
DrawAxisY
(
g
,
Font
,
_border
,
_offsetY
,
ref
left
,
ref
right
);
}
}
/// <summary>
/// Draws the series.
/// </summary>
/// <param name="g">The g.</param>
private
void
DrawSeries
(
Graphics
g
)
{
foreach
(
SeriesBase
item
in
_series
)
{
if
(
item
.
Visible
)
{
item
.
Draw
(
g
);
}
}
List
<
ColumnSeries
>
list
=
new
List
<
ColumnSeries
>();
foreach
(
SeriesBase
item2
in
_series
)
{
ColumnSeries
columnSeries
=
item2
as
ColumnSeries
;
if
(
columnSeries
!=
null
)
{
list
.
Add
(
columnSeries
);
}
}
if
(
list
!=
null
&&
list
.
Count
()
>
0
)
{
ColumnSeries
.
Draw
(
g
,
_border
,
_verticalSeparatorSum
,
list
.
ToArray
());
}
}
/// <summary>
/// Draws the mark line.
/// </summary>
/// <param name="g">The g.</param>
private
void
DrawMarkLine
(
Graphics
g
)
{
if
(
needDrawMarkLine
&&
!
isDraging
)
{
g
.
DrawLine
(
_markLinePen
,
markLineLocation
.
X
,
_border
.
Top
,
markLineLocation
.
X
,
_border
.
Bottom
);
}
}
/// <summary>
/// Selects the points.
/// </summary>
/// <param name="location">The location.</param>
private
void
SelectPoints
(
Point
location
)
{
Stopwatch
stopwatch
=
new
Stopwatch
();
stopwatch
.
Start
();
ChartPoint
[]
array
=
null
;
string
content
=
null
;
switch
(
SelectMode
)
{
case
SelectMode
.
Both
:
array
=
SelectPointsByLocation
(
location
,
4
);
if
(
array
!=
null
)
{
content
=
GetPointsContent1
(
array
);
}
break
;
case
SelectMode
.
X
:
array
=
SelectPointsByX
(
AxisXIndexForSelect
,
location
.
X
,
4
);
if
(
array
!=
null
)
{
content
=
GetPointsContent2
(
array
);
}
break
;
case
SelectMode
.
Y
:
array
=
SelectPointsByY
(
AxisYIndexForSelect
,
location
.
Y
,
4
);
if
(
array
!=
null
)
{
content
=
GetPointsContent3
(
array
);
}
break
;
}
if
(
array
!=
null
)
{
ChartPointEventArgs
chartPointEventArgs
=
new
ChartPointEventArgs
(
array
,
content
);
OnGotChartPoint
(
chartPointEventArgs
);
MainToolTip
.
SetToolTip
(
this
,
chartPointEventArgs
.
Content
);
}
stopwatch
.
Stop
();
}
/// <summary>
/// Gets the point location.
/// </summary>
/// <param name="scalesXAt">The scales x at.</param>
/// <param name="scalesYAt">The scales y at.</param>
/// <param name="cp">The cp.</param>
/// <returns>PointF.</returns>
public
PointF
GetPointLocation
(
int
scalesXAt
,
int
scalesYAt
,
ChartPoint
cp
)
{
return
new
PointF
(
CountLeft
(
scalesXAt
,
cp
.
X
),
CountTop
(
scalesYAt
,
cp
.
Y
));
}
/// <summary>
/// Counts the left.
/// </summary>
/// <param name="scalesXAt">The scales x at.</param>
/// <param name="xValue">The x value.</param>
/// <returns>System.Single.</returns>
public
float
CountLeft
(
int
scalesXAt
,
double
xValue
)
{
double
num
=
_border
.
Width
;
double
num2
=
num
/
_axisX
[
scalesXAt
].
Range
;
double
num3
=
(
xValue
-
_axisX
[
scalesXAt
].
MinValue
)
*
num2
;
if
(
_axisX
[
scalesXAt
].
IsReverse
)
{
num3
=
num
-
num3
;
}
num3
+=
(
double
)
_border
.
Left
;
return
Convert
.
ToSingle
(
num3
);
}
/// <summary>
/// Counts the top.
/// </summary>
/// <param name="scalesYAt">The scales y at.</param>
/// <param name="yValue">The y value.</param>
/// <returns>System.Single.</returns>
public
float
CountTop
(
int
scalesYAt
,
double
yValue
)
{
double
num
=
_border
.
Height
;
double
num2
=
num
/
_axisY
[
scalesYAt
].
Range
;
double
num3
=
(
yValue
-
_axisY
[
scalesYAt
].
MinValue
)
*
num2
;
if
(!
_axisY
[
scalesYAt
].
IsReverse
)
{
num3
=
num
-
num3
;
}
num3
+=
(
double
)
_border
.
Top
;
return
Convert
.
ToSingle
(
num3
);
}
/// <summary>
/// Counts the value x.
/// </summary>
/// <param name="scalesXAt">The scales x at.</param>
/// <param name="xLocation">The x location.</param>
/// <returns>System.Double.</returns>
public
double
CountValueX
(
int
scalesXAt
,
double
xLocation
)
{
double
num
=
_border
.
Width
;
double
num2
=
_axisX
[
scalesXAt
].
Range
/
num
;
double
num3
=
(
xLocation
-
(
double
)
_border
.
Left
)
*
num2
;
if
(
_axisX
[
scalesXAt
].
IsReverse
)
{
num3
=
_axisX
[
scalesXAt
].
Range
-
num3
;
}
return
num3
-
Math
.
Abs
(
_axisX
[
scalesXAt
].
MinValue
);
}
/// <summary>
/// Counts the value y.
/// </summary>
/// <param name="scalesYAt">The scales y at.</param>
/// <param name="yLocation">The y location.</param>
/// <returns>System.Double.</returns>
public
double
CountValueY
(
int
scalesYAt
,
double
yLocation
)
{
double
num
=
_border
.
Height
;
double
num2
=
_axisY
[
scalesYAt
].
Range
/
num
;
double
num3
=
(
yLocation
-
(
double
)
_border
.
Top
)
*
num2
;
if
(!
_axisY
[
scalesYAt
].
IsReverse
)
{
num3
=
_axisY
[
scalesYAt
].
Range
-
num3
;
}
return
num3
-
Math
.
Abs
(
_axisY
[
scalesYAt
].
MinValue
);
}
/// <summary>
/// Gets the mouse value string.
/// </summary>
/// <param name="mouseLocation">The mouse location.</param>
/// <returns>System.String.</returns>
public
string
GetMouseValueStr
(
Point
mouseLocation
)
{
string
text
=
""
;
int
count
=
_axisX
.
Count
;
if
(
count
>
0
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(!
_axisX
[
i
].
IsCustomLabels
)
{
double
value
=
CountValueX
(
i
,
mouseLocation
.
X
);
text
+=
"{_axisX[i].Title}:{Math.Round(value, 2)}\r\n"
;
}
}
}
int
count2
=
_axisY
.
Count
;
if
(
count2
>
0
)
{
for
(
int
j
=
0
;
j
<
count2
;
j
++)
{
if
(!
_axisY
[
j
].
IsCustomLabels
)
{
double
value2
=
CountValueY
(
j
,
mouseLocation
.
Y
);
text
+=
"{_axisY[j].Title}:{Math.Round(value2, 2)}\r\n"
;
}
}
}
return
text
;
}
/// <summary>
/// Draws to bitmap.
/// </summary>
/// <param name="bitmap">The bitmap.</param>
public
void
DrawToBitmap
(
Bitmap
bitmap
)
{
if
(
bitmap
!=
null
)
{
Size
size
=
base
.
Size
;
Point
location
=
base
.
Location
;
DockStyle
dock
=
Dock
;
Dock
=
DockStyle
.
None
;
base
.
Size
=
bitmap
.
Size
;
DrawToBitmap
(
bitmap
,
base
.
ClientRectangle
);
base
.
Size
=
size
;
base
.
Location
=
location
;
Dock
=
dock
;
}
}
/// <summary>
/// Sets the offset.
/// </summary>
/// <param name="offsetX">The offset x.</param>
/// <param name="offsetY">The offset y.</param>
public
void
SetOffset
(
int
offsetX
,
int
offsetY
)
{
_offsetX
=
offsetX
;
_offsetY
=
offsetY
;
Invalidate
();
}
/// <summary>
/// Sets the zoom times.
/// </summary>
/// <param name="times">The times.</param>
public
void
SetZoomTimes
(
double
times
)
{
if
(
times
<
-
2.0
)
{
zoomTimes
=
-
2.0
;
}
else
if
(
times
>
0.5
)
{
zoomTimes
=
0.5
;
}
else
{
zoomTimes
=
times
;
}
zoomTimes
=
Math
.
Round
(
zoomTimes
,
2
);
Invalidate
();
}
/// <summary>
/// Begins the update.
/// </summary>
public
void
BeginUpdate
()
{
updateFlag
=
false
;
}
/// <summary>
/// Ends the update.
/// </summary>
public
void
EndUpdate
()
{
updateFlag
=
true
;
Invalidate
();
}
/// <summary>
/// Selects the points by location.
/// </summary>
/// <param name="location">The location.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectPointsByLocation
(
Point
location
,
int
range
)
{
List
<
ChartPoint
>
list
=
new
List
<
ChartPoint
>();
foreach
(
SeriesBase
item
in
Series
)
{
ChartPoint
chartPoint
=
item
.
Select
(
location
.
X
,
location
.
Y
,
range
);
if
(
chartPoint
!=
null
)
{
list
.
Add
(
chartPoint
);
}
}
if
(
list
.
Count
>
0
)
{
return
list
.
ToArray
();
}
return
null
;
}
/// <summary>
/// Selects the points by x.
/// </summary>
/// <param name="indexOfAxisX">The index of axis x.</param>
/// <param name="x">The x.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectPointsByX
(
int
indexOfAxisX
,
int
x
,
int
range
)
{
List
<
ChartPoint
>
list
=
new
List
<
ChartPoint
>();
foreach
(
SeriesBase
item
in
_series
)
{
if
(
item
.
ScalesXAt
==
indexOfAxisX
)
{
ChartPoint
chartPoint
=
item
.
SelectByX
(
x
,
range
);
if
(
chartPoint
!=
null
)
{
if
(
list
.
Count
==
0
)
{
list
.
Add
(
chartPoint
);
}
else
if
(
chartPoint
.
X
==
list
[
0
].
X
)
{
list
.
Add
(
chartPoint
);
}
}
}
}
if
(
list
.
Count
>
0
)
{
return
list
.
ToArray
();
}
return
null
;
}
/// <summary>
/// Selects the points by y.
/// </summary>
/// <param name="indexOfAxisY">The index of axis y.</param>
/// <param name="y">The y.</param>
/// <param name="range">The range.</param>
/// <returns>ChartPoint[].</returns>
public
ChartPoint
[]
SelectPointsByY
(
int
indexOfAxisY
,
int
y
,
int
range
)
{
List
<
ChartPoint
>
list
=
new
List
<
ChartPoint
>();
foreach
(
SeriesBase
item
in
_series
)
{
if
(
item
.
ScalesYAt
==
indexOfAxisY
)
{
ChartPoint
chartPoint
=
item
.
SelectByY
(
y
,
range
);
if
(
chartPoint
!=
null
)
{
if
(
list
.
Count
==
0
)
{
list
.
Add
(
chartPoint
);
}
else
if
(
chartPoint
.
Y
==
list
[
0
].
Y
)
{
list
.
Add
(
chartPoint
);
}
}
}
}
if
(
list
.
Count
>
0
)
{
return
list
.
ToArray
();
}
return
null
;
}
/// <summary>
/// Gets the points content1.
/// </summary>
/// <param name="pts">The PTS.</param>
/// <returns>System.String.</returns>
public
string
GetPointsContent1
(
ChartPoint
[]
pts
)
{
string
text
=
""
;
foreach
(
ChartPoint
chartPoint
in
pts
)
{
if
(!
string
.
IsNullOrEmpty
(
text
))
{
text
+=
"\r"
;
}
text
=
text
+
chartPoint
.
Series
.
Title
+
"("
+
chartPoint
.
GetLabelFromAxisX
()
+
" , "
+
chartPoint
.
GetLabelFromAxisY
()
+
")"
;
}
return
text
;
}
/// <summary>
/// Gets the points content2.
/// </summary>
/// <param name="pts">The PTS.</param>
/// <returns>System.String.</returns>
public
string
GetPointsContent2
(
ChartPoint
[]
pts
)
{
string
text
=
pts
[
0
].
GetLabelFromAxisX
()
??
""
;
foreach
(
ChartPoint
chartPoint
in
pts
)
{
text
=
text
+
"\r"
+
chartPoint
.
Series
.
Title
+
" : "
+
chartPoint
.
GetLabelFromAxisY
();
}
return
text
;
}
/// <summary>
/// Gets the points content3.
/// </summary>
/// <param name="pts">The PTS.</param>
/// <returns>System.String.</returns>
public
string
GetPointsContent3
(
ChartPoint
[]
pts
)
{
string
text
=
pts
[
0
].
GetLabelFromAxisY
()
??
""
;
foreach
(
ChartPoint
chartPoint
in
pts
)
{
text
=
text
+
"\r"
+
chartPoint
.
Series
.
Title
+
" : "
+
chartPoint
.
GetLabelFromAxisX
();
}
return
text
;
}
/// <summary>
/// Sets the tool tip.
/// </summary>
/// <param name="caption">The caption.</param>
public
void
SetToolTip
(
string
caption
)
{
MainToolTip
.
SetToolTip
(
this
,
caption
);
}
/// <summary>
/// 将 <see cref="P:System.Windows.Forms.Control.RightToLeft" /> 属性重置为其默认值。
/// </summary>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
[
Bindable
(
false
)]
[
EditorBrowsable
(
EditorBrowsableState
.
Never
)]
public
override
void
ResetRightToLeft
()
{
base
.
ResetRightToLeft
();
}
}
}
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
44b6ae6
...
...
@@ -46,18 +46,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\Charts\BarChart\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\Axis.cs" />
<Compile Include="Controls\Charts\AxisCollection.cs" />
<Compile Include="Controls\Charts\AxisFormat.cs" />
<Compile Include="Controls\Charts\AxisLabel.cs" />
<Compile Include="Controls\Charts\AxisPosition.cs" />
<Compile Include="Controls\Charts\AxisType.cs" />
<Compile Include="Controls\Charts\AuxiliaryLable.cs" />
<Compile Include="Controls\Charts\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\BarChart\BarChartItem.cs" />
<Compile Include="Controls\Charts\ChartPoint.cs" />
<Compile Include="Controls\Charts\ChartPointCollection.cs" />
<Compile Include="Controls\Charts\ChartPointEventArgs.cs" />
<Compile Include="Controls\Charts\ChartPointEventHandler.cs" />
<Compile Include="Controls\Charts\CurveChart\UCCurve.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\CurveChart\CurveItem.cs" />
<Compile Include="Controls\Charts\MarkText.cs" />
<Compile Include="Controls\Charts\MarkTextPositionStyle.cs" />
<Compile Include="Controls\Charts\PieChart\UCPieChart.cs">
<SubType>UserControl</SubType>
</Compile>
...
...
@@ -73,20 +70,6 @@
<Compile Include="Controls\Charts\BarChart\UCBarChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Charts\UCChart.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Charts\SelectMode.cs" />
<Compile Include="Controls\Charts\SeriesBase.cs" />
<Compile Include="Controls\Charts\SeriesCollection.cs" />
<Compile Include="Controls\Charts\SeriesCollectionEditor.cs" />
<Compile Include="Controls\Charts\SeriesFormat.cs" />
<Compile Include="Controls\Charts\Series\BezierSeries.cs" />
<Compile Include="Controls\Charts\Series\ColumnSeries.cs" />
<Compile Include="Controls\Charts\Series\LabelSeries.cs" />
<Compile Include="Controls\Charts\Series\LineSeries.cs" />
<Compile Include="Controls\Charts\Series\PointSeries.cs" />
<Compile Include="Controls\Charts\Series\StandardLineSeries.cs" />
<Compile Include="Controls\Charts\ZoomType.cs" />
<Compile Include="Controls\FactoryControls\Arrow\UCArrow.cs">
<SubType>UserControl</SubType>
...
...
@@ -936,27 +919,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbBottom.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbMiddle.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbSpanBottom.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbSpanTop.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ThumbTop.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\uparrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\downarrow.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
...
...
HZH_Controls/Test/FrmMain.Designer.cs
查看文件 @
44b6ae6
...
...
@@ -89,7 +89,7 @@
this
.
panControl
.
Name
=
"panControl"
;
this
.
panControl
.
Size
=
new
System
.
Drawing
.
Size
(
815
,
707
);
this
.
panControl
.
TabIndex
=
9
;
this
.
scrollbarComponent1
.
SetUserCustomScrollbar
(
this
.
panControl
,
tru
e
);
this
.
scrollbarComponent1
.
SetUserCustomScrollbar
(
this
.
panControl
,
fals
e
);
//
// FrmMain
//
...
...
HZH_Controls/Test/FrmMain.cs
查看文件 @
44b6ae6
...
...
@@ -65,6 +65,7 @@ namespace Test
tnCharts
.
Nodes
.
Add
(
"滚动图表"
);
tnCharts
.
Nodes
.
Add
(
"柱状图"
);
tnCharts
.
Nodes
.
Add
(
"饼状图"
);
tnCharts
.
Nodes
.
Add
(
"曲线图"
);
this
.
tvMenu
.
Nodes
.
Add
(
tnCharts
);
TreeNode
tnFactory
=
new
TreeNode
(
" 工业控件"
);
...
...
@@ -215,6 +216,9 @@ namespace Test
case
"饼状图"
:
AddControl
(
new
UC
.
UCTestPieCharts
());
break
;
case
"曲线图"
:
AddControl
(
new
UC
.
UCTestCurveChart
());
break
;
case
"滚动图表"
:
AddControl
(
new
UC
.
UCTestWaveChart
()
{
Dock
=
DockStyle
.
Fill
});
break
;
...
...
HZH_Controls/Test/Test.csproj
查看文件 @
44b6ae6
...
...
@@ -110,6 +110,12 @@
<Compile Include="UC\UCTestConveyor.Designer.cs">
<DependentUpon>UCTestConveyor.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestCurveChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestCurveChart.Designer.cs">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestIcon.cs">
<SubType>UserControl</SubType>
</Compile>
...
...
@@ -326,6 +332,9 @@
<EmbeddedResource Include="UC\UCTestConveyor.resx">
<DependentUpon>UCTestConveyor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestCurveChart.resx">
<DependentUpon>UCTestCurveChart.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestForms.resx">
<DependentUpon>UCTestForms.cs</DependentUpon>
</EmbeddedResource>
...
...
HZH_Controls/Test/UC/UCTestCurveChart.Designer.cs
0 → 100644
查看文件 @
44b6ae6
namespace
Test.UC
{
partial
class
UCTestCurveChart
{
/// <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
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
ucCurve2
=
new
HZH_Controls
.
Controls
.
UCCurve
();
this
.
ucCurve1
=
new
HZH_Controls
.
Controls
.
UCCurve
();
this
.
ucCurve3
=
new
HZH_Controls
.
Controls
.
UCCurve
();
this
.
SuspendLayout
();
//
// timer1
//
this
.
timer1
.
Enabled
=
true
;
this
.
timer1
.
Interval
=
200
;
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// ucCurve2
//
this
.
ucCurve2
.
ColorDashLines
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucCurve2
.
CurveNameWidth
=
50
;
this
.
ucCurve2
.
IntervalAbscissaText
=
20
;
this
.
ucCurve2
.
IsAbscissaStrech
=
true
;
this
.
ucCurve2
.
IsRenderRightCoordinate
=
false
;
this
.
ucCurve2
.
Location
=
new
System
.
Drawing
.
Point
(
40
,
327
);
this
.
ucCurve2
.
Name
=
"ucCurve2"
;
this
.
ucCurve2
.
Size
=
new
System
.
Drawing
.
Size
(
963
,
318
);
this
.
ucCurve2
.
StrechDataCountMax
=
100
;
this
.
ucCurve2
.
TabIndex
=
1
;
this
.
ucCurve2
.
Title
=
"动态数据"
;
//
// ucCurve1
//
this
.
ucCurve1
.
ColorDashLines
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucCurve1
.
IntervalAbscissaText
=
-
1
;
this
.
ucCurve1
.
IsAbscissaStrech
=
true
;
this
.
ucCurve1
.
Location
=
new
System
.
Drawing
.
Point
(
40
,
22
);
this
.
ucCurve1
.
Name
=
"ucCurve1"
;
this
.
ucCurve1
.
Size
=
new
System
.
Drawing
.
Size
(
963
,
299
);
this
.
ucCurve1
.
StrechDataCountMax
=
7
;
this
.
ucCurve1
.
TabIndex
=
0
;
this
.
ucCurve1
.
Title
=
"一周生产"
;
//
// ucCurve3
//
this
.
ucCurve3
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
243
)))),
((
int
)(((
byte
)(
220
)))),
((
int
)(((
byte
)(
219
)))));
this
.
ucCurve3
.
ColorDashLines
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
50
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucCurve3
.
ColorLinesAndText
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucCurve3
.
CurveNameWidth
=
50
;
this
.
ucCurve3
.
ForeColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
150
)))),
((
int
)(((
byte
)(
255
)))),
((
int
)(((
byte
)(
77
)))),
((
int
)(((
byte
)(
59
)))));
this
.
ucCurve3
.
IntervalAbscissaText
=
-
1
;
this
.
ucCurve3
.
IsAbscissaStrech
=
true
;
this
.
ucCurve3
.
IsRenderRightCoordinate
=
false
;
this
.
ucCurve3
.
Location
=
new
System
.
Drawing
.
Point
(
40
,
651
);
this
.
ucCurve3
.
Name
=
"ucCurve3"
;
this
.
ucCurve3
.
Size
=
new
System
.
Drawing
.
Size
(
963
,
534
);
this
.
ucCurve3
.
StrechDataCountMax
=
6
;
this
.
ucCurve3
.
TabIndex
=
1
;
this
.
ucCurve3
.
Title
=
"小明模拟考试成绩走势"
;
this
.
ucCurve3
.
ValueSegment
=
10
;
//
// UCTestCurveChart
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
Controls
.
Add
(
this
.
ucCurve3
);
this
.
Controls
.
Add
(
this
.
ucCurve2
);
this
.
Controls
.
Add
(
this
.
ucCurve1
);
this
.
Name
=
"UCTestCurveChart"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
1041
,
1239
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
UCTestCurveChart_Load
);
this
.
ResumeLayout
(
false
);
}
#
endregion
private
HZH_Controls
.
Controls
.
UCCurve
ucCurve1
;
private
HZH_Controls
.
Controls
.
UCCurve
ucCurve2
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
private
HZH_Controls
.
Controls
.
UCCurve
ucCurve3
;
}
}
HZH_Controls/Test/UC/UCTestCurveChart.cs
0 → 100644
查看文件 @
44b6ae6
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
Test.UC
{
public
partial
class
UCTestCurveChart
:
UserControl
{
public
UCTestCurveChart
()
{
InitializeComponent
();
}
private
void
UCTestCurveChart_Load
(
object
sender
,
EventArgs
e
)
{
Random
r
=
new
Random
();
this
.
ucCurve1
.
SetCurveText
(
new
string
[]
{
"周一"
,
"周二"
,
"周三"
,
"周四"
,
"周五"
,
"周六"
,
"周日"
});
float
[]
data1
=
new
float
[
7
];
float
[]
data2
=
new
float
[
7
];
float
[]
data3
=
new
float
[
7
];
for
(
int
i
=
0
;
i
<
data1
.
Length
;
i
++)
{
data1
[
i
]
=
r
.
Next
(
0
,
100
);
data2
[
i
]
=
r
.
Next
(
0
,
100
);
data3
[
i
]
=
r
.
Next
(
0
,
100
);
}
ucCurve1
.
SetLeftCurve
(
"A"
,
data1
);
ucCurve1
.
SetLeftCurve
(
"B"
,
data2
);
ucCurve1
.
SetLeftCurve
(
"C"
,
data3
);
//辅助文字
ucCurve1
.
AddMarkText
(
"A"
,
0
,
"周一数据"
,
Color
.
Red
);
ucCurve1
.
AddMarkText
(
"A"
,
1
,
"周二数据"
);
ucCurve1
.
AddMarkText
(
"B"
,
0
,
"周一数据"
);
ucCurve1
.
AddMarkText
(
"B"
,
1
,
"周二数据"
);
ucCurve1
.
AddAuxiliaryLabel
(
new
HZH_Controls
.
Controls
.
AuxiliaryLable
()
{
LocationX
=
0.8f
,
Text
=
"不合格数:5"
,
TextBack
=
Brushes
.
Red
,
TextBrush
=
Brushes
.
White
});
ucCurve1
.
AddLeftAuxiliary
(
20
,
Color
.
Red
);
ucCurve2
.
SetLeftCurve
(
"A"
,
null
,
Color
.
Red
);
ucCurve2
.
SetLeftCurve
(
"B"
,
null
,
Color
.
Orange
);
ucCurve2
.
SetLeftCurve
(
"C"
,
null
,
Color
.
Blue
);
ucCurve2
.
SetLeftCurve
(
"D"
,
null
,
Color
.
Green
);
this
.
ucCurve3
.
SetCurveText
(
new
string
[]
{
"第一次模拟"
,
"第二次模拟"
,
"第三次模拟"
,
"第四次模拟"
,
"第五次模拟"
,
"第六次模拟"
,
"第七次模拟"
});
float
[]
data31
=
new
float
[
6
];
float
[]
data32
=
new
float
[
6
];
float
[]
data33
=
new
float
[
6
];
float
[]
data34
=
new
float
[
6
];
float
[]
data35
=
new
float
[
6
];
float
[]
data36
=
new
float
[
6
];
for
(
int
i
=
0
;
i
<
data31
.
Length
;
i
++)
{
data31
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
data32
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
data33
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
data34
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
data35
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
data36
[
i
]
=
r
.
Next
(
10
+
i
*
10
,
40
+
i
*
10
);
}
ucCurve3
.
SetLeftCurve
(
"语文"
,
data31
);
ucCurve3
.
SetLeftCurve
(
"数学"
,
data32
);
ucCurve3
.
SetLeftCurve
(
"英语"
,
data33
);
ucCurve3
.
SetLeftCurve
(
"化学"
,
data34
);
ucCurve3
.
SetLeftCurve
(
"生物"
,
data35
);
ucCurve3
.
SetLeftCurve
(
"物理"
,
data36
);
for
(
int
i
=
0
;
i
<
data31
.
Length
;
i
++)
{
ucCurve3
.
AddMarkText
(
"语文"
,
i
,
data31
[
i
].
ToString
());
ucCurve3
.
AddMarkText
(
"数学"
,
i
,
data32
[
i
].
ToString
());
ucCurve3
.
AddMarkText
(
"英语"
,
i
,
data33
[
i
].
ToString
());
ucCurve3
.
AddMarkText
(
"化学"
,
i
,
data34
[
i
].
ToString
());
ucCurve3
.
AddMarkText
(
"生物"
,
i
,
data35
[
i
].
ToString
());
ucCurve3
.
AddMarkText
(
"物理"
,
i
,
data36
[
i
].
ToString
());
}
}
int
count_tick
=
0
;
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
count_tick
++;
float
random1
=
(
float
)(
Math
.
Sin
(
2
*
Math
.
PI
*
count_tick
/
30
)
*
0.5d
+
0.5
);
float
random2
=
(
float
)(
Math
.
Sin
(
2
*
Math
.
PI
*
count_tick
/
50
)
*
0.5d
+
0.5
);
float
random3
=
(
float
)(
Math
.
Cos
(
2
*
Math
.
PI
*
count_tick
/
80
)
*
0.5d
+
0.5
);
float
random4
=
(
float
)(
Math
.
Cos
(
2
*
Math
.
PI
*
count_tick
/
10
)
*
0.5d
+
0.5
);
if
(
count_tick
%
50
==
0
)
{
ucCurve2
.
AddCurveData
(
new
string
[]
{
"A"
,
"B"
,
"C"
,
"D"
},
new
float
[]
{
random1
*
10
+
80
,
random2
*
20
+
50
,
random3
*
20
+
30
,
random4
*
10
+
20
,
},
new
string
[]
{
"标签1"
,
"标签2"
,
"标签3"
,
"标签4"
}
);
}
else
{
ucCurve2
.
AddCurveData
(
new
string
[]
{
"A"
,
"B"
,
"C"
,
"D"
},
new
float
[]
{
random1
*
10
+
80
,
random2
*
20
+
50
,
random3
*
20
+
30
,
random4
*
10
+
20
,
}
);
}
if
(
count_tick
>
10000
)
count_tick
=
0
;
}
}
}
HZH_Controls/Test/UC/UCTestCurveChart.resx
0 → 100644
查看文件 @
44b6ae6
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论