コード例 #1
0
        public DrawableMulti ToMultiPolygon(bool disposePath = true)
        {
            DrawableMulti multi = new DrawableMulti();

            if (Path == null)
            {
                return(null);
            }

            using (GraphicsPathIterator iterator = new GraphicsPathIterator(Path)) {
                GraphicsPath subpath = new GraphicsPath();
                bool         closed;
                while (iterator.NextSubpath(subpath, out closed) != 0)
                {
                    DrawablePolygon shape = new DrawablePolygon {
                        Points    = subpath.PathPoints,
                        Brush     = Brush,
                        Pen       = Pen,
                        PenClosed = closed
                    };
                    multi.Shapes.Add(shape);
                }
                subpath.Dispose();
            }

            if (disposePath)
            {
                Path?.Dispose();
            }

            return(multi);
        }
コード例 #2
0
        public DrawableMulti ToMulti(MultiGen cb, bool disposePath = true)
        {
            DrawableMulti multi = new DrawableMulti();

            if (Path == null)
            {
                return(null);
            }

            using (GraphicsPathIterator iterator = new GraphicsPathIterator(Path)) {
                GraphicsPath subpath = new GraphicsPath();
                bool         closed;
                int          i = 0;
                while (iterator.NextSubpath(subpath, out closed) != 0)
                {
                    Drawable shape = cb(i++, subpath, Brush, Pen, closed);
                    if (shape != null)
                    {
                        multi.Shapes.Add(shape);
                    }
                }
                subpath.Dispose();
            }

            if (disposePath)
            {
                Path?.Dispose();
            }

            return(multi);
        }
コード例 #3
0
        public override object Clone()
        {
            DrawableMulti clone = new DrawableMulti();

            if (Shapes == null)
            {
                return(clone);
            }
            clone.Shapes = new List <Drawable>(Shapes.Count);
            for (int i = 0; i < Shapes.Count; i++)
            {
                clone.Shapes.Add(Shapes[i]?.Clone() as Drawable);
            }
            return(clone);
        }