Esempio n. 1
0
        /// <summary>
        /// Paints the control.
        /// </summary>
        /// <param name="g">The Graphics object to paint to.</param>
        /// <param name="bounds">The bounds of the plotting area.</param>
        public override void Draw(Graphics g, Rectangle bounds)
        {
            PointF[] v     = new PointF[3];
            Norms    norms = new Norms();
            Pen      Pen   = new Pen(new SolidBrush(Color.White));

            g.Clear(Model.BackgroundColor);

            Measure(g, bounds);

            if (Bounds.Width >= 1 && Bounds.Height >= 1)
            {
                //calculate functions
                PaintThread.DrawStart(this);

                //draw items
                PaintThread.DrawItems(g);

                // draw selection
                if (sw != 0 && sh != 0)
                {
                    Pen.Color = Color.White;
                    g.DrawRectangle(Pen, Math.Min(sx, sx + sw), Math.Min(sy, sy + sh),
                                    Math.Abs(sw), Math.Abs(sh));
                    Pen.DashPattern = new float[2] {
                        3, 3
                    };
                    Pen.DashStyle = DashStyle.Custom;
                    Pen.Color     = Color.Black;
                    g.DrawRectangle(Pen, Math.Min(sx, sx + sw), Math.Min(sy, sy + sh),
                                    Math.Abs(sw), Math.Abs(sh));
                    Pen.DashStyle = DashStyle.Solid;
                }

                Pen.Color = Model.ScaleColor;
                Pen.Width = Model.ScaleLineWidth;

                GraphicsBase.Point[] p  = Model.View.BoundsCube();
                PointF[]             dp = new PointF[p.Length];
                Model.View.DeviceCoordinates(p, dp);
                g.DrawLines(Pen, dp);

                //draw legend
                GraphicsBase.DrawLegend(g, this);

                //draw status message
                if (!PaintThread.DrawDone)
                {
                    if (Parent != null)
                    {
                        Parent.Cursor = Cursors.WaitCursor;
                    }
                }
                else
                {
                    if (Parent != null)
                    {
                        Parent.Cursor = Cursors.Cross;
                    }
                    if (ProgressBar != null)
                    {
                        lock (ProgressBar) {
                            ProgressBar.Value   = 0;
                            ProgressBar.Visible = false;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Paints the control.
        /// </summary>
        /// <param name="g">The Graphics object to paint to.</param>
        /// <param name="bounds">The bounds of the plotting area.</param>
        public override void Draw(Graphics g, Rectangle bounds)
        {
            PointF[] v     = new PointF[3];
            Norms    norms = new Norms();

            g.Clear(Model.BackgroundColor);
            SmoothingMode smoothingMode = g.SmoothingMode;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Measure(g, bounds);

            if (Bounds.Width >= 1 && Bounds.Height >= 1)
            {
                //calculate functions
                PaintThread.DrawStart(this);

                //draw items
                PaintThread.DrawItems(g);

                // draw selection
                if (sw != 0 && sh != 0)
                {
                    Pen Pen = new Pen(new SolidBrush(Color.White));
                    Pen.Color = Color.White;
                    g.DrawRectangle(Pen, Math.Min(sx, sx + sw), Math.Min(sy, sy + sh),
                                    Math.Abs(sw), Math.Abs(sh));
                    Pen.DashPattern = new float[2] {
                        3, 3
                    };
                    Pen.DashStyle = DashStyle.Custom;
                    Pen.Color     = Color.Black;
                    g.DrawRectangle(Pen, Math.Min(sx, sx + sw), Math.Min(sy, sy + sh),
                                    Math.Abs(sw), Math.Abs(sh));
                    Pen.DashStyle = DashStyle.Solid;
                }

                // draw x-scale
                v[0] = new PointF(Bounds.X, Bounds.Y + Bounds.Height);
                v[1] = new PointF(Bounds.X + Bounds.Width, Bounds.Y + Bounds.Height);
                v[2] = new PointF(Bounds.X, Bounds.Y);
                Model.x.Draw(g, v, true, ref norms);

                // draw y-scale
                v[0] = new PointF(Bounds.X, Bounds.Y);
                v[1] = new PointF(Bounds.X, Bounds.Y + Bounds.Height);
                v[2] = new PointF(Bounds.X + Bounds.Width, Bounds.Y);
                Model.y.Draw(g, v, true, ref norms);

                //draw z-scale
                Graphics2D.DrawZScale(g, Model, ref v, true, new Rectangle(Bounds.X + Bounds.Width + fd, Bounds.Y, fd, Bounds.Height), ref norms);

                //draw legend
                GraphicsBase.DrawLegend(g, this);

                //draw status message
                if (!PaintThread.DrawDone)
                {
                    if (Parent != null)
                    {
                        Parent.Cursor = Cursors.WaitCursor;
                    }
                }
                else
                {
                    if (Parent != null)
                    {
                        Parent.Cursor = Cursors.Cross;
                    }
                    if (ProgressBar != null)
                    {
                        lock (ProgressBar) {
                            ProgressBar.Value   = 0;
                            ProgressBar.Visible = false;
                        }
                    }
                }

                g.SmoothingMode = smoothingMode;
            }
        }