Example #1
0
 private void DrawGate(Gage gageInfo)
 {
     this.chart1.Series[gageInfo.gageName].Points.Clear();
     if (!gageInfo.visiable)
     {
         return;
     }
     for (int i = 0; i < 5; i++)
     {
         chart1.Series[gageInfo.gageName].Points.AddXY(gageInfo.initPositionX, gageInfo.initPositionY - 5 / 2 + i);
     }
     for (int i = 0; i < gageInfo.Gagelength + 1; i++)
     {
         chart1.Series[gageInfo.gageName].Points.AddXY(gageInfo.initPositionX + i, gageInfo.initPositionY);
     }
     for (int i = 0; i < 5; i++)
     {
         chart1.Series[gageInfo.gageName].Points.AddXY(gageInfo.initPositionX + gageInfo.Gagelength, gageInfo.initPositionY - 5 / 2 + i);
     }
 }
Example #2
0
        /// <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);
        }
Example #3
0
 private void InitGage()
 {
     gageA = new Gage
     {
         gageTpye      = GageTpye.GageA,
         Gagelength    = 10,
         initPositionX = 70,
         initPositionY = 70,
         gageName      = "Series2",
         visiable      = true
     };
     gageB = new Gage
     {
         gageTpye      = GageTpye.GageB,
         Gagelength    = 10,
         initPositionX = 20,
         initPositionY = 20,
         gageName      = "Series3",
         visiable      = true
     };
     allGage    = new Gage[2];
     allGage[0] = gageA;
     allGage[1] = gageB;
 }