Ejemplo n.º 1
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (m_Style == null)
     {
         return;
     }
     DrawInternalBackground(e, false);
     m_Style.SetParameterValue(m_ParameterValue, m_Parameter);
     m_Style.SetParameterValue(m_OtherCurrentValue, m_OtherParameter);
     if (m_Parameter == Parameters.ArrowheadEndSize || m_Parameter == Parameters.ArrowheadStartSize)
     {
         // if showing size difference, ensure we show something, even if current head is 'None'
         if (m_Style.Style == Lined.ArrowheadC.Styles.None)
         {
             m_Style.Style = Lined.ArrowheadC.Styles.SimpleSolid;
         }
     }
     m_Style.Size *= 2;             // we need multiply the value because the data and this GUI are using different scales
     // the number is not precise, but we probably cannot display it exactly to scale as the button will be big enough
     System.Drawing.Drawing2D.SmoothingMode old = e.Graphics.SmoothingMode;
     if (!Utilities.Low_Graphics_Safe())
     {
         e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     }
     m_Arrowhead.Draw(new NetCanvas(e.Graphics), 1, 1, null, StaticView.InvalidationBuffer.Base);
     e.Graphics.SmoothingMode = old;
     DrawHighlightAndKey(e);
 }
Ejemplo n.º 2
0
        private void Init()
        {
            drawables_      = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_     = new ArrayList();
            ordering_       = new SortedList();
            FontFamily fontFamily = new FontFamily("Arial");

            TitleFont                   = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            padding_                    = 10;
            title_                      = "";
            autoScaleTitle_             = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_                     = null;
            xAxis2_                     = null;
            yAxis1_                     = null;
            yAxis2_                     = null;
            pXAxis1Cache_               = null;
            pYAxis1Cache_               = null;
            pXAxis2Cache_               = null;
            pYAxis2Cache_               = null;
            titleBrush_                 = new SolidBrush(Color.Black);
            plotBackColor_              = Color.White;

            legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
        public static System.Drawing.Drawing2D.SmoothingMode AsDrawingSmoothingMode(this SmoothingMode smoothingMode)
        {
            System.Drawing.Drawing2D.SmoothingMode drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            switch (smoothingMode)
            {
            case SmoothingMode.AntiAlias:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                break;

            case SmoothingMode.Default:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
                break;

            case SmoothingMode.HighQuality:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                break;

            case SmoothingMode.HighSpeed:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                break;

            case SmoothingMode.Invalid:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Invalid;
                break;

            case SmoothingMode.None:
                drawingSmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                break;
            }
            return(drawingSmoothingMode);
        }
Ejemplo n.º 4
0
 public DrawingBuffer(Structs.Size canvasSize, System.Drawing.Drawing2D.SmoothingMode smoothingMode)
 {
     this.Bitmap   = new Bitmap(canvasSize.Width, canvasSize.Height);
     this.Graphics = Graphics.FromImage(this.Bitmap);
     this.Graphics.SmoothingMode = smoothingMode;
     this.CanvasSize             = canvasSize;
 }
Ejemplo n.º 5
0
        public void drawLines(short[] xy, int pointCnt)
        {
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            if (pointCnt > xy.Length / 2)
            {
                pointCnt = xy.Length / 2;
            }

            int i = 0;
            int x0, y0, x, y;

            //path.StartFigure();
            x0 = xy[0];
            y0 = xy[1];
            for (i = 1; i < pointCnt; i++)
            {
                x = xy[2 * i];
                y = xy[2 * i + 1];
                path.AddLine(x0, y0, x, y);
                x0 = x;
                y0 = y;
            }
            //path.CloseFigure();
            mGraphics.DrawPath(mPen, path);

            mGraphics.SmoothingMode = oldSmoothMode;
        }
Ejemplo n.º 6
0
        public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            System.Drawing.Drawing2D.GraphicsPath drawPath = CreateViewportPath(coordinateMapper);
            System.Drawing.Pen pen = CreateViewportPen(coordinateMapper);

            System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode;
            try
            {
                switch (base.DrawMode)
                {
                case VObjectDrawMode.Draft:
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
                    break;

                case VObjectDrawMode.Normal:
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    break;

                default:
                    throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode"));
                }

                if (_brush != null)
                {
                    AdaptBrushToViewport(coordinateMapper);
                    try
                    {
                        g.FillPath(_brush, drawPath);
                    }
                    finally
                    {
                        RestoreBrush();
                    }
                }
                if (pen != null)
                {
                    g.DrawPath(pen, drawPath);
                }
            }
            finally
            {
                if (pen != null)
                {
                    pen.Dispose();
                }
                drawPath.Dispose();
                g.SmoothingMode = oldSmoothingMode;
            }
        }
Ejemplo n.º 7
0
        public void drawLine(int x1, int y1, int x2, int y2)
        {
            if (y1 < -10000)
            {
                return;
            }
            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mGraphics.DrawLine(mPen, x1, y1, x2, y2);
            mGraphics.SmoothingMode = oldSmoothMode;
        }
Ejemplo n.º 8
0
        public frmMain()
        {
            InitializeComponent();

            savePointX = new float[sizeArray];
            savePointY = new float[sizeArray];

            System.Drawing.Drawing2D.QualityMode Quality = new System.Drawing.Drawing2D.QualityMode();
            System.Drawing.Drawing2D.SmoothingMode Smoothing = new System.Drawing.Drawing2D.SmoothingMode();
            Quality = System.Drawing.Drawing2D.QualityMode.High;
            Smoothing = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        }
Ejemplo n.º 9
0
        public void drawLine(int x1, int y1, int x2, int y2, float thickness)
        {
            float oldThick = mPen.Width;

            mPen.Width = thickness;

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mGraphics.DrawLine(mPen, x1, y1, x2, y2);

            mPen.Width = oldThick;
            mGraphics.SmoothingMode = oldSmoothMode;
        }
