Esempio n. 1
0
        /*private void DrawBackVLine(PaintEventArgs e, string tag)
         * {
         *  if (dataList.Count < 2)
         *  {
         *      return;
         *  }
         *  Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.
         *  Pen p1 = new Pen(Color.FromArgb(169, 169, 169), 2);
         *  Pen p2 = new Pen(Color.FromArgb(211, 211, 211), 1);
         *
         *  Rectangle rect;
         *  int[] value;
         *  int hig = ctrlProperty.topRect.Height / 15;
         *  if (tag == "top")
         *  {
         *      rect = ctrlProperty.topRect;
         *      value = ControlDataEntity.tValue;
         *      hig *= 3;
         *  }
         *  else
         *  {
         *      rect = ctrlProperty.botRect;
         *      value = ControlDataEntity.bValue;
         *      hig *= 2;
         *  }
         *
         *
         *  // 刻度文字居中
         *  StringFormat stringFormat = new StringFormat();
         *  stringFormat.LineAlignment = StringAlignment.Center;
         *  stringFormat.Alignment = StringAlignment.Center;
         *  // 刻度文字
         *  Font font1 = new Font("Arial", 8, FontStyle.Bold);
         *
         *  // 时间文字
         *  Font font = new Font("Arial", 9);
         *
         *  //画竖线
         *  for (int i = 0; i < dataList.Count; i++)
         *  {
         *      if (dataList[i].isDrawVLine)
         *      {
         *          g.DrawLine(p2, new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Top), new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Bottom));
         *      }
         *
         *      if (dataList[i].isDrawTime)
         *      {
         *          g.DrawLine(p1, new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Top), new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Bottom));
         *
         *          if (tag == "bottom")
         *          {
         *              g.DrawString(dataList[i].sampleTime, font, Brushes.Gray, dataPointChildHeart1[i].X + paddingLeft, rect.Bottom + 10);
         *          }
         *
         *      }
         *
         *      if (dataList[i].isDrawNum)
         *      {
         *          for (int j = 0; j < ControlDataEntity.tValue.Length; j++)
         *          {
         *              //g.FillRectangle(Brushes.White, dataPointChildHeart1[i].X, rect.Top + hig * j - paddingLeft/2, 20, 10);
         *              g.DrawString(value[j].ToString(), font1, Brushes.Gray, dataPointChildHeart1[i].X + paddingLeft, rect.Top + hig * j, stringFormat);
         *          }
         *      }
         *  }
         * }*/
        /// <summary>
        /// 画竖线
        /// </summary>
        /// <param name="e"></param>
        /// <param name="tag"></param>
        private void DrawBackVLine(PaintEventArgs e, string tag)
        {
            List <ControlDataEntity> dataTemp = new List <ControlDataEntity>();

            if (dataList.Count >= 0 && dataList.Count < ctrlProperty.topRect.Width / pix)
            {
                ControlDataEntity[] dataArray = new ControlDataEntity[dataList.Count];
                dataList.CopyTo(dataArray, 0);
                dataTemp = dataArray.ToList <ControlDataEntity>();
                //dataList.CopyTo(dataTemp.ToArray(), 0);
                DateTime timei = DateTime.Now;
                if (dataList.Count > 0)
                {
                    timei = Convert.ToDateTime(dataList[dataList.Count - 1].entity.SampleTime);
                }

                for (int i = dataList.Count; i < ctrlProperty.topRect.Width / pix; i++)
                {
                    ControlDataEntity entity = new ControlDataEntity();
                    if (i != 0)
                    {
                        timei = timei.AddSeconds(1);
                    }

                    entity.entity.SampleTime = timei.ToString();

                    DateTime time0 = DateTime.Now;
                    if (ctrlData.datalist.Count > 0)
                    {
                        time0 = Convert.ToDateTime(ctrlData.datalist[0].entity.SampleTime);
                    }

                    Int64 seci = timei.Ticks;
                    Int64 sec0 = time0.Ticks;

                    TimeSpan ts1 = new TimeSpan(seci); //获取当前时间的刻度数
                                                       //执行某操作
                    TimeSpan ts2 = new TimeSpan(sec0);

                    TimeSpan ts  = ts2.Subtract(ts1).Duration();     //时间差的绝对值
                    int      sec = Convert.ToInt32(ts.TotalSeconds); //执行时间的总秒数
                    if (sec % 60 == 0)
                    {
                        entity.isDrawTime = true;
                        // 四分钟显示刻度
                        if (sec % 240 == 0)
                        {
                            entity.isDrawNum = true;
                        }
                        entity.isDrawVLine = false;
                    }
                    else if (sec % 15 == 0)
                    {
                        entity.isDrawTime  = false;
                        entity.isDrawVLine = true;
                    }
                    dataTemp.Add(entity);
                }
            }
            else
            {
                dataTemp = dataList;
            }

            /*if(dataList.Count<2)
             * {
             *  return;
             * }*/
            //如果采集点未满一屏幕,那么给datalist 充满值
            Graphics g  = e.Graphics; //创建画板,这里的画板是由Form提供的.
            Pen      p1 = new Pen(Color.FromArgb(169, 169, 169), 2);
            Pen      p2 = new Pen(Color.FromArgb(211, 211, 211), 1);

            Rectangle rect;

            int[] value;
            int   hig = ctrlProperty.topRect.Height / 15;

            if (tag == "top")
            {
                rect  = ctrlProperty.topRect;
                value = ControlDataEntity.tValue;
                hig  *= 3;
            }
            else
            {
                rect  = ctrlProperty.botRect;
                value = ControlDataEntity.bValue;
                hig  *= 2;
            }


            // 刻度文字居中
            StringFormat stringFormat = new StringFormat();

            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.Alignment     = StringAlignment.Center;
            StringFormat stringFormat1 = new StringFormat();

            stringFormat1.LineAlignment = StringAlignment.Near;
            stringFormat1.Alignment     = StringAlignment.Near;
            // 刻度文字
            Font font1 = new Font("Arial", textSize, FontStyle.Bold);

            // 时间文字
            Font font = new Font("Arial", textSize, FontStyle.Bold);

            //画竖线
            int mark = 0;

            for (int i = 0; i < dataTemp.Count; i++)
            {
                int hig1   = ctrlProperty.topRect.Height / 15;
                int top    = 0;
                int bottom = 0;
                if (tag == "top")
                {
                    top    = rect.Top;
                    bottom = top + 15 * hig1;
                }
                else
                {
                    top    = rect.Top;
                    bottom = top + 10 * hig1;
                }
                if (dataTemp[i].isDrawVLine)
                {
                    g.DrawLine(p2, new Point(i * pix + paddingLeft, top), new Point(i * pix + paddingLeft, bottom));
                }

                if (dataTemp[i].isDrawTime)
                {
                    g.DrawLine(p1, new Point(i * pix + paddingLeft, top), new Point(i * pix + paddingLeft, bottom));

                    if (tag == "bottom")
                    {
                        string strTime = dataTemp[i].entity.SampleTime;
                        if (mark != 0)
                        {
                            string[] time = dataTemp[i].entity.SampleTime.Split(' ');
                            strTime = time[1];
                        }
                        mark++;
                        //string time = dataList[i].sampleTime.Substring(,)
                        g.DrawString(strTime, font, Brushes.Gray, new RectangleF {
                            X = i * pix + paddingLeft, Y = ctrlProperty.timeRect.Top, Width = 200, Height = ctrlProperty.timeRect.Height
                        }, stringFormat1);
                    }
                }
                if (dataTemp[i].isDrawNum)
                {
                    for (int j = 0; j < ControlDataEntity.tValue.Length; j++)
                    {
                        //g.FillRectangle(Brushes.White, dataPointChildHeart1[i].X, rect.Top + hig * j - paddingLeft/2, 20, 10);
                        g.DrawString(value[j].ToString(), font1, Brushes.Gray, i * pix + paddingLeft, rect.Top + hig * j, stringFormat);
                    }
                }
                if (tag == "top")
                {
                    if (isShowFetal1)
                    {
                        if (dataTemp[i].entity.bFetal1Alert)
                        {
                            if (i > 0)
                            {
                                if (!dataTemp[i - 1].entity.bFetal1Alert)
                                {
                                    DrawFetalAlert(e, new PointF()
                                    {
                                        X = i * pix + paddingLeft, Y = top
                                    });
                                    fetalAlertList.Add(new FetalAlertStruct()
                                    {
                                        x = i * pix + paddingLeft, y = top, width = 20, heigth = 20, content = dataTemp[i].entity.strFetal1AlertContent
                                    });
                                }
                            }
                        }
                    }
                    if (isShowFetal2)
                    {
                        if (dataTemp[i].entity.bFetal2Alert)
                        {
                            if (i > 0)
                            {
                                if (!dataTemp[i - 1].entity.bFetal2Alert)
                                {
                                    DrawFetalAlert(e, new PointF()
                                    {
                                        X = i * pix + paddingLeft, Y = top
                                    });
                                    fetalAlertList.Add(new FetalAlertStruct()
                                    {
                                        x = i * pix + paddingLeft, y = top, width = 20, heigth = 20, content = dataTemp[i].entity.strFetal2AlertContent
                                    });
                                }
                            }
                        }
                    }
                    //画手动胎动
                    if (dataTemp[i].entity.ManualFetalMove == 1)
                    {
                        int h = ctrlProperty.topRect.Top + (210 - normalFetalLow) * (hig * 15) / (210 - 60);
                        DrawManualFetalMove(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = h
                        });
                    }
                    if (dataTemp[i].entity.FHRSame == 1)
                    {
                        DrawFetalCoincide(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = top + 20
                        });
                    }
                }
                if (tag == "bottom")
                {
                    if (dataTemp[i].entity.Mark == 1)
                    {
                        DrawMark(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = top
                        });
                    }
                }
                if (dataTemp[i].entity.bPcMark)
                {
                    DrawPcMark(e, new PointF()
                    {
                        X = i * pix + paddingLeft, Y = (float)(Height * dataTemp[i].entity.yPcMark)
                    }, dataTemp[i].entity.PcMark);
                }
            }
            return;
        }