コード例 #1
0
 public LineGraph()
 {
     mGraphPane = new GraphPane();
     this.SetStyle(ControlStyles.DoubleBuffer, true);
     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     this.SetStyle(ControlStyles.UserPaint, true);
 }
コード例 #2
0
        public override void Draw(Graphics g, GraphPane pane)
        {
            SizeF size;
            PointF pos;
            float x, y1, y2, y3;
            string label;

            //Draw Axis Title
            if (mTitle.Visible) {
                using (Brush brush = new SolidBrush(mTitle.Color)) {
                    if (mTitle.Orientation == Orientation.Vertical) {
                        g.RotateTransform(-90);
                        g.TranslateTransform(-mPane.ClientRectangle.Height, 0);
                        size = g.MeasureString(mTitle.Text, mTitle.Font);
                        pos = new PointF(mTitle.Padding, mRect.Left + mRect.Width / 2 - size.Height / 2);
                        g.DrawString(mTitle.Text, mTitle.Font, brush, pos);
                        g.ResetTransform();
                    } else {
                        size = g.MeasureString(mTitle.Text, mTitle.Font);
                        pos = new PointF(mRect.Left + (mRect.Width / 2 - size.Width / 2), mRect.Top + mTitle.Padding);
                        if (mLabels.Visible) pos.Y += (mLabels.Font.Height + (mLabels.Padding * 2));
                        g.DrawString(mTitle.Text, mTitle.Font, brush, pos);

                    }
                }
            }

            //Draw Minor Gridlines and Marks
            y1 = mRect.Top - mMinorMark.Size;
            y2 = mRect.Top;
            for (double dx = Minimum; dx <= Maximum; dx += mMinorStep) {
                x = mRect.X + (float)((dx - mMinimum) * mScale);
                if (mMinorMark.Visible) g.DrawLine(mMinorMark.Pen, x, y1, x, y2);
            }

            //Draw Major Gridlines, Marks and Labels
            y1 = mRect.Top - mMajorMark.Size;
            y2 = mRect.Top;
            y3 = y2 + mLabels.Padding;
            using (Brush b = new SolidBrush(mLabels.Color)) {
                for (double dx = Minimum; dx <= Maximum; dx += mMajorStep) {
                    x = mRect.X + (float)((dx - mMinimum) * mScale);
                    if (mMajorMark.Visible) g.DrawLine(mMajorMark.Pen, x, y1, x, y2);
                    if (mLabels.Visible) {
                        label = FormatLabel(dx);
                        size = g.MeasureString(label, mLabels.Font);
                        x = x - size.Width / 2;
                        if (mPane.ClientRectangle.Contains(x, y3) && mPane.ClientRectangle.Contains(x + size.Width, y3 + size.Height))
                            g.DrawString(label, mLabels.Font, b, x, y3);
                    }
                }
            }

            //Draw The Axis
            g.DrawLine(mPen, mRect.Left, mRect.Top, mRect.Right, mRect.Top);
        }