Ejemplo n.º 10
0
        public static SmoothingMode ToSmoothingMode(this System.Drawing.Drawing2D.SmoothingMode mode)
        {
            switch (mode)
            {
            case System.Drawing.Drawing2D.SmoothingMode.AntiAlias:
                return(SmoothingMode.AntiAlias);

            case System.Drawing.Drawing2D.SmoothingMode.None:
                return(SmoothingMode.None);

            default:
                return(SmoothingMode.Default);
            }
        }
 public static void FillRoundedRectangle(Graphics g, Rectangle r, int d, Brush b)
 {
     // anti alias distorts fill so remove it.
     System.Drawing.Drawing2D.SmoothingMode mode = g.SmoothingMode;
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
     g.FillPie(b, r.X, r.Y, d, d, 180, 90);
     g.FillPie(b, r.X + r.Width - d, r.Y, d, d, 270, 90);
     g.FillPie(b, r.X, r.Y + r.Height - d, d, d, 90, 90);
     g.FillPie(b, r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90);
     g.FillRectangle(b, r.X + d / 2, r.Y, r.Width - d, d / 2);
     g.FillRectangle(b, r.X, r.Y + d / 2, r.Width, r.Height - d);
     g.FillRectangle(b, r.X + d / 2, r.Y + r.Height - d / 2, r.Width - d, d / 2);
     g.SmoothingMode = mode;
 }
Ejemplo n.º 12
0
        public void drawLineDotHorizontal(int x1, int y1, int x2, int y2)
        {
            System.Drawing.Drawing2D.DashStyle old = mPen.DashStyle;
            mPen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dot;
            mPen.DashPattern = new float[] { 5, 5 };

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mGraphics.DrawLine(mPen, x1, y1, x2, y2);

            //  restore old state
            mPen.DashStyle          = old;
            mGraphics.SmoothingMode = oldSmoothMode;
        }
Ejemplo n.º 13
0
        private void drawCharacter(Graphics g)
        {
            System.Drawing.Drawing2D.SmoothingMode prev = g.SmoothingMode;
            g.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            RectangleF rect = coordToPixel(characterPosition);

            rect.X   += rect.Width / 2 - characterSize / 2;
            rect.Y   += rect.Height / 2 - characterSize / 2;
            rect.Size = new Size(characterSize, characterSize);

            g.FillEllipse(characterBrush, rect);

            g.SmoothingMode = prev;
        }
Ejemplo n.º 14
0
        protected virtual void DrawDescrizione(Graphics g)
        {
            Rectangle textRc = new Rectangle(10, TileRectangle.Height - 20, TileRectangle.Width - 20, 20);

            TextFormatFlags tff = TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine;

            if (Dimensione == MetroTileSize.Media)
            {
                tff |= TextFormatFlags.HorizontalCenter;
            }

            System.Drawing.Drawing2D.SmoothingMode oldMode = g.SmoothingMode;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            TextRenderer.DrawText(g, Descrizione, VisualManager.MetroTileTextFont, textRc, VisualManager.MetroTileTextColor, tff);
            g.SmoothingMode = oldMode;
        }
Ejemplo n.º 15
0
        //文字が読みずらいので、TextShadowぽいのを作る
        //see http://www.r-nakai.com/archives/280
        private void Button_Paint(object sender, PaintEventArgs e)
        {
            Button btn = (Button)sender;

            //アンチエリアス
            System.Drawing.Drawing2D.SmoothingMode initialMode
                = e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            //レンダリング品質
            System.Drawing.Drawing2D.CompositingQuality initialQuality
                = e.Graphics.CompositingQuality;
            e.Graphics.CompositingQuality
                = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

            string str = (String)btn.Tag;

            SizeF size = e.Graphics.MeasureString(str, btn.Font);
            int   x    = (int)((btn.Width / 2) - (size.Width / 1.5));
            int   y    = btn.Height - btn.Font.Height - 10;

            System.Drawing.Drawing2D.GraphicsPath gp =
                new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddString(str, btn.Font.FontFamily
                         , (int)FontStyle.Regular
                         , btn.Font.Size + 10
                         , new Point(x, y), StringFormat.GenericDefault);

            //パスの線分を描画
            Pen drawPen = new Pen(btn.BackColor, 3.0F);

            e.Graphics.DrawPath(drawPen, gp);

            //塗る
            Brush fillBrush = new SolidBrush(btn.ForeColor);

            e.Graphics.FillPath(fillBrush, gp);

            drawPen.Dispose();
            fillBrush.Dispose();

            //念のため元に戻しておきます
            e.Graphics.SmoothingMode      = initialMode;
            e.Graphics.CompositingQuality = initialQuality;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// </summary>
        /// <param name="chartControl"></param>
        /// <param name="graphics"></param>
        /// <param name="bars"></param>
        /// <param name="panelIdx"></param>
        /// <param name="fromIdx"></param>
        /// <param name="toIdx"></param>
        /// <param name="bounds"></param>
        /// <param name="max"></param>
        /// <param name="min"></param>
        public override void PaintBars(ChartControl chartControl, Graphics graphics, Data.Bars bars, int panelIdx, int fromIdx, int toIdx, Rectangle bounds, double max, double min)
        {
            if (fromIdx >= toIdx)             // DrawLines needs at least 2 elements to draw line
            {
                return;
            }

            System.Collections.ArrayList points = new System.Collections.ArrayList();

            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, UpColor, DownColor, System.Drawing.Drawing2D.LinearGradientMode.Vertical);


            if (fromIdx > 0)
            {
                fromIdx--;
            }
            if (toIdx < bars.Count - 1)
            {
                toIdx++;
            }

            for (int idx = fromIdx; idx <= toIdx; idx++)
            {
                int   x     = chartControl.GetXByBarIdx(bars, idx);
                Point point = new Point(x, chartControl.GetYByValue(bars, bars.GetClose(idx)));

                points.Add(point);
            }

            if (points.Count == 0)
            {
                return;
            }


            System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            graphics.DrawLines(Pen, (Point[])points.ToArray(typeof(Point)));


            points.Add(new Point(chartControl.GetXByBarIdx(bars, toIdx), bounds.Bottom));
            points.Add(new Point(chartControl.GetXByBarIdx(bars, fromIdx), bounds.Bottom));
            graphics.FillPolygon(brush, (Point[])points.ToArray(typeof(Point)));


            graphics.SmoothingMode = oldSmoothingMode;
        }
