Example #1
0
        static void DrawPathAlternateAndWinding(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawPath (alternate / winding)");

            XPen pen = new XPen(XColors.Navy, 2.5);

            // Alternate fill mode
            XGraphicsPath path = new XGraphicsPath();

            path.FillMode = XFillMode.Alternate;
            path.AddLine(10, 130, 10, 40);
            path.AddBeziers(new XPoint[] { new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40),
                                           new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40) });
            path.AddLine(120, 40, 120, 130);
            path.CloseFigure();
            path.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);

            // Winding fill mode
            path          = new XGraphicsPath();
            path.FillMode = XFillMode.Winding;
            path.AddLine(130, 130, 130, 40);
            path.AddBeziers(new XPoint[] { new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40),
                                           new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40) });
            path.AddLine(240, 40, 240, 130);
            path.CloseFigure();
            path.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);

            EndBox(gfx);
        }
Example #2
0
        void RenderAlternatePath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.Navy, 2.5);

            // Alternate fill mode
            XGraphicsPath path = new XGraphicsPath();

            path.FillMode = XFillMode.Alternate;
            path.AddLine(10, 130, 10, 40);
            path.AddBeziers(new XPoint[] { new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40),
                                           new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40) });
            path.AddLine(120, 40, 120, 130);
            path.CloseFigure();
            path.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);
        }
Example #3
0
        void RenderWindingPath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 150);

            XPen pen = new XPen(XColors.Navy, 2.5);

            // Winding fill mode
            XGraphicsPath path = new XGraphicsPath();

            path          = new XGraphicsPath();
            path.FillMode = XFillMode.Winding;
            path.AddLine(130, 130, 130, 40);
            path.AddBeziers(new XPoint[] { new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40),
                                           new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40) });
            path.AddLine(240, 40, 240, 130);
            path.CloseFigure();
            path.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);
        }
Example #4
0
        private void DrawPathAlternateAndWinding(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawPath (alternate / winding)");
            XPen          pen           = new XPen(XColors.Navy, 2.5);
            XGraphicsPath xGraphicsPath = new XGraphicsPath();

            xGraphicsPath.FillMode = XFillMode.Alternate;
            xGraphicsPath.AddLine(10, 130, 10, 40);
            xGraphicsPath.AddBeziers(new XPoint[]
            {
                new XPoint(10.0, 40.0),
                new XPoint(30.0, 0.0),
                new XPoint(40.0, 20.0),
                new XPoint(60.0, 40.0),
                new XPoint(80.0, 60.0),
                new XPoint(100.0, 60.0),
                new XPoint(120.0, 40.0)
            });
            xGraphicsPath.AddLine(120, 40, 120, 130);
            xGraphicsPath.CloseFigure();
            xGraphicsPath.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, xGraphicsPath);
            xGraphicsPath          = new XGraphicsPath();
            xGraphicsPath.FillMode = XFillMode.Winding;
            xGraphicsPath.AddLine(130, 130, 130, 40);
            xGraphicsPath.AddBeziers(new XPoint[]
            {
                new XPoint(130.0, 40.0),
                new XPoint(150.0, 0.0),
                new XPoint(160.0, 20.0),
                new XPoint(180.0, 40.0),
                new XPoint(200.0, 60.0),
                new XPoint(220.0, 60.0),
                new XPoint(240.0, 40.0)
            });
            xGraphicsPath.AddLine(240, 40, 240, 130);
            xGraphicsPath.CloseFigure();
            xGraphicsPath.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, xGraphicsPath);
            base.EndBox(gfx);
        }
