public void SetGageVisible(GageTpye gageTpye, bool isVisible) { foreach (Gage item in allGage) { if (item.gageTpye == gageTpye) { item.visiable = isVisible; } DrawGate(item); } }
/// <summary> /// 绘制闸门位置 /// </summary> /// <param name="gageTpye">闸门类型</param> /// <param name="centerPoint">闸门中心点</param> /// <param name="gageLength">闸门长度</param> public void SetGage(GageTpye gageTpye, Point initPos, int gageLength) { foreach (Gage item in allGage) { if (item.gageTpye == gageTpye) { item.initPositionX = initPos.X; item.initPositionY = initPos.Y; item.Gagelength = gageLength; } DrawGate(item); } }
/// <summary> /// 返回闸门范围内的数据 /// </summary> /// <param name="gageTpye"></param> /// <param name="sourceArray"></param> /// <returns></returns> public double [] GetGageData(GageTpye gageTpye, double [] sourceArray) { Gage gage = new Gage(); foreach (Gage item in allGage) { if (item.gageTpye == gageTpye) { gage = item; break; } } int startIndex = Convert.ToInt32((gage.initPositionX) * chartView.axisXScale / 100); if (startIndex > sourceArray.Length) { return(null); } int stopIndex = Convert.ToInt32((gage.initPositionX + gage.Gagelength) * chartView.axisXScale / 100); if (stopIndex > chartView.axisXScale || stopIndex > sourceArray.Length) { if (chartView.axisXScale >= sourceArray.Length) { stopIndex = sourceArray.Length; } else { stopIndex = chartView.axisXScale; } } int indexLength = stopIndex - startIndex; double[] data = new double[indexLength]; Array.Copy(sourceArray, startIndex, data, 0, indexLength); return(data); }