コード例 #3
0
        public override void Draw(Graphics g, GraphPane pane)
        {
            SizeF size;
            PointF pos;
            float y, x1, x2, x3;
            string label;

            //Draw Axis Title
            if (mTitle.Visible) {
                using (Brush b = new SolidBrush(mTitle.Color)) {
                    if (mTitle.Orientation == Orientation.Vertical) {
                        g.RotateTransform(-90);
                        g.TranslateTransform(-mRect.Height, 0);
                        size = g.MeasureString(mTitle.Text, mTitle.Font);
                        pos = new PointF(mRect.Height / 2 - size.Width / 2, mRect.Left + mTitle.Padding);
                        g.DrawString(mTitle.Text, mTitle.Font, b, pos);
                        g.ResetTransform();
                    } else {
                        size = g.MeasureString(mTitle.Text, mTitle.Font);
                        pos = new PointF(mRect.Left + mTitle.Padding, mRect.Height / 2 - size.Width / 2);
                        g.DrawString(mTitle.Text, mTitle.Font, b, pos);
                    }
                }
            }

            //Draw Minor Grid and Mark
            x1 = mRect.Right + mMinorMark.Size;
            x2 = x1 - mMinorMark.Size;
            for (double dy = Minimum; dy < Maximum; dy += mMinorStep) {
                y = mRect.Bottom - (float)((dy - mMinimum) * mScale);
                if (mMinorMark.Visible) g.DrawLine(mMinorMark.Pen, x1, y, x2, y);
            }

            //Draw Major Gridlines, Marks and Labels
            x1 = mRect.Right + mMajorMark.Size;
            x2 = x1 - mMajorMark.Size;

            using (Brush b = new SolidBrush(mLabels.Color)) {
                for (double dy = Minimum; dy <= Maximum; dy += mMajorStep) {
                    y = mRect.Bottom - (float)((dy - mMinimum) * mScale);
                    if (mMajorMark.Visible) g.DrawLine(mMajorMark.Pen, x1, y, x2, y);
                    if (mLabels.Visible) {
                        label = dy.ToString(mLabels.Format);
                        size = g.MeasureString(label, mLabels.Font);
                        y = y - size.Height / 2;
                        x3 = x2 - (size.Width + mLabels.Padding);
                        if (mPane.ClientRectangle.Contains(x3, y) && mPane.ClientRectangle.Contains(x3, y + size.Height))
                            g.DrawString(label, mLabels.Font, b, x3, y);
                    }
                }
            }

            //Draw The Axis
            g.DrawLine(mPen, mRect.Right, mRect.Top, mRect.Right, mRect.Bottom);
        }
コード例 #4
0
ファイル: Axis.cs プロジェクト: eprimo/Linc-Reporting-Service
 public Axis(GraphPane pane)
 {
     mPane = pane;
     mMaximum = 0;
     mMinimum = 0;
     mScale = 1.0f;
     mTitle = new AxisTitle();
     mLabels = new AxisLabels();
     mMajorMark = new AxisMark(15.0f);
     mMinorMark = new AxisMark(6.0f);
     mAxisType = AxisType.Linear;
     mPen = SystemPens.ControlText;
 }
コード例 #5
0
ファイル: Line.cs プロジェクト: eprimo/Linc-Reporting-Service
        public void Draw(Graphics g, GraphPane pane)
        {
            if (!mVisible) return;

            double scaleX = pane.XAxis.Scale;
            double scaleY = pane.YAxis.Scale;

            PointF p1 = new PointF();
            PointF p2 = new PointF();

            DataPoint prev = null;

            using (Pen pen = new Pen(mColor, mWidth)) {
                using (Brush brush = new SolidBrush(mColor)) {
                    pen.DashStyle = this.Style;

                    foreach (DataPoint p in mPoints) {
                        if (prev != null) {
                            p1.X = (float)((prev.X - pane.XAxis.Minimum) * scaleX);
                            p1.Y = (float)((prev.Y - pane.YAxis.Minimum) * scaleY);
                            p2.X = (float)((p.X - pane.XAxis.Minimum) * scaleX);
                            p2.Y = (float)((p.Y - pane.YAxis.Minimum) * scaleY);
                            if (p1.X > 5000) p1.X = 5000;
                            if (p1.Y > 5000) p1.Y = 5000;
                            if (p2.X > 5000) p2.X = 5000;
                            if (p2.Y > 5000) p2.Y = 5000;
                            g.DrawLine(pen, p1, p2);
                        }
                        switch (mSymbolType) {
                            case SymbolType.Circle:
                                p1.X = (float)((p.X - pane.XAxis.Minimum) * scaleX);
                                p1.Y = (float)((p.Y - pane.YAxis.Minimum) * scaleY);
                                if (p1.X > 5000) p1.X = 5000;
                                if (p1.Y > 5000) p1.Y = 5000;

                                g.FillEllipse(brush, p1.X - 3, p1.Y - 3, 6, 6);
                                break;
                        }
                        prev = p;
                    }
                }
            }
        }
コード例 #6
0
 public XAxis(GraphPane pane)
     : base(pane)
 {
     mTitle.Text = "X Axis";
     mLabels.Spacing = 30;
 }
コード例 #7
0
ファイル: Axis.cs プロジェクト: eprimo/Linc-Reporting-Service
 public abstract void Draw(Graphics g, GraphPane pane);
コード例 #8
0
 public YAxis(GraphPane pane)
     : base(pane)
 {
     mTitle.Text = "Y Axis";
     mLabels.Spacing = 10;
 }