예제 #1
0
파일: Utility.cs 프로젝트: w8w8w8/Photo.Net
        public static GeometryRegion RectanglesToRegion(RectangleF[] rectsF1, RectangleF[] rectsF2,
                                                        params RectangleF[][] rectsFA)
        {
            using (var path = new GeometryGraphicsPath())
            {
                path.FillMode = FillMode.Winding;

                if (rectsF1 != null && rectsF1.Length > 0)
                {
                    path.AddRectangles(rectsF1);
                }

                if (rectsF2 != null && rectsF2.Length > 0)
                {
                    path.AddRectangles(rectsF2);
                }

                foreach (RectangleF[] rectsF in rectsFA)
                {
                    if (rectsF != null && rectsF.Length > 0)
                    {
                        path.AddRectangles(rectsF);
                    }
                }

                return(new GeometryRegion(path));
            }
        }
예제 #2
0
파일: Utility.cs 프로젝트: w8w8w8/Photo.Net
        public static GeometryRegion RectanglesToRegion(Rectangle[] rects, int startIndex, int length)
        {
            GeometryRegion region;

            if (length == 0)
            {
                region = GeometryRegion.CreateEmpty();
            }
            else
            {
                using (var path = new GeometryGraphicsPath())
                {
                    path.FillMode = FillMode.Winding;
                    if (startIndex == 0 && length == rects.Length)
                    {
                        path.AddRectangles(rects);
                    }
                    else
                    {
                        for (int i = startIndex; i < startIndex + length; ++i)
                        {
                            path.AddRectangle(rects[i]);
                        }
                    }

                    region = new GeometryRegion(path);
                    path.Dispose();
                }
            }

            return(region);
        }