Ejemplo n.º 17
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            MindFusion.FlowChartX.ShapeTemplate shape =
                e.Value as MindFusion.FlowChartX.ShapeTemplate;

            if (shape == null)
            {
                return;
            }

            // Draw the shape
            RectangleF rect = new RectangleF(
                (float)e.Bounds.Left, (float)e.Bounds.Top,
                (float)e.Bounds.Width - 1, (float)e.Bounds.Height - 1);

            rect.Inflate(-2, -2);
            MindFusion.FlowChartX.ShapeTemplate.PathData data =
                shape.initData(rect, 0);
            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(Color.LightSteelBlue);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black);

            System.Drawing.Drawing2D.SmoothingMode mode =
                e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            System.Drawing.Drawing2D.GraphicsPath path =
                shape.getPath(data, 0);
            e.Graphics.FillPath(brush, path);
            e.Graphics.DrawPath(pen, path);
            path.Dispose();

            path = shape.getDecorationPath(data, 0);
            if (path != null)
            {
                e.Graphics.DrawPath(pen, path);
                path.Dispose();
            }

            e.Graphics.SmoothingMode = mode;

            pen.Dispose();
            brush.Dispose();
        }
        /// <summary>
        /// Resizes a bitmap
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="destW"></param>
        /// <param name="destH"></param>
        /// <param name="maintainProportions"></param>
        /// <param name="interpolationMode"></param>
        /// <param name="smoothingMode"></param>
        /// <returns></returns>
        public static Bitmap Resize(this Bitmap bitmap, int destW, int destH, bool maintainProportions = true,
                                    System.Drawing.Drawing2D.InterpolationMode interpolationMode       =
                                    System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic,
                                    System.Drawing.Drawing2D.SmoothingMode smoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias)
        {
            var output = new System.Drawing.Bitmap(destW, destH);

            if (!maintainProportions)
            {
                using (var g = System.Drawing.Graphics.FromImage(output))
                {
                    g.InterpolationMode = interpolationMode;
                    g.SmoothingMode     = smoothingMode;
                    g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                    g.DrawImage(bitmap, 0, 0, destW, destH);
                }
            }
            else
            {
                //get the scaling ratio
                var scaleRatio = Math.Min((double)destW / (double)bitmap.Width,
                                          (double)destH / (double)bitmap.Height);

                //resize image appropriately
                bitmap = Resize(bitmap, (int)(bitmap.Width * scaleRatio), (int)(bitmap.Height * scaleRatio), false,
                                interpolationMode, smoothingMode);

                //and paint it in the middle of destination canvas
                using (var g = System.Drawing.Graphics.FromImage(output))
                {
                    g.InterpolationMode = interpolationMode;
                    g.SmoothingMode     = smoothingMode;
                    g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                    g.DrawImage(
                        bitmap,
                        (destW - bitmap.Width) / 2,
                        (destH - bitmap.Height) / 2,
                        bitmap.Width,
                        bitmap.Height
                        );
                }
            }

            return(output);
        }
Ejemplo n.º 19
0
        private void Init()
        {
            drawables_      = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_     = new ArrayList();
            xAxisOverrides_ = new ArrayList();
            yAxisOverrides_ = new ArrayList();
            ordering_       = new SortedList();

            try
            {
                FontFamily fontFamily = new FontFamily("Arial");
                TitleFont = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            }
            catch (System.ArgumentException)
            {
                throw new NPlotException("Error: Arial font is not installed on this system");
            }

            padding_                    = 10;
            title_                      = "";
            autoScaleTitle_             = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_                     = null;
            xAxis2_                     = null;
            yAxis1_                     = null;
            yAxis2_                     = null;
            pXAxis1Cache_               = null;
            pYAxis1Cache_               = null;
            pXAxis2Cache_               = null;
            pYAxis2Cache_               = null;
            titleBrush_                 = new SolidBrush(Color.Black);
            plotBackColor_              = Color.White;

            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Ejemplo n.º 20
0
        public void drawLineDot(int x1, int y1, int x2, int y2, float thickness)
        {
            float oldThick = mPen.Width;

            mPen.Width = thickness;

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            System.Drawing.Drawing2D.DashStyle old = mPen.DashStyle;
            mPen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dot;
            mPen.DashPattern = new float[] { 5, 5 };

            mGraphics.DrawLine(mPen, x1, y1, x2, y2);

            mPen.Width = oldThick;
            mGraphics.SmoothingMode = oldSmoothMode;

            //  restore old state
            mPen.DashStyle = old;
        }
Ejemplo n.º 21
0
        public void drawLinesDot(short[] xy, int pointCnt)
        {
            System.Drawing.Drawing2D.DashStyle old = mPen.DashStyle;
            mPen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dot;
            mPen.DashPattern = new float[] { 5, 5 };

            System.Drawing.Drawing2D.SmoothingMode oldSmoothMode = mGraphics.SmoothingMode;
            mGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);

            if (pointCnt > xy.Length / 2)
            {
                pointCnt = xy.Length / 2;
            }

            int i = 0;
            int x0, y0, x, y;

            //path.StartFigure();
            x0 = xy[0];
            y0 = xy[1];
            for (i = 1; i < pointCnt; i++)
            {
                x = xy[2 * i];
                y = xy[2 * i + 1];
                path.AddLine(x0, y0, x, y);
                x0 = x;
                y0 = y;
            }
            //path.CloseFigure();
            mGraphics.DrawPath(mPen, path);

            //  restore old state
            mPen.DashStyle          = old;
            mGraphics.SmoothingMode = oldSmoothMode;
        }
