You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
787 lines
22 KiB
C#
787 lines
22 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Steema.TeeChart.Styles;
|
|
|
|
namespace Mesnac.Controls.Sulf
|
|
{
|
|
[ToolboxBitmap(typeof(LineChart), "ICONS.TraceLine.bmp")]
|
|
public partial class RadarChart : UserControl
|
|
{
|
|
private int _num = 28800; //保持的点数
|
|
private bool _isShowTime = false; //是否显示时间刻度
|
|
private string _timeformat = "{0:HH:mm:ss}"; //时间格式
|
|
Polar[] list = new Polar[8]; //曲线集合
|
|
int times = 2;//计数器
|
|
Timer timer = new Timer();
|
|
string datetime = string.Empty;
|
|
double AngleForpersec,Angle;
|
|
|
|
|
|
public RadarChart()
|
|
{
|
|
InitializeComponent();
|
|
this.InitMethod();
|
|
timer.Enabled = true;
|
|
timer.Interval = 1000;
|
|
timer.Tick += new EventHandler(timer_Tick);
|
|
}
|
|
|
|
//protected override void OnLoad(EventArgs e)
|
|
//{
|
|
// base.OnLoad(e);
|
|
// this.InitMethod();
|
|
//}
|
|
|
|
void timer_Tick(object sender, EventArgs e)
|
|
{
|
|
times++;
|
|
if (times == 4)
|
|
{
|
|
times = 1;
|
|
}
|
|
}
|
|
|
|
public void InitMethod()
|
|
{
|
|
this.tChart1.Series.Clear();
|
|
this.tChart1.Axes.Top.Grid.ZPosition = 0D;
|
|
this.tChart1.BackColor = System.Drawing.Color.Transparent;
|
|
this.tChart1.Cursor = System.Windows.Forms.Cursors.Default;
|
|
this.tChart1.Axes.Left.Automatic = false;
|
|
this.tChart1.Axes.Bottom.Grid.Visible = false;
|
|
//this.tChart1.Axes.Bottom.Automatic = false;
|
|
//this.tChart1.Axes.Top.Automatic = false;
|
|
//this.tChart1.Axes.Right.Automatic = false;
|
|
this.tChart1.Axes.Left.SetMinMax(0, 200);
|
|
this.tChart1.Axes.Bottom.SetMinMax(0, 100);
|
|
this.tChart1.Aspect.View3D = false;
|
|
this.IsShowLegend = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始数据
|
|
/// </summary>
|
|
public DataTable InitData0
|
|
{
|
|
set
|
|
{
|
|
if (value != null)
|
|
{
|
|
DataTable dt = (DataTable)value;
|
|
Clear();
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (list[0] != null)
|
|
this.list[0].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][1].ToString()));
|
|
if (list[1] != null)
|
|
this.list[1].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][2].ToString()));
|
|
if (list[2] != null)
|
|
this.list[2].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][3].ToString()));
|
|
if (list[3] != null)
|
|
this.list[3].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][4].ToString()));
|
|
if (list[4] != null)
|
|
this.list[4].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][5].ToString()));
|
|
if (list[5] != null)
|
|
this.list[5].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][6].ToString()));
|
|
if (list[6] != null)
|
|
this.list[6].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][7].ToString()));
|
|
if (list[7] != null)
|
|
this.list[7].Add(getAngle(Convert.ToDateTime(dt.Rows[i][0].ToString())), double.Parse(dt.Rows[i][8].ToString()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void InitPointValue(double value, int i)
|
|
{
|
|
if (this.list[i] == null)
|
|
{
|
|
list[i] = new Polar();
|
|
list[i].ShowInLegend = false;
|
|
this.tChart1.Series.Add(list[i]);
|
|
}
|
|
if (this.list[i].Count >= this._num)
|
|
{
|
|
this.list[i].Delete(0, 1, true);
|
|
}
|
|
if (this._isShowTime)
|
|
{
|
|
this.list[i].Add(value, String.Format(this._timeformat, DateTime.Now));
|
|
}
|
|
else
|
|
{
|
|
this.list[i].Add(value);
|
|
}
|
|
}
|
|
|
|
#region bHaveAction
|
|
|
|
private bool _bHaveAction;
|
|
public bool bHaveAction
|
|
{
|
|
get
|
|
{
|
|
return _bHaveAction;
|
|
}
|
|
set
|
|
{
|
|
_bHaveAction = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
[Category("曲线设置"), Description("曲线的标题,可修改.")]
|
|
public string Title
|
|
{
|
|
get
|
|
{
|
|
|
|
return this.tChart1.Text;
|
|
}
|
|
set
|
|
{
|
|
this.tChart1.Text = value == null ? String.Empty : value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 是否显示时间刻度
|
|
/// </summary>
|
|
[Description("是否显示时间"), Category("外观")]
|
|
public bool IsShowTime
|
|
{
|
|
get { return this._isShowTime; }
|
|
set { this._isShowTime = value; }
|
|
}
|
|
/// <summary>
|
|
/// 是否显示图表列表
|
|
/// </summary>
|
|
[Description("是否显示图表"), Category("外观")]
|
|
public bool IsShowChartList
|
|
{
|
|
get { return this.chartListBox1.Visible; }
|
|
set { this.chartListBox1.Visible = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保持的点数
|
|
/// </summary>
|
|
|
|
[Description("保持的点数"), Category("外观")]
|
|
public int Num
|
|
{
|
|
get { return this._num; }
|
|
set
|
|
{
|
|
this._num = value;
|
|
//if (this._num < 10)
|
|
//{
|
|
// this._num = 10;
|
|
//}
|
|
//if (this._num > 1000)
|
|
//{
|
|
// this._num = 1000;
|
|
//}
|
|
}
|
|
}
|
|
|
|
private void SetCurveName(string value, int i)
|
|
{
|
|
|
|
if (String.IsNullOrWhiteSpace(value))
|
|
{
|
|
if (list[i] != null)
|
|
{
|
|
this.tChart1.Series.Remove(list[i]);
|
|
list[i].Dispose();
|
|
list[i] = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list[i] == null)
|
|
{
|
|
list[i] = new Polar();
|
|
list[i].Brush.Visible = false;
|
|
list[i].Pointer.Visible = false;
|
|
list[i].ShowInLegend = false;
|
|
list[i].CloseCircle = false;
|
|
list[i].Marks.Callout.Draw3D = false;
|
|
this.tChart1.Series.Add(list[i]);
|
|
}
|
|
list[i].Title = value;
|
|
list[i].Visible = true;
|
|
}
|
|
}
|
|
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName1
|
|
{
|
|
get
|
|
{
|
|
return list[0] == null ? String.Empty : list[0].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 0);
|
|
}
|
|
}
|
|
|
|
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName2
|
|
{
|
|
get
|
|
{
|
|
return list[1] == null ? String.Empty : list[1].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 1);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName3
|
|
{
|
|
get
|
|
{
|
|
return list[2] == null ? String.Empty : list[2].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 2);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName4
|
|
{
|
|
get
|
|
{
|
|
return list[3] == null ? String.Empty : list[3].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 3);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName5
|
|
{
|
|
get
|
|
{
|
|
return list[4] == null ? String.Empty : list[4].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 4);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName6
|
|
{
|
|
get
|
|
{
|
|
return list[5] == null ? String.Empty : list[5].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 5);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName7
|
|
{
|
|
get
|
|
{
|
|
return list[6] == null ? String.Empty : list[6].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 6);
|
|
}
|
|
}
|
|
[Category("曲线名"), Description("曲线的名称,可修改.")]
|
|
public string CurveName8
|
|
{
|
|
get
|
|
{
|
|
return list[7] == null ? String.Empty : list[7].Title;
|
|
}
|
|
set
|
|
{
|
|
SetCurveName(value, 7);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
public string MCDataSourceID
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
#region 动画属性
|
|
|
|
private string[] _pointName = new string[8];
|
|
|
|
public string PointName1
|
|
{
|
|
get { return this._pointName[0]; }
|
|
set { this._pointName[0] = value; }
|
|
}
|
|
|
|
public string PointName2
|
|
{
|
|
get { return this._pointName[1]; }
|
|
set { this._pointName[1] = value; }
|
|
}
|
|
|
|
public string PointName3
|
|
{
|
|
get { return this._pointName[2]; }
|
|
set { this._pointName[2] = value; }
|
|
}
|
|
|
|
public string PointName4
|
|
{
|
|
get { return this._pointName[3]; }
|
|
set { this._pointName[3] = value; }
|
|
}
|
|
|
|
public string PointName5
|
|
{
|
|
get { return this._pointName[4]; }
|
|
set { this._pointName[4] = value; }
|
|
}
|
|
|
|
public string PointName6
|
|
{
|
|
get { return this._pointName[5]; }
|
|
set { this._pointName[5] = value; }
|
|
}
|
|
|
|
public string PointName7
|
|
{
|
|
get { return this._pointName[6]; }
|
|
set { this._pointName[6] = value; }
|
|
}
|
|
|
|
public string PointName8
|
|
{
|
|
get { return this._pointName[7]; }
|
|
set { this._pointName[7] = value; }
|
|
}
|
|
|
|
private void SetPointValue(double value, int i)
|
|
{
|
|
if (this.list[i] == null)
|
|
{
|
|
list[i] = new Polar();
|
|
list[i].Brush.Visible = false;
|
|
list[i].Pointer.Visible = false;
|
|
list[i].ShowInLegend = false;
|
|
this.tChart1.Series.Add(list[i]);
|
|
}
|
|
if (this.list[i].Count >= this._num)
|
|
{
|
|
this.list[i].Delete(0, 1, true);
|
|
}
|
|
if (this._isShowTime)
|
|
{
|
|
this.list[i].Add(getAngle(DateTime.Now),value);
|
|
}
|
|
else
|
|
{
|
|
this.list[i].Add(value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取角度
|
|
/// </summary>
|
|
/// <param name="time"></param>
|
|
/// <returns></returns>
|
|
double getAngle(DateTime time)
|
|
{
|
|
AngleForpersec = 360.0000/(24.0000*3600.0000);
|
|
Angle = (time.Hour * 3600 + time.Minute * 60 + time.Second) * AngleForpersec * (-1) + 90;
|
|
return Angle;
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
for (int i = 0; i < list.Length; i++)
|
|
{
|
|
if (this.list[i] != null)
|
|
this.list[i].Clear();
|
|
}
|
|
}
|
|
|
|
public double PointValue1
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue2
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue3
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue4
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 3);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue5
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 4);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue6
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 5);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue7
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 6);
|
|
}
|
|
}
|
|
}
|
|
|
|
public double PointValue8
|
|
{
|
|
set
|
|
{
|
|
if (times % 3 == 0)
|
|
{
|
|
SetPointValue(value, 7);
|
|
}
|
|
}
|
|
}
|
|
private bool _isShowLegend = true; //是否显示图例
|
|
/// <summary>
|
|
/// 是否显示图例
|
|
/// </summary>
|
|
[Description("显示图例"), Category("外观")]
|
|
public bool IsShowLegend
|
|
{
|
|
get { return _isShowLegend; }
|
|
set
|
|
{
|
|
_isShowLegend = value;
|
|
foreach (Polar line in this.list)
|
|
{
|
|
if (line != null)
|
|
{
|
|
line.ShowInLegend = _isShowLegend;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 颜色设置
|
|
/// <summary>
|
|
/// 获取默认颜色
|
|
/// </summary>
|
|
/// <param name="i">曲线索引</param>
|
|
/// <returns>返回默认颜色</returns>
|
|
private Color GetDefaultColor(int i)
|
|
{
|
|
Color[] _colors = { Color.Red, Color.Green, Color.Purple, Color.Blue, Color.Black, Color.FromArgb(0x7b, 0x68, 0xee), Color.FromArgb(0xcd, 0x5c, 0x5c), Color.FromArgb(0xdb, 0x70, 0x93), Color.FromArgb(0x5f, 0x9e, 0xa0), Color.FromArgb(0xdd, 0xa0, 0xdd), Color.FromArgb(0x90, 0xee, 0x90), Color.FromArgb(0xff, 0x00, 0xff), Color.FromArgb(0x48, 0xd1, 0xcc) };
|
|
if (i >= _colors.Length - 1)
|
|
{
|
|
return Color.Red;
|
|
}
|
|
return _colors[i];
|
|
}
|
|
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue1
|
|
{
|
|
get
|
|
{
|
|
if (this.list[0] != null)
|
|
return this.list[0].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(0); //默认红色
|
|
}
|
|
set
|
|
{
|
|
if (this.list[0] != null)
|
|
{
|
|
this.list[0].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue2
|
|
{
|
|
get
|
|
{
|
|
if (this.list[1] != null)
|
|
return this.list[1].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(1); //默认绿色
|
|
}
|
|
set
|
|
{
|
|
if (this.list[1] != null)
|
|
{
|
|
this.list[1].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue3
|
|
{
|
|
get
|
|
{
|
|
if (this.list[2] != null)
|
|
return this.list[2].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(2); //默认紫色
|
|
}
|
|
set
|
|
{
|
|
if (this.list[2] != null)
|
|
{
|
|
this.list[2].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue4
|
|
{
|
|
get
|
|
{
|
|
if (this.list[3] != null)
|
|
return this.list[3].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(3); //默认蓝色
|
|
}
|
|
set
|
|
{
|
|
if (this.list[3] != null)
|
|
{
|
|
this.list[3].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue5
|
|
{
|
|
get
|
|
{
|
|
if (this.list[4] != null)
|
|
return this.list[4].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(4); //默认黑色
|
|
}
|
|
set
|
|
{
|
|
if (this.list[4] != null)
|
|
{
|
|
this.list[4].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue6
|
|
{
|
|
get
|
|
{
|
|
if (this.list[5] != null)
|
|
return this.list[5].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(5);
|
|
}
|
|
set
|
|
{
|
|
if (this.list[5] != null)
|
|
{
|
|
this.list[5].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue7
|
|
{
|
|
get
|
|
{
|
|
if (this.list[6] != null)
|
|
return this.list[6].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(6);
|
|
}
|
|
set
|
|
{
|
|
if (this.list[6] != null)
|
|
{
|
|
this.list[6].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
public Color ColorValue8
|
|
{
|
|
get
|
|
{
|
|
if (this.list[7] != null)
|
|
return this.list[7].Pen.Color;
|
|
else
|
|
return this.GetDefaultColor(7);
|
|
}
|
|
set
|
|
{
|
|
if (this.list[7] != null)
|
|
{
|
|
this.list[7].Pen.Color = value;
|
|
}
|
|
}
|
|
}
|
|
public string LabTyreNo
|
|
{
|
|
get
|
|
{
|
|
return this.label1.Text;
|
|
}
|
|
set
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(value))
|
|
this.label1.Text = value;
|
|
}
|
|
}
|
|
|
|
private void tChart1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
//[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
//public Color ColorValue9
|
|
//{
|
|
// get
|
|
// {
|
|
// if (this.list[8] != null)
|
|
// return this.list[8].LinePen.Color;
|
|
// else
|
|
// return this.GetDefaultColor(8);
|
|
// }
|
|
// set
|
|
// {
|
|
// if (this.list[8] != null)
|
|
// {
|
|
// this.list[8].LinePen.Color = value;
|
|
// }
|
|
// }
|
|
//}
|
|
//[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
//public Color ColorValue10
|
|
//{
|
|
// get
|
|
// {
|
|
// if (this.list[9] != null)
|
|
// return this.list[9].LinePen.Color;
|
|
// else
|
|
// return this.GetDefaultColor(9);
|
|
// }
|
|
// set
|
|
// {
|
|
// if (this.list[9] != null)
|
|
// {
|
|
// this.list[9].LinePen.Color = value;
|
|
// }
|
|
// }
|
|
//}
|
|
//[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
//public Color ColorValue11
|
|
//{
|
|
// get
|
|
// {
|
|
// if (this.list[10] != null)
|
|
// return this.list[10].LinePen.Color;
|
|
// else
|
|
// return this.GetDefaultColor(10);
|
|
// }
|
|
// set
|
|
// {
|
|
// if (this.list[10] != null)
|
|
// {
|
|
// this.list[10].LinePen.Color = value;
|
|
// }
|
|
// }
|
|
//}
|
|
//[Category("曲线颜色"), Description("曲线颜色,可修改.")]
|
|
//public Color ColorValue12
|
|
//{
|
|
// get
|
|
// {
|
|
// if (this.list[11] != null)
|
|
// return this.list[11].LinePen.Color;
|
|
// else
|
|
// return this.GetDefaultColor(11);
|
|
// }
|
|
// set
|
|
// {
|
|
// if (this.list[11] != null)
|
|
// {
|
|
// this.list[11].LinePen.Color = value;
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|