コード例 #1
0
        public override void AddToPath(IGraphicsPath graphicsPath)
        {
            var pathData = graphicsPath.PathData;
            var points   = pathData.Points;

            if (points.Length <= 0)
            {
                return;
            }

            // Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
            var last = points.Length - 1;

            if (!points[0].Equals(points[last]))
            {
                var i = last;
                while (i > 0 && pathData.Types[i] > 0)
                {
                    --i;
                }
                graphicsPath.AddLine(points[last], points[i]);
            }

            graphicsPath.CloseFigure();
        }
コード例 #2
0
        private static IGraphicsPath ConvertPolygon(IDisplay display, IPolygon polygon, IGraphicsPath gp)
        {
            //if (polygon == null || polygon.RingCount == 0)
            //    return null;

            for (int r = 0; r < polygon.RingCount; r++)
            {
                bool  first  = true;
                int   count  = 0;
                IRing ring   = polygon[r];
                int   pCount = ring.PointCount;

                //double o_x = -1e10, o_y = -1e10;
                float o_x = float.MinValue, o_y = float.MinValue;
                gp.StartFigure();
                for (int p = 0; p < pCount; p++)
                {
                    IPoint point = ring[p];
                    double x = point.X, y = point.Y;

                    display.World2Image(ref x, ref y);

                    //
                    // Auf 0.1 Pixel runden, sonst kann es bei fast
                    // horizontalen (vertikalen) Linien zu Fehlern kommen
                    // -> Eine hälfte (beim Bruch) wird nicht mehr gezeichnet
                    //
                    x = Math.Round(x, 1);
                    y = Math.Round(y, 1);

                    if (!((float)o_x == (float)x &&
                          (float)o_y == (float)y))
                    {
                        if (!first)
                        {
                            gp.AddLine(
                                (float)o_x,
                                (float)o_y,
                                (float)x,
                                (float)y);
                            count++;
                        }
                        else
                        {
                            first = false;
                        }
                    }
                    o_x = (float)x;
                    o_y = (float)y;
                }
                if (count > 0)
                {
                    gp.CloseFigure();
                }
            }

            return(gp);
        }
コード例 #3
0
        private static IGraphicsPath ConvertEnvelope(IDisplay display, IEnvelope envelope, IGraphicsPath gp)
        {
            double minx = envelope.minx, miny = envelope.miny;
            double maxx = envelope.maxx, maxy = envelope.maxy;

            display.World2Image(ref minx, ref miny);
            display.World2Image(ref maxx, ref maxy);

            gp.StartFigure();
            gp.AddLine((float)minx, (float)miny, (float)maxx, (float)miny);
            gp.AddLine((float)maxx, (float)miny, (float)maxx, (float)maxy);
            gp.AddLine((float)maxx, (float)maxy, (float)minx, (float)maxy);
            gp.CloseFigure();

            return(gp);
        }