Ejemplo n.º 22
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            DrawingUtils.FillRectangle(pe.Graphics, this.AccentColor, BarRect);

            if (ExpandButtonHighlighted == true)
            {
                DrawingUtils.FillRectangle(pe.Graphics, this.HighlightedAccentColor, ExpandButtonRect);
            }

            if (Expanded == false && MessageList.Lines != null && MessageList.Lines.Length > 0)
            {
                TextRenderer.DrawText(
                    pe.Graphics,
                    MessageList.Lines[MessageList.Lines.Length - 1] ?? string.Empty,
                    this.Font,
                    this.TextRect,
                    this.TextColor,
                    TextFormatFlags.TextBoxControl
                    | TextFormatFlags.VerticalCenter
                    | TextFormatFlags.Left
                    | TextFormatFlags.SingleLine
                    | TextFormatFlags.EndEllipsis);
            }

            using (SolidBrush brush = new SolidBrush(TextColor))
            {
                System.Drawing.Drawing2D.SmoothingMode lastSmoothingMode = pe.Graphics.SmoothingMode;
                pe.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                pe.Graphics.FillPolygon(
                    brush,
                    expandArrow);

                pe.Graphics.SmoothingMode = lastSmoothingMode;
            }
        }
Ejemplo n.º 23
0
        private void Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();

            try
            {
                FontFamily fontFamily = new FontFamily("Arial");
                TitleFont = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            }
            catch (System.ArgumentException)
            {
                throw new FlorenceException("Error: Arial font is not installed on this system");
            }

            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;
            outerBackColor = null;
            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Ejemplo n.º 24
0
        private void PaintCompass()
        {
            compass?.Dispose();     // ensure we are clean
            compass = null;

            pixelsperdegree = (double)this.Width / (double)WidthDegrees;

            int bitmapwidth  = (int)(360 * pixelsperdegree);       // size of bitmap
            int bitmapheight = Height * CompassHeightPercentage / 100;

            //System.Diagnostics.Debug.WriteLine("Compass width " + this.Width + " deg width " + WidthDegrees + " pix/deg " + pixelsperdegree);

            if (!DesignMode)        // for some reason, FromImage craps it out
            {
                compass = new Bitmap(bitmapwidth, bitmapheight);

                using (Graphics g = Graphics.FromImage(compass))
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

                    if (!BackColor.IsFullyTransparent())
                    {
                        using (Brush b = new SolidBrush(BackColor))
                            g.FillRectangle(b, new Rectangle(0, 0, compass.Width, compass.Height));

                        textsmoothingmode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    }
                    else
                    {
                        textsmoothingmode = System.Drawing.Drawing2D.SmoothingMode.None;
                    }

                    int yline = 0;

                    SizeF sz = g.MeasureString("360", Font);
                    fontline = bitmapheight - (int)(sz.Height + 1);
                    int bigtickdepth   = bitmapheight * TickHeightPercentage / 100;
                    int smalltickdepth = bigtickdepth / 2;

                    int stmajor = stencilmajortickat;
                    int stminor = stencilminortickat;

                    if (autosetstencilticks)
                    {
                        double minmajorticks = sz.Width / pixelsperdegree;
                        // System.Diagnostics.Debug.WriteLine("Major min ticks at {0} = {1}", sz.Width, minmajorticks);
                        if (minmajorticks >= 40)
                        {
                            stmajor = 80; stminor = 20;
                        }
                        else if (minmajorticks >= 20)
                        {
                            stmajor = 40; stminor = 10;
                        }
                        else if (minmajorticks >= 10)
                        {
                            stmajor = 20; stminor = 5;
                        }
                        else
                        {
                            stmajor = 10; stminor = 2;
                        }
                    }

                    Color sc    = Enabled ? StencilColor : StencilColor.Multiply(0.5F);
                    Pen   p1    = new Pen(sc, 1);
                    Pen   p2    = new Pen(sc, 2);
                    Brush textb = new SolidBrush(Enabled ? this.ForeColor : this.ForeColor.Multiply(0.5F));
                    var   fmt   = ControlHelpersStaticFunc.StringFormatFromContentAlignment(ContentAlignment.MiddleCenter);

                    for (int d = pixelstart; d < 360 + pixelstart; d++)
                    {
                        int x = (int)((d - pixelstart) * pixelsperdegree);

                        bool majortick = d % stmajor == 0;
                        bool minortick = (d % stminor == 0) && !majortick;

                        if (majortick)
                        {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                            g.DrawLine(p2, new Point(x, yline), new Point(x, yline + bigtickdepth));
                            g.SmoothingMode = textsmoothingmode;
                            g.DrawString(ToVisual(d).ToStringInvariant(), this.Font, textb, new Rectangle(x - 30, fontline, 60, compass.Height - fontline), fmt);

                            //DEBUG g.DrawLine(p1, x - sz.Width / 2, fontline, x + sz.Width / 2, fontline);
                        }

                        if (minortick)
                        {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                            g.DrawLine(p1, new Point(x, yline), new Point(x, yline + smalltickdepth));
                        }
                    }

                    p1.Dispose();
                    p2.Dispose();
                    textb.Dispose();
                    fmt.Dispose();
                }
            }
            else
            {           // FromImage above crashes the designer..
                emergencydesignlabel          = new Label();
                emergencydesignlabel.Location = new Point(10, 10);
                emergencydesignlabel.AutoSize = true;
                emergencydesignlabel.Text     = "Compass.. FromImage crashes designer";
                this.BackColor = Color.LightBlue;
                Controls.Add(emergencydesignlabel);
            }
        }
 protected override void OnRendering(Graphics g, Map map)
 {
     base.OnRendering(g, map);
     _smoothingMode  = g.SmoothingMode;
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
 }
