Exemple #1
0
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPolygon polygon, IAreaStyle style)
        {
            if (polygon == null || style == null)
            {
                return;
            }

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

            gp.AddPolygon(RenderUtil.CoordToPoint(polygon.Shell.Coordinates));
            foreach (ILinearRing l in polygon.Holes)
            {
                gp.AddPolygon(RenderUtil.CoordToPoint(l.Coordinates));
            }
            gp.CloseFigure();

            if (style.Fill != null)
            {
                RenderUtil.RenderFill(engine, graphics, gp, style.Fill);
            }

            if (style.Outline != null)
            {
                RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
            }
        }
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style)
        {
            if (line == null || style == null)
                return;

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            //TODO: Does not seems to add a single long line, but multiple line segments
            gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates));

            if (style.Outlines != null)
                foreach(IOutline linestyle in style.Outlines)
                    RenderUtil.RenderOutline(engine, graphics, gp, linestyle);
        }
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPolygon polygon, IAreaStyle style)
        {
            if (polygon == null || style == null) return;

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

            gp.AddPolygon(RenderUtil.CoordToPoint(polygon.Shell.Coordinates));
            foreach (ILinearRing l in polygon.Holes)
                gp.AddPolygon(RenderUtil.CoordToPoint(l.Coordinates));
            gp.CloseFigure();

            if (style.Fill != null) RenderUtil.RenderFill(engine, graphics, gp, style.Fill);

            if (style.Outline != null) RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
        }
        public static void RenderFill(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IFill fill)
        {
            Brush brush;
            if (fill.Pattern != null)
            {
                //TODO: Make this
                return;
            }
            else
            {
                //TODO: Hatch style
                brush = new System.Drawing.SolidBrush(fill.ForegroundColor);
            }

            using(brush)
                if (fill.Pattern == null) graphics.FillPath(brush, path);

        }
        public static void RenderOutline(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IOutline line)
        {
            Pen pen;
            if (line.Pattern != null)
            {
                //TODO: Fix this
                return;
            }
            else
            {
                //TODO: Dash style
                pen = new Pen(line.ForegroundColor, line.Width);
            }

            if (line.Pattern == null)
                graphics.DrawPath(pen, path);


        }
Exemple #6
0
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style)
        {
            if (line == null || style == null)
            {
                return;
            }

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            //TODO: Does not seems to add a single long line, but multiple line segments
            gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates));

            if (style.Outlines != null)
            {
                foreach (IOutline linestyle in style.Outlines)
                {
                    RenderUtil.RenderOutline(engine, graphics, gp, linestyle);
                }
            }
        }
Exemple #7
0
        public static void RenderOutline(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IOutline line)
        {
            Pen pen;

            if (line.Pattern != null)
            {
                //TODO: Fix this
                return;
            }
            else
            {
                //TODO: Dash style
                pen = new Pen(line.ForegroundColor, line.Width);
            }

            if (line.Pattern == null)
            {
                graphics.DrawPath(pen, path);
            }
        }
Exemple #8
0
        public static void RenderFill(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IFill fill)
        {
            Brush brush;

            if (fill.Pattern != null)
            {
                //TODO: Make this
                return;
            }
            else
            {
                //TODO: Hatch style
                brush = new System.Drawing.SolidBrush(fill.ForegroundColor);
            }

            using (brush)
                if (fill.Pattern == null)
                {
                    graphics.FillPath(brush, path);
                }
        }