Example #5
0
        /// <summary>
        /// Draws the marker given through rendererInfo at the specified position. Position specifies
        /// the center of the marker.
        /// </summary>
        internal static void Draw(XGraphics graphics, XPoint pos, MarkerRendererInfo rendererInfo)
        {
#if SILVERLIGHT
            return; // BUG: Code crashs Silverlight Path class.

#pragma warning disable 0162
#endif

            if (rendererInfo.MarkerStyle == MarkerStyle.None)
            {
                return;
            }

            double size = rendererInfo.MarkerSize;
            double size2 = size / 2;
            double x0, y0, x1, y1;
            double g;

            XPen   foreground = new XPen(rendererInfo.MarkerForegroundColor, 0.5);
            XBrush background = new XSolidBrush(rendererInfo.MarkerBackgroundColor);

            XGraphicsPath gp = new XGraphicsPath();
            switch (rendererInfo.MarkerStyle)
            {
            case MarkerStyle.Square:
                x0 = pos.X - size2;
                y0 = pos.Y - size2;
                x1 = pos.X + size2;
                y1 = pos.Y + size2;
                gp.AddLine(x0, y0, x1, y0);
                gp.AddLine(x1, y0, x1, y1);
                gp.AddLine(x1, y1, x0, y1);
                gp.AddLine(x0, y1, x0, y0);
                break;

            case MarkerStyle.Diamond:
                gp.AddLine(x1                   = pos.X + size2, pos.Y, pos.X, y0 = pos.Y - size2);
                gp.AddLine(pos.X, y0, x0        = pos.X - size2, pos.Y);
                gp.AddLine(x0, pos.Y, pos.X, y1 = pos.Y + size2);
                gp.AddLine(pos.X, y1, x1, pos.Y);
                break;

            case MarkerStyle.Triangle:
                y0 = pos.Y + size / 2;
                y1 = pos.Y - size / 2;
                g  = Math.Sqrt(size * size * 4 / 3) / 2;
                gp.AddLine(pos.X, y1, pos.X + g, y0);
                gp.AddLine(pos.X + g, y0, pos.X - g, y0);
                gp.AddLine(pos.X - g, y0, pos.X, y1);
                break;

            case MarkerStyle.Plus:
                g = size2 / 4;
                gp.AddLine(pos.X - size2, pos.Y + g, pos.X - g, pos.Y + g);
                gp.AddLine(pos.X - g, pos.Y + g, pos.X - g, pos.Y + size2);
                gp.AddLine(pos.X - g, pos.Y + size2, pos.X + g, pos.Y + size2);
                gp.AddLine(pos.X + g, pos.Y + size2, pos.X + g, pos.Y + g);
                gp.AddLine(pos.X + g, pos.Y + g, pos.X + size2, pos.Y + g);
                gp.AddLine(pos.X + size2, pos.Y + g, pos.X + size2, pos.Y - g);
                gp.AddLine(pos.X + size2, pos.Y - g, pos.X + g, pos.Y - g);
                gp.AddLine(pos.X + g, pos.Y - g, pos.X + g, pos.Y - size2);
                gp.AddLine(pos.X + g, pos.Y - size2, pos.X - g, pos.Y - size2);
                gp.AddLine(pos.X - g, pos.Y - size2, pos.X - g, pos.Y - g);
                gp.AddLine(pos.X - g, pos.Y - g, pos.X - size2, pos.Y - g);
                gp.AddLine(pos.X - size2, pos.Y - g, pos.X - size2, pos.Y + g);
                break;

            case MarkerStyle.Circle:
            case MarkerStyle.Dot:
                x0 = pos.X - size2;
                y0 = pos.Y - size2;
                gp.AddEllipse(x0, y0, size, size);
                break;

            case MarkerStyle.Dash:
                x0 = pos.X - size2;
                y0 = pos.Y - size2 / 3;
                x1 = pos.X + size2;
                y1 = pos.Y + size2 / 3;
                gp.AddLine(x0, y0, x1, y0);
                gp.AddLine(x1, y0, x1, y1);
                gp.AddLine(x1, y1, x0, y1);
                gp.AddLine(x0, y1, x0, y0);
                break;

            case MarkerStyle.X:
                g = size / 4;
                gp.AddLine(pos.X - size2 + g, pos.Y - size2, pos.X, pos.Y - g);
                gp.AddLine(pos.X, pos.Y - g, pos.X + size2 - g, pos.Y - size2);
                gp.AddLine(pos.X + size2 - g, pos.Y - size2, pos.X + size2, pos.Y - size2 + g);
                gp.AddLine(pos.X + size2, pos.Y - size2 + g, pos.X + g, pos.Y);
                gp.AddLine(pos.X + g, pos.Y, pos.X + size2, pos.Y + size2 - g);
                gp.AddLine(pos.X + size2, pos.Y + size2 - g, pos.X + size2 - g, pos.Y + size2);
                gp.AddLine(pos.X + size2 - g, pos.Y + size2, pos.X, pos.Y + g);
                gp.AddLine(pos.X, pos.Y + g, pos.X - size2 + g, pos.Y + size2);
                gp.AddLine(pos.X - size2 + g, pos.Y + size2, pos.X - size2, pos.Y + size2 - g);
                gp.AddLine(pos.X - size2, pos.Y + size2 - g, pos.X - g, pos.Y);
                gp.AddLine(pos.X - g, pos.Y, pos.X - size2, pos.Y - size2 + g);
                break;

            case MarkerStyle.Star:
            {
                XPoint[] points = new XPoint[10];

                double radStep     = 2 * Math.PI / 5;
                double outerCircle = size / 2;
                double innerCircle = size / 5;
                // outer circle
                double rad = -(Math.PI / 2);         // 90�
                for (int idx = 0; idx < 10; idx += 2)
                {
                    points[idx].X = pos.X + outerCircle * Math.Cos(rad);
                    points[idx].Y = pos.Y + outerCircle * Math.Sin(rad);
                    rad          += radStep;
                }

                // inner circle
                rad = -(Math.PI / 4);         // 45�
                double x = innerCircle * Math.Cos(rad);
                double y = innerCircle * Math.Sin(rad);
                points[1].X = pos.X + x;
                points[1].Y = pos.Y + y;
                points[9].X = pos.X - x;
                points[9].Y = pos.Y + y;
                rad        += radStep;
                x           = innerCircle * Math.Cos(rad);
                y           = innerCircle * Math.Sin(rad);
                points[3].X = pos.X + x;
                points[3].Y = pos.Y + y;
                points[7].X = pos.X - x;
                points[7].Y = pos.Y + y;
                rad        += radStep;
                y           = innerCircle * Math.Sin(rad);
                points[5].X = pos.X;
                points[5].Y = pos.Y + y;
                gp.AddLines(points);
            }
            break;
            }

            gp.CloseFigure();
            if (rendererInfo.MarkerStyle != MarkerStyle.Dot)
            {
                graphics.DrawPath(background, gp);
                graphics.DrawPath(foreground, gp);
            }
        }