Ejemplo n.º 26
0
 public DrawingBuffer(int width, int height, System.Drawing.Drawing2D.SmoothingMode smoothingMode)
     : this(new Structs.Size(width, height), smoothingMode)
 {
 }
Ejemplo n.º 27
0
 public static SmoothingMode ToNPlot(this SD.Drawing2D.SmoothingMode value) => (SmoothingMode)value;
Ejemplo n.º 28
0
        private void Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();

            try
            {
                TitleFont = DefaultTitleFont;
            }
            catch (System.ArgumentException)
            {
                throw new NPlotException("Error: Arial font is not installed on this system");
            }

            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;

            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Ejemplo n.º 29
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle backgroundRect  = new Rectangle(0, 0, this.Width, this.Height);
            Rectangle drawingZoneRect = new Rectangle(2, 2, this.Width - 4, this.Height - 4);
            Rectangle chartZoneRect   = new Rectangle((int)leftOffset, (int)topOffset, zoneWidth, zoneHeigth);

            // fill each rectangle with a solid color
            e.Graphics.FillRectangle(Brushes.Black, backgroundRect);
            e.Graphics.FillRectangle(Brushes.White, drawingZoneRect);
            e.Graphics.FillRectangle(Brushes.LightGray, chartZoneRect);


            Font         drawFontBold    = new Font("Tahoma", 9, FontStyle.Bold);
            Font         drawFont        = new Font("Tahoma", 8);
            StringFormat drawFormatTitle = new StringFormat();

            drawFormatTitle.Alignment = StringAlignment.Center;
            e.Graphics.DrawString(selectedLinearProperty.Description, drawFontBold, Brushes.Black,
                                  new RectangleF(0, 5, 256, 20), drawFormatTitle);
            StringFormat drawFormat = new StringFormat();

            drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;
            drawFormat             = new StringFormat();
            drawFormat.Alignment   = StringAlignment.Center;
            e.Graphics.DrawString("time [0 to 1]", drawFont, Brushes.Black, new RectangleF(leftOffset, topOffset + 204, zoneWidth, 20), drawFormat);
            for (int i = 0; i <= 10; i++)
            {
                int x = (int)(leftOffset + i * (zoneWidth / 10));
                int y = (int)(topOffset + i * (zoneHeigth / 10));
                e.Graphics.DrawLine(Pens.Gray, new PointF(x, topOffset), new PointF(x, topOffset + zoneHeigth - 1));
                e.Graphics.DrawLine(Pens.Gray, new PointF(leftOffset, y), new PointF(leftOffset + zoneWidth - 1, y));
            }

            PointF[] drawPoints = new PointF[selectedLinearProperty.Values.Count];
            for (int i = 0; i < selectedLinearProperty.Values.Count; i++)
            {
                float value = selectedLinearProperty.Values[i].Y;
                drawPoints[i] = convertLinearValuesToPixelCoordinates(selectedLinearProperty.Values[i]);
            }
            if (drawPoints.Length > 1)
            {
                System.Drawing.Drawing2D.SmoothingMode oldMode = e.Graphics.SmoothingMode;
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                e.Graphics.DrawLines(Pens.Blue, drawPoints);
                e.Graphics.SmoothingMode = oldMode;
            }
            for (int i = 0; i < selectedLinearProperty.Values.Count; i++)
            {
                Brush paintBrush = Brushes.Red;
                if (i == selectedPoint)
                {
                    paintBrush = Brushes.Aqua;
                    // tool tip
                    String tipText = Math.Round(selectedLinearProperty.Values[selectedPoint].X, 2) + " - "
                                     + Math.Round(selectedLinearProperty.Values[selectedPoint].Y, 2);
                    int tipWidth = (int)e.Graphics.MeasureString(tipText, drawFont).Width + 6;
                    int tipPos   = 10;
                    if (drawPoints[i].X + tipPos + tipWidth > 256)
                    {
                        tipPos = 256 - (int)drawPoints[i].X - tipWidth - tipPos;
                    }
                    Rectangle  tipRect  = new Rectangle((int)drawPoints[i].X + tipPos, (int)drawPoints[i].Y - 20, tipWidth, 16);
                    SolidBrush tipBrush = new SolidBrush(System.Drawing.Color.FromArgb(160, System.Drawing.Color.White));
                    e.Graphics.FillRectangle(tipBrush, tipRect);
                    e.Graphics.DrawRectangle(Pens.Black, tipRect);
                    StringFormat drawFormatTip = new StringFormat();
                    drawFormatTip.Alignment     = StringAlignment.Center;
                    drawFormatTip.LineAlignment = StringAlignment.Center;
                    e.Graphics.DrawString(tipText, drawFont, Brushes.Black,
                                          tipRect, drawFormatTip);
                    tipBrush.Dispose();
                }
                e.Graphics.FillRectangle(paintBrush, drawPoints[i].X - 3, drawPoints[i].Y - 3, 6, 6);
                e.Graphics.DrawRectangle(Pens.Black, drawPoints[i].X - 3, drawPoints[i].Y - 3, 6, 6);
            }
        }
		protected override void OnRendering(Graphics g, Map map)
		{
			base.OnRendering(g, map);
            _smoothingMode = g.SmoothingMode;
			g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
		}
