/// <summary> /// 处理图表点击事件,根据X值定位表格里的数据 /// </summary> /// <param name="sender"></param> /// <param name="x"></param> /// <param name="y"></param> void curve_CtrCurveClick(CtrCurve sender, double x, double y) { IParameter param = sender.Parameters[0]; int index = (int)x; if ((index > 0) && (index < this.mDataDT.Rows.Count - 1)) { ShowDataBySecond(index); } else ShowDataBySecond(0); }
/// <summary> /// 动态增加图表控件 /// </summary> /// <param name="parameter"></param> /// <param name="data"></param> private void AddCurve(FlyParameter parameter, List<float> data, List<int> happenTimes,int duration) { CtrCurve curve = new CtrCurve(); curve.GetParameterObject = this; curve.Height = 200; curve.Dock = DockStyle.Top; NPlot.LineList lineList = new NPlot.LineList(parameter, data); curve.SuspendLayout(); curve.InitCurve(); curve.DrawCurve(lineList, 0, lineList.EndNum); curve.Parameters.Add(parameter); //添加红线(故障的发生时间) List<VerticalLine> vlines = GetVerticalLines(happenTimes, duration); if (vlines != null) { curve.AddVerticalLines(vlines); } this.pnlContainer.Controls.Add(curve); curve.ResumeLayout(); curve.BringToFront(); curve.CtrCurveClick += new CtrCurveClickEvent(curve_CtrCurveClick); //curve.CurveInteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(curve_CurveInteractionOccured); curve.RestoreStatusClick += new EventHandler(curve_RestoreStatusClick); this.mCtrCurves.Add(curve); }