取得GraphicsPath的源码

private string OutputGraphicsPath(GraphicsPath gp)
        {
            StringBuilder sb = new StringBuilder();
            GraphicsPathIterator gpi = new GraphicsPathIterator(gp);
            int start, end, count = 0;
            count = gpi.NextMarker(out start, out end);
            PointF[] points = new PointF[count];
            byte[] types = new byte[count];
            gpi.CopyData(ref points, ref types, start, end);
            sb.Append(string.Format("GraphicsPath path{0} = new GraphicsPath(\r\n", 0));
            sb.Append("new PointF[] {\r\n");
            for (int i = 0; i < points.Length; i++)
            {
                sb.Append(String.Format("new PointF({0}F,{1}F)", points[i].X, points[i].Y));
                if (i != points.Length - 1) sb.Append(",");
                if ((i + 1) % 5 == 0) sb.Append("\r\n");
            }
            sb.Append(@"},
            new System.Byte[] {
            ");
            for (int i = 0; i < types.Length; i++)
            {
                sb.Append(types[i].ToString());
                if (i != types.Length - 1) sb.Append(",");
                if ((i + 1) % 20 == 0) sb.Append("\r\n");
            }
            sb.Append(" });\r\n");
            //resultGP.AddPath(gp, false);
            //g.FillPath(Brushes.Red, gp);
            //sb.Append(gp.ToString());
            return sb.ToString();
        }

你可能感兴趣的:(取得GraphicsPath的源码)