Ejemplo n.º 31
0
        public void PlotSignal(double[] values, double pointSpacing = 1, double offsetX = 0, double offsetY = 0, float lineWidth = 1, Color?lineColor = null)
        {
            if (lineColor == null)
            {
                lineColor = Color.Red;
            }
            if (values == null)
            {
                return;
            }

            int    pointCount         = values.Length;
            double lastPointX         = offsetX + values.Length * pointSpacing;
            int    dataMinPx          = (int)((offsetX - xAxis.min) / xAxis.unitsPerPx);
            int    dataMaxPx          = (int)((lastPointX - xAxis.min) / xAxis.unitsPerPx);
            double binUnitsPerPx      = xAxis.unitsPerPx / pointSpacing;
            double dataPointsPerPixel = xAxis.unitsPerPx / pointSpacing;

            List <Point>  points = new List <Point>();
            List <double> Ys     = new List <double>();

            for (int i = 0; i < values.Length; i++)
            {
                Ys.Add(values[i]);                                     // copy entire array into list (SLOW!!!)
            }
            if (dataPointsPerPixel < 1)
            {
                // LOW DENSITY TRADITIONAL X/Y PLOTTING
                int iLeft  = (int)(((xAxis.min - offsetX) / xAxis.unitsPerPx) * dataPointsPerPixel);
                int iRight = iLeft + (int)(dataPointsPerPixel * bmpGraph.Width);
                for (int i = Math.Max(0, iLeft - 2); i < Math.Min(iRight + 3, Ys.Count - 1); i++)
                {
                    int xPx = xAxis.GetPixel((double)i * pointSpacing + offsetX);
                    int yPx = yAxis.GetPixel(Ys[i]);
                    points.Add(new Point(xPx, yPx));
                }
            }
            else
            {
                // BINNING IS REQUIRED FOR HIGH DENSITY PLOTTING
                for (int xPixel = Math.Max(0, dataMinPx); xPixel < Math.Min(bmpGraph.Width, dataMaxPx); xPixel++)
                {
                    int iLeft  = (int)(binUnitsPerPx * (xPixel - dataMinPx));
                    int iRight = (int)(iLeft + binUnitsPerPx);
                    iLeft  = Math.Max(iLeft, 0);
                    iRight = Math.Min(Ys.Count - 1, iRight);
                    iRight = Math.Max(iRight, 0);
                    if (iLeft == iRight)
                    {
                        continue;
                    }
                    double yPxMin = Ys.GetRange(iLeft, iRight - iLeft).Min() + offsetY;
                    double yPxMax = Ys.GetRange(iLeft, iRight - iLeft).Max() + offsetY;
                    points.Add(new Point(xPixel, yAxis.GetPixel(yPxMin)));
                    points.Add(new Point(xPixel, yAxis.GetPixel(yPxMax)));
                }
            }

            if (points.Count < 2)
            {
                return;
            }
            Pen        penLine     = new Pen(new SolidBrush((Color)lineColor), lineWidth);
            float      markerSize  = 3;
            SolidBrush markerBrush = new SolidBrush((Color)lineColor);

            System.Drawing.Drawing2D.SmoothingMode originalSmoothingMode = gfxGraph.SmoothingMode;
            gfxGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; // no antialiasing


            // todo: prevent infinite zooming overflow errors
            try {
                gfxGraph.DrawLines(penLine, points.ToArray());

                if (dataPointsPerPixel < .5)
                {
                    foreach (Point pt in points)
                    {
                        gfxGraph.FillEllipse(markerBrush, pt.X - markerSize / 2, pt.Y - markerSize / 2, markerSize, markerSize);
                    }
                }
            }
            catch (Exception ex) {
                System.Console.WriteLine("Exception plotting");
            }


            gfxGraph.SmoothingMode = originalSmoothingMode;
            this.pointCount       += values.Length;
        }
