Beispiel #1
0
        public MedCurve addCurve(string title, MedPointList points, Color color)
        {
            MedCurve curve = new MedCurve(points, color);

            curve.Title = title;
            _curveList.Add(curve);
            return(curve);
        }
Beispiel #2
0
        public MedCurve addCurve(string title, MedPointList points, Image image)
        {
            MedCurve curve = new MedCurve(points, image);

            curve.Title = title;
            _curveList.Add(curve);
            return(curve);
        }
Beispiel #3
0
        public MedCurve addCurve(string title, MedPointList points, Image image, Color color, int xaxisindex, int yaxisindex)
        {
            MedCurve curve = new MedCurve(points, xaxisindex, yaxisindex, new MedSymbol(image), new Pen(color));

            curve.Title = title;
            _curveList.Add(curve);
            return(curve);
        }
Beispiel #4
0
        public MedCurve addCurve(string title, MedPointList points, MedSymbol symbol, Pen pen, int xaxisindex, int yaxisindex)
        {
            MedCurve curve = new MedCurve(points, xaxisindex, yaxisindex, symbol, pen);

            curve.Title = title;
            _curveList.Add(curve);
            return(curve);
        }
Beispiel #5
0
        /// <summary>
        /// 画图
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.DesignMode)
            {
                ///Y坐标轴
                _mainPanel.YAxisList.Clear();
                _mainPanel.YAxisList.Add(new MedAxis(this.Font, Brushes.Black, 100, 0, 20));
                _mainPanel.YAxisList.MinSetp   = 1;
                _mainPanel.YAxisList.Pen.Color = Color.Black;

                ///X坐标轴
                _mainPanel.XAxisList.Clear();
                MedAxis axis = new MedAxis(this.Font, Brushes.Black, 10, 1, 1f);
                _mainPanel.XAxisList.Add(axis);
                _mainPanel.XAxisList.MinSetp   = 1;
                _mainPanel.XAxisList.Pen.Color = Color.Black;

                ///其他属性
                _mainPanel.LeftMargin      = 10;
                _mainPanel.BottomMargin    = 20;
                _mainPanel.RectBorderPen   = Pens.Gray;
                _mainPanel.HasAxisGridLine = false;
                _mainPanel.XAxisTitleAtTop = false;

                _mainPanel.CurveList.Clear();
                MedPointList points = new MedPointList();
                points.Add(1, 10);
                points.Add(2, 40);
                points.Add(3, 20);
                points.Add(4, 80);
                points.Add(5, 50);
                points.Add(6, 70);
                points.Add(7, 60);
                points.Add(8, 100);
                points.Add(9, 90);
                points.Add(10, 0);
                MedCurve curve = new MedCurve(points);
                _mainPanel.CurveList.Add(curve);
            }

            ///隐藏滚动条

            ///如果没有坐标轴则不作图
            if ((_mainPanel.XAxisList.Count == 0) || (_mainPanel.YAxisList.Count == 0))
            {
                return;
            }

            _mainPanel.DrawGraph(e.Graphics);

            ///绘制光标位置
            if (_drawcursorpos)
            {
                DrawCursorPos(e.Graphics);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 绘制曲线
        /// </summary>
        /// <param name="g">作图对象</param>
        /// <param name="leftOffSet">横向位移</param>
        /// <param name="topOffSet">纵向位移</param>
        public void DrawCurves(Graphics g, int leftOffSet, int topOffSet)
        {
            float xx, yy, xx1 = 0, yy1 = 0, barCount = 0, barIndex = 0, barWidth = 0;

            for (int i = 0; i < _curveList.Count; i++)
            {
                if (((MedCurve)_curveList[i]).IsBar)
                {
                    barCount++;
                    if (barWidth <= 0)
                    {
                        barWidth = ((MedCurve)_curveList[i]).BarWidth;
                    }
                }
            }

            for (int i = 0; i < _curveList.Count; i++)
            {
                MedCurve     curve  = (MedCurve)_curveList[i];
                MedPointList points = curve.Points;

                ///画曲线的每个点
                for (int j = 0; j < points.Count; j++)
                {
                    xx = TranslateX(points[j].X, curve.XAxisIndex);
                    yy = TranslateY(points[j].Y, curve.YAxisIndex);

                    ///图柱状图
                    if (curve.IsBar)
                    {
                        g.DrawRectangle(curve.Pen, xx + leftOffSet - (barWidth * barCount / 2) + barIndex * barWidth, yy + topOffSet, barWidth, MainRect.Bottom - yy - topOffSet);
                        g.FillRectangle(new SolidBrush(curve.Pen.Color), xx + leftOffSet - (barWidth * barCount / 2) + barIndex * barWidth, yy + topOffSet, barWidth, MainRect.Bottom - yy - topOffSet);
                    }

                    ///画折线图
                    else
                    {
                        if (j > 0)
                        {
                            if (curve.hasLine)
                            {
                                ///绘制连线
                                g.DrawLine(curve.Pen, xx1 + leftOffSet, yy1 + topOffSet, xx + leftOffSet, yy + topOffSet);
                            }
                        }
                        if (points[j].Symbol != null)
                        {
                            ///绘制点标识
                            points[j].Symbol.Draw(g, xx + leftOffSet, yy + topOffSet);
                        }
                        else if (curve.Symbol.SymbolType != MedSymbolType.None)
                        {
                            ///绘制曲线点标识
                            curve.Symbol.Draw(g, xx + leftOffSet, yy + topOffSet);
                        }
                        xx1 = xx;
                        yy1 = yy;
                    }
                }///画曲线的每个点

                if (curve.IsBar)
                {
                    barIndex++;
                }
            }
        }
Beispiel #7
0
 public void Add(MedCurve curve)
 {
     List.Add(curve);
 }