using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using Steema.TeeChart.Styles; using Mesnac.Controls.Base; using Steema.TeeChart; namespace Mesnac.Controls.Default { [ToolboxBitmap(typeof(MultiCurveMove), "ICONS.TraceLine.bmp")] public partial class MultiCurveMove : UserControl { #region 类型定义 /// /// 曲线类别 /// public enum CurveTypes { /// /// 超过设定点数累加 /// Accumulate = 0, /// /// 超过设定点数平移 /// Pan = 1 } #endregion #region 字段定义 private int _defaultNum = 180; //默认保持的点数 private const int LINENUM = 12; //支持的最大曲线数 private int _num = 200; //保持的点数 private CurveTypes _curveType = CurveTypes.Accumulate; //曲线类别 private bool _isShowTime = false; //是否显示时间刻度 private bool _isShowLegend = true; //是否显示图例 private LegendAlignments _legendPosition = LegendAlignments.Right; //图例位置 private bool _isShowCharList = false; //是否显示图例控件 private bool _isShowCommander = false; //是否显示工具栏 private int _charListWidth = 100; //图例控件的宽度 private string _timeformat = "{0:HH:mm:ss}"; //时间格式 FastLine[] list = new FastLine[LINENUM]; //曲线集合 private bool _isUseMixTime = false; //是否关联密炼时间 private int _mixTime = 0; //密炼时间 private string _mixTimeName = String.Empty; //密炼时间动画 private bool _isMove = false; //是否执行拖拽操作 private int _lineWidth = 1; //线条宽度 private string _chartName; //显示曲线标题 //曲线设备变量替换属性 private string _replaceStr1;// private string _replaceStr2;// private string _replaceStr3;// private string _replaceStr4;// private string _replaceStr5;// private string _replaceStr6;// private string _replaceStr7;// private string _replaceStr8;// private string _replaceStr9;// private string _replaceStr10;// private string _replaceStr11;// private string _replaceStr12;// #endregion #region 构造方法 public MultiCurveMove() { InitializeComponent(); this.InitMethod(); } #endregion #region 辅助方法 /// /// 初始化方法 /// public void InitMethod() { this.tChart1.Series.Clear(); this.tChart1.Legend.Alignment = LegendAlignments.Right; this.tChart1.Legend.Visible = true; this.tChart1.Axes.Bottom.Automatic = false; //默认已累加方式显示曲线 this.tChart1.Axes.Bottom.Maximum = this._num; this.chartListBox1.Visible = this._isShowCharList; this.commander1.Visible = this._isShowCommander; //this.button1.Text = "曲线综合展示"; //悬浮拖动 变化位置 this.button1.MouseDown += new MouseEventHandler(MultiCurveMove_MouseDown); this.button1.MouseLeave += new EventHandler(MultiCurveMove_MouseLeave); this.button1.MouseMove += new MouseEventHandler(MultiCurveMove_MouseMove); } 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 FastLine(); list[i].ShowInLegend = this._isShowLegend; //if (value.Contains("率")) // list[i].VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right; list[i].LinePen.Width = this._lineWidth; //设置线条宽度 this.tChart1.Series.Add(list[i]); } list[i].Title = value; list[i].Visible = true; } } #endregion #region 拖动 const int Band = 5; const int MinWidth = 50; const int MinHeight = 60; /// /// 鼠标在事件源的位置 /// private Point p = new Point(); private Point p1 = new Point(); private enum EnumMousePointPosition { MouseSizeNone = 0, //'无 MouseSizeRight = 1, //'拉伸右边框 MouseSizeLeft = 2, //'拉伸左边框 MouseSizeBottom = 3, //'拉伸下边框 MouseSizeTop = 4, //'拉伸上边框 MouseSizeTopLeft = 5, //'拉伸左上角 MouseSizeTopRight = 6, //'拉伸右上角 MouseSizeBottomLeft = 7, //'拉伸左下角 MouseSizeBottomRight = 8, //'拉伸右下角 MouseDrag = 9 // '鼠标拖动 } private EnumMousePointPosition m_MousePointPosition; void MultiCurveMove_MouseDown(object sender, MouseEventArgs e) { p.X = e.X; p.Y = e.Y; p1.X = e.X; p1.Y = e.Y; } void MultiCurveMove_MouseLeave(object sender, EventArgs e) { m_MousePointPosition = EnumMousePointPosition.MouseSizeNone; this.Cursor = Cursors.Arrow; } void MultiCurveMove_MouseMove(object sender, MouseEventArgs e) { int ParentWidth = this.Parent.Width; int ParentHeight = this.Parent.Height; int GridWidth = this.Width; int GridHeight = this.Height; Control lCtrl = (sender as Control); Control Ctrl = lCtrl.Parent as Control; if (e.Button == MouseButtons.Left) { switch (m_MousePointPosition) { case EnumMousePointPosition.MouseDrag: #region 设置拖动范围,当超出一定范围时,自动复原 if (this.Left > ParentWidth - GridWidth) { this.Left = ParentWidth - GridWidth; return; } if (this.Top > ParentHeight - GridHeight) { this.Top = ParentHeight - GridHeight; return; } #endregion this.Left = this.Left + e.X - p.X; this.Top = this.Top + e.Y - p.Y; break; default: break; } if (this.Width < MinWidth) Ctrl.Width = MinWidth; if (this.Height < MinHeight) Ctrl.Height = MinHeight; } else { m_MousePointPosition = MousePointPosition(Ctrl.Size, e); //'判断光标的位置状态 switch (m_MousePointPosition) //'改变光标 { case EnumMousePointPosition.MouseSizeNone: this.Cursor = Cursors.Arrow; //'箭头 break; case EnumMousePointPosition.MouseDrag: this.Cursor = Cursors.SizeAll; //'四方向 break; case EnumMousePointPosition.MouseSizeRight: this.Cursor = Cursors.SizeWE; //东西 break; case EnumMousePointPosition.MouseSizeLeft: this.Cursor = Cursors.SizeWE; //东西 break; case EnumMousePointPosition.MouseSizeBottom: this.Cursor = Cursors.SizeNS; //'南北 break; default: break; } } //再次确认控件位置,超出屏幕则复原 if (this.Left > ParentWidth - GridWidth) { this.Left = ParentWidth - GridWidth; return; } if (this.Top > ParentHeight - GridHeight) { this.Top = ParentHeight - GridHeight; return; } } private EnumMousePointPosition MousePointPosition(Size size, System.Windows.Forms.MouseEventArgs e) { if ((e.X >= -1 * Band) | (e.X <= size.Width) | (e.Y >= -1 * Band) | (e.Y <= size.Height)) { if (e.X < Band) { if (e.Y < Band) { return EnumMousePointPosition.MouseSizeNone; } else { if (e.Y > -1 * Band + size.Height) { return EnumMousePointPosition.MouseSizeNone; } else { return EnumMousePointPosition.MouseSizeLeft; } } } else { if (e.X > -1 * Band + size.Width) { if (e.Y < Band) { return EnumMousePointPosition.MouseSizeNone; } else { if (e.Y > -1 * Band + size.Height) { return EnumMousePointPosition.MouseSizeNone; } else { return EnumMousePointPosition.MouseSizeRight; } } } else { if (e.Y < Band) { return EnumMousePointPosition.MouseSizeNone; } else { if (e.Y > -1 * Band + size.Height) { return EnumMousePointPosition.MouseSizeBottom; } else { return EnumMousePointPosition.MouseDrag; } } } } } else { return EnumMousePointPosition.MouseSizeNone; } } #endregion #region bHaveAction private bool _bHaveAction; public bool bHaveAction { get { return _bHaveAction; } set { _bHaveAction = value; } } #endregion #region 基本属性 /// /// 数据源 /// [TypeConverter(typeof(DataSourceConverter))] public string MCDataSourceID { get; set; } [Description("曲线的标题,可修改."), Category("Appearance")] public string Title { get { return this.tChart1.Text; } set { this.tChart1.Text = value == null ? String.Empty : value; } } /// /// 是否显示时间刻度 /// [Description("是否显示时间"), Category("Appearance")] public bool IsShowTime { get { return this._isShowTime; } set { this._isShowTime = value; } } /// /// 是否显示图例 /// [Description("显示图例"), Category("Appearance")] public bool IsShowLegend { get { return _isShowLegend; } set { _isShowLegend = value; foreach (FastLine line in this.list) { if (line != null) { line.ShowInLegend = _isShowLegend; } } } } /// /// 图例位置 /// [Description("图例位置"), Category("Appearance")] public LegendAlignments LegendPosition { get { return _legendPosition; } set { _legendPosition = value; this.tChart1.Legend.Alignment = _legendPosition; } } /// /// 是否显示图表列表 /// [Description("显示图例列表控件"), Category("Appearance")] public bool IsShowChartList { get { return this._isShowCharList; } set { this._isShowCharList = value; this.chartListBox1.Visible = value; } } /// /// 图例列表宽度 /// [Description("图例列表宽度"), Category("Appearance")] public int CharListWidth { get { return _charListWidth; } set { _charListWidth = value; this.chartListBox1.Width = value; } } /// /// 是否显示工具栏 /// [Description("是否显示工具栏"), Category("Behavior")] public bool IsShowCommander { get { return this._isShowCommander; } set { this._isShowCommander = value; this.commander1.Visible = value; } } [Description("是否允许拖拽"), Category("Behavior")] public bool IsMove { get { return _isMove; } set { _isMove = value; if (this._isMove) { this.tChart1.MouseDown += new MouseEventHandler(MultiCurveMove_MouseDown); this.tChart1.MouseLeave += new EventHandler(MultiCurveMove_MouseLeave); this.tChart1.MouseMove += new MouseEventHandler(MultiCurveMove_MouseMove); } else { this.tChart1.MouseDown -= new MouseEventHandler(MultiCurveMove_MouseDown); this.tChart1.MouseLeave -= new EventHandler(MultiCurveMove_MouseLeave); this.tChart1.MouseMove -= new MouseEventHandler(MultiCurveMove_MouseMove); } } } /// /// 默认点数 /// [Description("默认点数"), Category("Appearance")] public int DefaultNum { get { return _defaultNum; } set { _defaultNum = value; } } /// /// 保持的点数 /// [Description("保持的点数"), Category("Appearance")] 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; } this.tChart1.Axes.Bottom.Maximum = this._num; } } /// /// 线条宽度 /// [Description("线条宽度"), Category("Appearance")] public int LineWidth { get { return _lineWidth; } set { _lineWidth = value; } } /// /// 曲线状态 /// [Description("曲线状态"), Category("Appearance")] public CurveTypes CurveType { get { return _curveType; } set { _curveType = value; if (_curveType == CurveTypes.Pan) { this.tChart1.Axes.Bottom.Automatic = true; } else { this.tChart1.Axes.Bottom.Automatic = false; this.tChart1.Axes.Bottom.Maximum = this._num; } } } /// /// 是否关联密炼时间 /// [Description("关联密炼时间"), Category("Behavior")] public bool IsUseMixTime { get { return _isUseMixTime; } set { _isUseMixTime = value; } } /// /// 密炼时间 /// [Description("密炼时间"), Category("Behavior")] public int MixTime { get { return _mixTime; } set { _mixTime = value; } } #endregion #region 曲线名称属性定义 [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName1 { get { return list[0] == null ? String.Empty : list[0].Title; } set { SetCurveName(value, 0); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName2 { get { return list[1] == null ? String.Empty : list[1].Title; } set { SetCurveName(value, 1); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName3 { get { return list[2] == null ? String.Empty : list[2].Title; } set { SetCurveName(value, 2); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName4 { get { return list[3] == null ? String.Empty : list[3].Title; } set { SetCurveName(value, 3); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName5 { get { return list[4] == null ? String.Empty : list[4].Title; } set { SetCurveName(value, 4); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName6 { get { return list[5] == null ? String.Empty : list[5].Title; } set { SetCurveName(value, 5); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName7 { get { return list[6] == null ? String.Empty : list[6].Title; } set { SetCurveName(value, 6); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName8 { get { return list[7] == null ? String.Empty : list[7].Title; } set { SetCurveName(value, 7); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName9 { get { return list[8] == null ? String.Empty : list[8].Title; } set { SetCurveName(value, 8); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName10 { get { return list[9] == null ? String.Empty : list[9].Title; } set { SetCurveName(value, 9); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName11 { get { return list[10] == null ? String.Empty : list[10].Title; } set { SetCurveName(value, 10); } } [Category("Data"), Description("曲线的名称,可修改.")] public string CurveName12 { get { return list[11] == null ? String.Empty : list[11].Title; } set { SetCurveName(value, 11); } } /// /// 设定开机名称 /// public string ChartName { get { return _chartName; } set { if (value != null) { _chartName = value; this.button1.Text = value.Remove(0, 2) + "#开炼机"; } } } #endregion #region 垂直坐标系属性定义 [Category("Data"), Description("垂直坐标1,可修改.")] public VerticalAxis VertAxis1 { get { return this.list[0] == null ? VerticalAxis.Left : this.list[0].VertAxis; } set { if (this.list[0] != null) { this.list[0].VertAxis = value; } } } [Category("Data"), Description("垂直坐标2,可修改.")] public VerticalAxis VertAxis2 { get { return this.list[1] == null ? VerticalAxis.Left : this.list[1].VertAxis; } set { if (this.list[1] != null) { this.list[1].VertAxis = value; } } } [Category("Data"), Description("垂直坐标3,可修改.")] public VerticalAxis VertAxis3 { get { return this.list[2] == null ? VerticalAxis.Left : this.list[2].VertAxis; } set { if (this.list[2] != null) { this.list[2].VertAxis = value; } } } [Category("Data"), Description("垂直坐标1,可修改.")] public VerticalAxis VertAxis4 { get { return this.list[3] == null ? VerticalAxis.Left : this.list[3].VertAxis; } set { if (this.list[3] != null) { this.list[3].VertAxis = value; } } } [Category("Data"), Description("垂直坐标5,可修改.")] public VerticalAxis VertAxis5 { get { return this.list[4] == null ? VerticalAxis.Left : this.list[4].VertAxis; } set { if (this.list[4] != null) { this.list[4].VertAxis = value; } } } [Category("Data"), Description("垂直坐标6,可修改.")] public VerticalAxis VertAxis6 { get { return this.list[5] == null ? VerticalAxis.Left : this.list[5].VertAxis; } set { if (this.list[5] != null) { this.list[5].VertAxis = value; } } } [Category("Data"), Description("垂直坐标7,可修改.")] public VerticalAxis VertAxis7 { get { return this.list[6] == null ? VerticalAxis.Left : this.list[6].VertAxis; } set { if (this.list[6] != null) { this.list[6].VertAxis = value; } } } [Category("Data"), Description("垂直坐标8,可修改.")] public VerticalAxis VertAxis8 { get { return this.list[7] == null ? VerticalAxis.Left : this.list[7].VertAxis; } set { if (this.list[7] != null) { this.list[7].VertAxis = value; } } } [Category("Data"), Description("垂直坐标9,可修改.")] public VerticalAxis VertAxis9 { get { return this.list[8] == null ? VerticalAxis.Left : this.list[8].VertAxis; } set { if (this.list[8] != null) { this.list[8].VertAxis = value; } } } [Category("Data"), Description("垂直坐标10,可修改.")] public VerticalAxis VertAxis10 { get { return this.list[9] == null ? VerticalAxis.Left : this.list[9].VertAxis; } set { if (this.list[9] != null) { this.list[9].VertAxis = value; } } } [Category("Data"), Description("垂直坐标11,可修改.")] public VerticalAxis VertAxis11 { get { return this.list[10] == null ? VerticalAxis.Left : this.list[10].VertAxis; } set { if (this.list[10] != null) { this.list[10].VertAxis = value; } } } [Category("Data"), Description("垂直坐标12,可修改.")] public VerticalAxis VertAxis12 { get { return this.list[11] == null ? VerticalAxis.Left : this.list[11].VertAxis; } set { if (this.list[11] != null) { this.list[11].VertAxis = value; } } } #endregion #region 动画属性 /// /// 密炼时间动画属性 /// public string MixTimeName { get { return _mixTimeName; } set { _mixTimeName = value; } } private string[] _pointName = new string[LINENUM]; 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; } } public string PointName9 { get { return this._pointName[8]; } set { this._pointName[8] = value; } } public string PointName10 { get { return this._pointName[9]; } set { this._pointName[9] = value; } } public string PointName11 { get { return this._pointName[10]; } set { this._pointName[10] = value; } } public string PointName12 { get { return this._pointName[11]; } set { this._pointName[11] = value; } } private void SetPointValue(double value, int i) { if (this._isUseMixTime && this._mixTime == 0) { this.Clear(); } else { if (this.list[i] == null) { list[i] = new FastLine(); list[i].ShowInLegend = this._isShowLegend; //是否显示图例 list[i].Color = this.GetDefaultColor(i); //获取默认颜色 this.tChart1.Series.Add(list[i]); } if (this._curveType == CurveTypes.Pan) { if (this.list[i].Count >= this._num) { this.list[i].Delete(0, 1, true); } } else { if (this.list[i].Count >= this._num) { this.Num += 10; } } if (this._isShowTime) { this.list[i].Add(value, String.Format(this._timeformat, DateTime.Now)); } else if (this._isUseMixTime) { this.list[i].Add(this._mixTime, value); } else { this.list[i].Add(value); } } } /// /// 获取默认颜色 /// /// 曲线索引 /// 返回默认颜色 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]; } public void Clear() { for (int i = 0; i < list.Length; i++) { //this.list[i].Delete(0, this.list[i].Count, true); if (this.list[i] != null) this.list[i].Clear(); } this.tChart1.Axes.Bottom.Maximum = this._defaultNum; //重置横坐标 } public double PointValue1 { set { SetPointValue(value, 0); } } public double PointValue2 { set { SetPointValue(value, 1); } } public double PointValue3 { set { SetPointValue(value, 2); } } public double PointValue4 { set { SetPointValue(value, 3); } } public double PointValue5 { set { SetPointValue(value, 4); } } public double PointValue6 { set { SetPointValue(value, 5); } } public double PointValue7 { set { SetPointValue(value, 6); } } public double PointValue8 { set { SetPointValue(value, 7); } } public double PointValue9 { set { SetPointValue(value, 8); } } public double PointValue10 { set { SetPointValue(value, 9); } } public double PointValue11 { set { SetPointValue(value, 10); } } public double PointValue12 { set { SetPointValue(value, 11); } } #endregion #region 设备变量替换属性 public string ReplaceStr1 { get { return _replaceStr1; } set { _replaceStr1 = value; } } public string ReplaceStr2 { get { return _replaceStr2; } set { _replaceStr2 = value; } } public string ReplaceStr3 { get { return _replaceStr3; } set { _replaceStr3 = value; } } public string ReplaceStr4 { get { return _replaceStr4; } set { _replaceStr4 = value; } } public string ReplaceStr5 { get { return _replaceStr5; } set { _replaceStr5 = value; } } public string ReplaceStr6 { get { return _replaceStr6; } set { _replaceStr6 = value; } } public string ReplaceStr7 { get { return _replaceStr7; } set { _replaceStr7 = value; } } public string ReplaceStr8 { get { return _replaceStr8; } set { _replaceStr8 = value; } } public string ReplaceStr9 { get { return _replaceStr9; } set { _replaceStr9 = value; } } public string ReplaceStr10 { get { return _replaceStr10; } set { _replaceStr10 = value; } } public string ReplaceStr11 { get { return _replaceStr11; } set { _replaceStr11 = value; } } public string ReplaceStr12 { get { return _replaceStr12; } set { _replaceStr12 = value; } } #endregion #region 颜色设置 [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue1 { get { if (this.list[0] != null) return this.list[0].LinePen.Color; else return this.GetDefaultColor(0); //默认红色 } set { if (this.list[0] != null) { this.list[0].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue2 { get { if (this.list[1] != null) return this.list[1].LinePen.Color; else return this.GetDefaultColor(1); //默认绿色 } set { if (this.list[1] != null) { this.list[1].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue3 { get { if (this.list[2] != null) return this.list[2].LinePen.Color; else return this.GetDefaultColor(2); //默认紫色 } set { if (this.list[2] != null) { this.list[2].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue4 { get { if (this.list[3] != null) return this.list[3].LinePen.Color; else return this.GetDefaultColor(3); //默认蓝色 } set { if (this.list[3] != null) { this.list[3].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue5 { get { if (this.list[4] != null) return this.list[4].LinePen.Color; else return this.GetDefaultColor(4); //默认黑色 } set { if (this.list[4] != null) { this.list[4].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue6 { get { if (this.list[5] != null) return this.list[5].LinePen.Color; else return this.GetDefaultColor(5); } set { if (this.list[5] != null) { this.list[5].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue7 { get { if (this.list[6] != null) return this.list[6].LinePen.Color; else return this.GetDefaultColor(6); } set { if (this.list[6] != null) { this.list[6].LinePen.Color = value; } } } [Category("Data"), Description("曲线颜色,可修改.")] public Color ColorValue8 { get { if (this.list[7] != null) return this.list[7].LinePen.Color; else return this.GetDefaultColor(7); } set { if (this.list[7] != null) { this.list[7].LinePen.Color = value; } } } [Category("Data"), 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("Data"), 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("Data"), 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("Data"), 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 #region 右键菜单 private void tChart1_MouseClick(object sender, MouseEventArgs e) { //if (e.Button == System.Windows.Forms.MouseButtons.Right) //{ // this.cmsTeeChart.Show(this.tChart1, new Point(e.X, e.Y)); //} } private void cmsTeeChart_VisibleChanged(object sender, EventArgs e) { this.mnuMove.Enabled = !this._isMove; this.mnuUnMove.Enabled = this._isMove; this.mnuHideLegend.Enabled = this._isShowLegend; this.mnuShowLegend.Enabled = !this._isShowLegend; this.mnuHideSerials.Enabled = this.chartListBox1.Visible; this.mnuShowSerials.Enabled = !this.chartListBox1.Visible; //this.mnuHideTools.Enabled = this.commander1.Visible; //this.mnuShowTools.Enabled = !this.commander1.Visible; } private void mnuResetAxes_Click(object sender, EventArgs e) { this.Reset(); } private void mnuShowLegend_Click(object sender, EventArgs e) { this.IsShowLegend = true; } private void mnuHideLegend_Click(object sender, EventArgs e) { this.IsShowLegend = false; } private void mnuShowTools_Click(object sender, EventArgs e) { this.commander1.Visible = true; } private void mnuHideTools_Click(object sender, EventArgs e) { this.commander1.Visible = false; } private void mnuShowSerials_Click(object sender, EventArgs e) { this.chartListBox1.Visible = true; } private void mnuHideSerials_Click(object sender, EventArgs e) { this.chartListBox1.Visible = false; } private void mnuMove_Click(object sender, EventArgs e) { this.IsMove = true; } private void mnuUnMove_Click(object sender, EventArgs e) { this.IsMove = false; } private void mnuPropertySetting_Click(object sender, EventArgs e) { if (this.PropertySet != null) { this.PropertySet(this, e); } } #endregion #region 坐标系属性 private string _buttomAxes = string.Empty; private string _leftAxes = string.Empty; private string _rightAxes = string.Empty; public bool AxesAuto { get; set; } /// /// 底部坐标系 /// public string ButtomAxes { get { return _buttomAxes; } set { if (!String.IsNullOrEmpty(value)) { _buttomAxes = value; if (_buttomAxes.Split(',').Length == 2) this.tChart1.Axes.Bottom.SetMinMax(Convert.ToDouble(_buttomAxes.Split(',')[0]), Convert.ToDouble(_buttomAxes.Split(',')[1])); } } } /// /// 左部坐标系 /// public string LeftAxes { get { return _leftAxes; } set { if (!String.IsNullOrEmpty(value)) { _leftAxes = value; if (_leftAxes.Split(',').Length == 2) this.tChart1.Axes.Left.SetMinMax(Convert.ToDouble(_leftAxes.Split(',')[0]), Convert.ToDouble(_leftAxes.Split(',')[1])); } } } /// /// 右部坐标系 /// public string RightAxes { get { return _rightAxes; } set { if (!String.IsNullOrEmpty(value)) { _rightAxes = value; if (_rightAxes.Split(',').Length == 2) { this.tChart1.Axes.Right.SetMinMax(Convert.ToDouble(_rightAxes.Split(',')[0]), Convert.ToDouble(_rightAxes.Split(',')[1])); } } } } /// /// 曲线坐标复位 /// public void Reset() { this.tChart1.Zoom.Undo(); if (!String.IsNullOrEmpty(this._buttomAxes)) { if (_buttomAxes.Split(',').Length == 2) this.tChart1.Axes.Bottom.SetMinMax(Convert.ToDouble(_buttomAxes.Split(',')[0]), Convert.ToDouble(_buttomAxes.Split(',')[1])); } if (!String.IsNullOrEmpty(this._leftAxes)) { if (_leftAxes.Split(',').Length == 2) this.tChart1.Axes.Left.SetMinMax(Convert.ToDouble(_leftAxes.Split(',')[0]), Convert.ToDouble(_leftAxes.Split(',')[1])); } if (!String.IsNullOrEmpty(_rightAxes)) { if (_rightAxes.Split(',').Length == 2) { this.tChart1.Axes.Right.SetMinMax(Convert.ToDouble(_rightAxes.Split(',')[0]), Convert.ToDouble(_rightAxes.Split(',')[1])); } } } /// /// 放大缩小 /// /// +放大 -缩小 public void Tzoom(string action) { if (action == "+") this.tChart1.Zoom.ZoomPercent(110); if (action == "-") this.tChart1.Zoom.ZoomPercent(90); } /// /// 坐标按指定方向变化 /// /// public void AxesScroll(string dircet) { switch (dircet) { case "Left": this.tChart1.Axes.Bottom.Scroll(-10, false); break; case "Right": this.tChart1.Axes.Bottom.Scroll(10, false); break; case "Top": this.tChart1.Axes.Left.Scroll(10, false); this.tChart1.Axes.Right.Scroll(10, false); break; case "Bottom": this.tChart1.Axes.Left.Scroll(-10, false); this.tChart1.Axes.Right.Scroll(-10, false); break; default: break; } } #endregion #region 事件定义 public event EventHandler PropertySet; #endregion private void toolStripMenuItem2_Click(object sender, EventArgs e) { this.chartListBox1.Visible = true; } private void toolStripMenuItem3_Click(object sender, EventArgs e) { this.chartListBox1.Visible = false; } } }