Ejemplo n.º 32
0
        private void Init()
        {
            drawables_ = new ArrayList();
            xAxisPositions_ = new ArrayList();
            yAxisPositions_ = new ArrayList();
            zPositions_ = new ArrayList();
            ordering_ = new SortedList();
            FontFamily fontFamily = new FontFamily("Arial");
            TitleFont = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            padding_ = 10;
            title_ = "";
            autoScaleTitle_ = false;
            autoScaleAutoGeneratedAxes_ = false;
            xAxis1_ = null;
            xAxis2_ = null;
            yAxis1_ = null;
            yAxis2_ = null;
            pXAxis1Cache_ = null;
            pYAxis1Cache_ = null;
            pXAxis2Cache_ = null;
            pYAxis2Cache_ = null;
            titleBrush_ = new SolidBrush( Color.Black );
            plotBackColor_ = Color.White;

            this.legend_ = null;

            smoothingMode_ = System.Drawing.Drawing2D.SmoothingMode.None;

            axesConstraints_ = new ArrayList();
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Draw the the PlotSurface2D and all contents [axes, drawables, and legend] on the
        /// supplied graphics surface.
        /// </summary>
        /// <param name="g">The graphics surface on which to draw.</param>
        /// <param name="bounds">A bounding box on this surface that denotes the area on the
        /// surface to confine drawing to.</param>
        public void Draw(Graphics g, Rectangle bounds)
        {
            // determine font sizes and tick scale factor.
            float scale = DetermineScaleFactor(bounds.Width, bounds.Height);

            // if there is nothing to plot, return.
            if (drawables_.Count == 0)
            {
                // draw title
                float x_center = (bounds.Left + bounds.Right) / 2.0f;
                float y_center = (bounds.Top + bounds.Bottom) / 2.0f;
                Font  scaled_font;
                if (AutoScaleTitle)
                {
                    scaled_font = Utils.ScaleFont(titleFont_, scale);
                }
                else
                {
                    scaled_font = titleFont_;
                }
                g.DrawString(title_, scaled_font, titleBrush_, new PointF(x_center, y_center), titleDrawFormat_);

                return;
            }

            // determine the [non physical] axes to draw based on the axis properties set.
            Axis xAxis1 = null;
            Axis xAxis2 = null;
            Axis yAxis1 = null;
            Axis yAxis2 = null;

            DetermineAxesToDraw(out xAxis1, out xAxis2, out yAxis1, out yAxis2);

            // apply scale factor to axes as desired.

            if (xAxis1.AutoScaleTicks)
            {
                xAxis1.TickScale = scale;
            }
            if (xAxis1.AutoScaleText)
            {
                xAxis1.FontScale = scale;
            }
            if (yAxis1.AutoScaleTicks)
            {
                yAxis1.TickScale = scale;
            }
            if (yAxis1.AutoScaleText)
            {
                yAxis1.FontScale = scale;
            }
            if (xAxis2.AutoScaleTicks)
            {
                xAxis2.TickScale = scale;
            }
            if (xAxis2.AutoScaleText)
            {
                xAxis2.FontScale = scale;
            }
            if (yAxis2.AutoScaleTicks)
            {
                yAxis2.TickScale = scale;
            }
            if (yAxis2.AutoScaleText)
            {
                yAxis2.FontScale = scale;
            }

            // determine the default physical positioning of those axes.
            PhysicalAxis pXAxis1 = null;
            PhysicalAxis pYAxis1 = null;
            PhysicalAxis pXAxis2 = null;
            PhysicalAxis pYAxis2 = null;

            DeterminePhysicalAxesToDraw(
                bounds, xAxis1, xAxis2, yAxis1, yAxis2,
                out pXAxis1, out pXAxis2, out pYAxis1, out pYAxis2);

            float oldXAxis2Height = pXAxis2.PhysicalMin.Y;

            // Apply axes constraints
            for (int i = 0; i < axesConstraints_.Count; ++i)
            {
                ((AxesConstraint)axesConstraints_[i]).ApplyConstraint(
                    pXAxis1, pYAxis1, pXAxis2, pYAxis2);
            }

            /////////////////////////////////////////////////////////////////////////
            // draw legend if have one.
            // Note: this will update axes if necessary.

            Point legendPosition = new Point(0, 0);

            if (legend_ != null)
            {
                legend_.UpdateAxesPositions(
                    pXAxis1, pYAxis1, pXAxis2, pYAxis2,
                    drawables_, scale, padding_, bounds,
                    out legendPosition);
            }

            float newXAxis2Height = pXAxis2.PhysicalMin.Y;

            float titleExtraOffset = oldXAxis2Height - newXAxis2Height;

            // now we are ready to define the bounding box for the plot area (to use in clipping
            // operations.
            plotAreaBoundingBoxCache_ = new Rectangle(
                Math.Min(pXAxis1.PhysicalMin.X, pXAxis1.PhysicalMax.X),
                Math.Min(pYAxis1.PhysicalMax.Y, pYAxis1.PhysicalMin.Y),
                Math.Abs(pXAxis1.PhysicalMax.X - pXAxis1.PhysicalMin.X + 1),
                Math.Abs(pYAxis1.PhysicalMin.Y - pYAxis1.PhysicalMax.Y + 1)
                );
            bbXAxis1Cache_ = pXAxis1.GetBoundingBox();
            bbXAxis2Cache_ = pXAxis2.GetBoundingBox();
            bbYAxis1Cache_ = pYAxis1.GetBoundingBox();
            bbYAxis2Cache_ = pYAxis2.GetBoundingBox();

            // Fill in the background.
            if (plotBackColor_ != null)
            {
                g.FillRectangle(
                    new System.Drawing.SolidBrush((Color)plotBackColor_),
                    (Rectangle)plotAreaBoundingBoxCache_);
            }
            else if (plotBackBrush_ != null)
            {
                g.FillRectangle(
                    plotBackBrush_.Get((Rectangle)plotAreaBoundingBoxCache_),
                    (Rectangle)plotAreaBoundingBoxCache_);
            }
            else if (plotBackImage_ != null)
            {
                g.DrawImage(
                    Utils.TiledImage(plotBackImage_, new Size(
                                         ((Rectangle)plotAreaBoundingBoxCache_).Width,
                                         ((Rectangle)plotAreaBoundingBoxCache_).Height)),
                    (Rectangle)plotAreaBoundingBoxCache_);
            }

            // draw title
            float xt = (pXAxis2.PhysicalMax.X + pXAxis2.PhysicalMin.X) / 2.0f;
            float yt = bounds.Top + padding_ - titleExtraOffset;
            Font  scaledFont;

            if (AutoScaleTitle)
            {
                scaledFont = Utils.ScaleFont(titleFont_, scale);
            }
            else
            {
                scaledFont = titleFont_;
            }
            g.DrawString(title_, scaledFont, titleBrush_, new PointF(xt, yt), titleDrawFormat_);

            //count number of new lines in title.
            int nlCount = 0;

            for (int i = 0; i < title_.Length; ++i)
            {
                if (title_[i] == '\n')
                {
                    nlCount += 1;
                }
            }

            SizeF s = g.MeasureString(title_, scaledFont);

            bbTitleCache_ = new Rectangle((int)(xt - s.Width / 2), (int)(yt), (int)(s.Width), (int)(s.Height) * (nlCount + 1));

            // draw drawables..
            System.Drawing.Drawing2D.SmoothingMode smoothSave = g.SmoothingMode;

            g.SmoothingMode = smoothingMode_;

            bool legendDrawn = false;

            for (int i_o = 0; i_o < ordering_.Count; ++i_o)
            {
                int    i      = (int)ordering_.GetByIndex(i_o);
                double zOrder = (double)ordering_.GetKey(i_o);
                if (zOrder > legendZOrder_)
                {
                    // draw legend.
                    if (!legendDrawn && legend_ != null)
                    {
                        legend_.Draw(g, legendPosition, drawables_, scale);
                        legendDrawn = true;
                    }
                }

                IDrawable     drawable = (IDrawable)drawables_[i];
                XAxisPosition xap      = (XAxisPosition)xAxisPositions_[i];
                YAxisPosition yap      = (YAxisPosition)yAxisPositions_[i];

                PhysicalAxis drawXAxis;
                PhysicalAxis drawYAxis;

                if (xap == XAxisPosition.Bottom)
                {
                    drawXAxis = pXAxis1;
                }
                else
                {
                    drawXAxis = pXAxis2;
                }

                if (yap == YAxisPosition.Left)
                {
                    drawYAxis = pYAxis1;
                }
                else
                {
                    drawYAxis = pYAxis2;
                }

                // set the clipping region.. (necessary for zoom)
                g.Clip = new Region((Rectangle)plotAreaBoundingBoxCache_);
                // plot.
                drawable.Draw(g, drawXAxis, drawYAxis);
                // reset it..
                g.ResetClip();
            }

            if (!legendDrawn && legend_ != null)
            {
                legend_.Draw(g, legendPosition, drawables_, scale);
            }

            // cache the physical axes we used on this draw;
            pXAxis1Cache_ = pXAxis1;
            pYAxis1Cache_ = pYAxis1;
            pXAxis2Cache_ = pXAxis2;
            pYAxis2Cache_ = pYAxis2;

            g.SmoothingMode = smoothSave;

            // now draw axes.
            Rectangle axisBounds;

            pXAxis1.Draw(g, out axisBounds);
            pXAxis2.Draw(g, out axisBounds);
            pYAxis1.Draw(g, out axisBounds);
            pYAxis2.Draw(g, out axisBounds);

#if DEBUG_BOUNDING_BOXES
            g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbXAxis1Cache_);
            g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbXAxis2Cache_);
            g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbYAxis1Cache_);
            g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbYAxis2Cache_);
            g.DrawRectangle(new Pen(Color.Red, 5.0F), (Rectangle)plotAreaBoundingBoxCache_);
            //if(this.ShowLegend)g.DrawRectangle( new Pen(Color.Chocolate, 3.0F), (Rectangle) bbLegendCache_);
            g.DrawRectangle(new Pen(Color.DeepPink, 2.0F), (Rectangle)bbTitleCache_);