Exemple #9
0
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPoint point, IPointStyle style)
        {
            if (point == null || style == null)
            {
                return;
            }

            if (style.Type == global::LittleSharpRenderEngine.Style.Point.PointType.Symbol)
            {
                return;
            }
            else
            {
                int w = style.Size.Width / 2;
                int h = style.Size.Height / 2;
                System.Drawing.Point[] points;

                switch (style.Type)
                {
                case global::LittleSharpRenderEngine.Style.Point.PointType.Circle:
                    int pc = (int)Math.Max(8, Math.Log10(Math.Max(w, h)));
                    points = new System.Drawing.Point[pc + 1];

                    double fr = (2 * Math.PI) / pc;

                    for (int i = 0; i < pc; i++)
                    {
                        points[i] = new System.Drawing.Point((int)(Math.Cos(fr * i) * w + point.X), (int)(Math.Sin(fr * i) * h + point.Y));
                    }
                    points[pc] = points[0];
                    break;

                case global::LittleSharpRenderEngine.Style.Point.PointType.Square:
                    points = new System.Drawing.Point[]
                    {
                        new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
                        new System.Drawing.Point((int)point.X + w, (int)point.Y - h),
                        new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
                        new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                        new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
                    };
                    break;

                case global::LittleSharpRenderEngine.Style.Point.PointType.Triangle:
                    points = new System.Drawing.Point[]
                    {
                        new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                        new System.Drawing.Point((int)point.X, (int)point.Y - h),
                        new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
                        new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                    };
                    break;

                default:
                    return;
                }

                //TODO: Apply rotation
                if (style.Type != global::LittleSharpRenderEngine.Style.Point.PointType.Circle)
                {
                }

                //Apply offset
                for (int i = 0; i < points.Length; i++)
                {
                    points[i].X += (w - style.Center.X);
                    points[i].Y += (h - style.Center.Y);
                }

                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                gp.AddPolygon(points);
                gp.CloseFigure();

                if (style.Fill != null)
                {
                    RenderUtil.RenderFill(engine, graphics, gp, style.Fill);
                }

                if (style.Outline != null)
                {
                    RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
                }
            }
        }
        public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPoint point, IPointStyle style)
        {
            if (point == null || style == null)
                return;

            if (style.Type == global::LittleSharpRenderEngine.Style.Point.PointType.Symbol)
            {
                return;
            }
            else
            {
                int w = style.Size.Width / 2;
                int h = style.Size.Height / 2;
                System.Drawing.Point[] points;

                switch (style.Type)
                {
                    case global::LittleSharpRenderEngine.Style.Point.PointType.Circle:
                        int pc = (int)Math.Max(8, Math.Log10(Math.Max(w, h)));
                        points = new System.Drawing.Point[pc + 1];

                        double fr = (2*Math.PI) / pc;

                        for (int i = 0; i < pc; i++)
                            points[i] = new System.Drawing.Point((int)(Math.Cos(fr * i) * w + point.X), (int)(Math.Sin(fr * i) * h + point.Y));
                        points[pc] = points[0];
                        break;
                    case global::LittleSharpRenderEngine.Style.Point.PointType.Square:
                        points = new System.Drawing.Point[] 
                                {
                                    new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
                                    new System.Drawing.Point((int)point.X + w, (int)point.Y - h),
                                    new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
                                    new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                                    new System.Drawing.Point((int)point.X - w, (int)point.Y - h),
                                };
                        break;
                    case global::LittleSharpRenderEngine.Style.Point.PointType.Triangle:
                        points = new System.Drawing.Point[] 
                                {
                                    new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                                    new System.Drawing.Point((int)point.X, (int)point.Y - h),
                                    new System.Drawing.Point((int)point.X + w, (int)point.Y + h),
                                    new System.Drawing.Point((int)point.X - w, (int)point.Y + h),
                                };
                        break;
                    default:
                        return;
                }

                //TODO: Apply rotation
                if (style.Type != global::LittleSharpRenderEngine.Style.Point.PointType.Circle)
                {
                }

                //Apply offset
                for (int i = 0; i < points.Length; i++)
                {
                    points[i].X += (w - style.Center.X);
                    points[i].Y += (h - style.Center.Y);
                }

                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                gp.AddPolygon(points);
                gp.CloseFigure();

                if (style.Fill != null)
                    RenderUtil.RenderFill(engine, graphics, gp, style.Fill);

                if (style.Outline != null)
                    RenderUtil.RenderOutline(engine, graphics, gp, style.Outline);
            }
        }