#endif
        }
Ejemplo n.º 34
0
        virtual public void DrawGrabbers(IDisplay display)
        {
            IMultiPoint grabbers = Grabbers(display, true);

            if (grabbers == null)
            {
                return;
            }

            System.Drawing.Drawing2D.SmoothingMode smode = display.GraphicsContext.SmoothingMode;
            display.GraphicsContext.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            SimplePointSymbol pointSymbol = new SimplePointSymbol();

            pointSymbol.Color        = System.Drawing.Color.White;
            pointSymbol.OutlineColor = System.Drawing.Color.Black;
            pointSymbol.OutlineWidth = 1;
            pointSymbol.Size         = 8;

            if (display.GraphicsContainer.EditMode == GrabberMode.Pointer)
            {
                Ring ring = new Ring();
                for (int i = 0; i < Math.Min(grabbers.PointCount, 4); i++)
                {
                    ring.AddPoint(grabbers[i]);
                }
                Polygon polygon = new Polygon();
                polygon.AddRing(ring);

                SimpleLineSymbol lSymbol = new SimpleLineSymbol();
                lSymbol.Color     = System.Drawing.Color.Gray;
                lSymbol.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                display.Draw(lSymbol, polygon);
                lSymbol.Release();

                for (int i = 0; i < grabbers.PointCount; i++)
                {
                    if (!UseGrabber((GrabberIDs)i))
                    {
                        continue;
                    }

                    if (i > 7 && pointSymbol.Color == System.Drawing.Color.White)
                    {
                        pointSymbol.Color = System.Drawing.Color.Yellow;
                        DrawRotationGrabberline(display);
                    }
                    display.Draw(pointSymbol, grabbers[i]);
                }
            }
            else if (display.GraphicsContainer.EditMode == GrabberMode.Vertex)
            {
                pointSymbol.Marker = SimplePointSymbol.MarkerType.Square;
                pointSymbol.Size   = 5;

                for (int i = 0; i < grabbers.PointCount; i++)
                {
                    display.Draw(pointSymbol, grabbers[i]);
                }
            }

            display.GraphicsContext.SmoothingMode = smode;
        }
Ejemplo n.º 35
0
        public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            // FillPath doesn't support specifying FillMode, it always uses FillMode.Alternate,
            // so we have to use Graphics.FillPolygon method in other cases.
            if (!_closePath || base.Brush == null || _fillMode == System.Drawing.Drawing2D.FillMode.Alternate)
            {
                base.Draw(renderingRect, g, coordinateMapper);
            }
            else
            {
                System.Drawing.PointF[] transformedPoints = VObjectsUtils.TransformPoints(base.Transform, _points);
                for (int i = 0; i < transformedPoints.Length; i++)
                {
                    transformedPoints[i] = coordinateMapper.WorkspaceToControl(transformedPoints[i], Aurigma.GraphicsMill.Unit.Point);
                }

                System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode;
                System.Drawing.Pen pen = base.CreateViewportPen(coordinateMapper);
                try
                {
                    switch (base.DrawMode)
                    {
                    case VObjectDrawMode.Draft:
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                        break;

                    case VObjectDrawMode.Normal:
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        break;

                    default:
                        throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode"));
                    }

                    if (base.Brush != null)
                    {
                        AdaptBrushToViewport(coordinateMapper);
                        try
                        {
                            g.FillPolygon(base.Brush, transformedPoints, _fillMode);
                        }
                        finally
                        {
                            RestoreBrush();
                        }
                    }
                    if (pen != null)
                    {
                        g.DrawPolygon(pen, transformedPoints);
                    }
                }
                finally
                {
                    pen.Dispose();
                    g.SmoothingMode = oldSmoothingMode;
                }
            }
        }