public static GeometryRegion CreateEmpty() { GeometryRegion region = new GeometryRegion(); region.MakeEmpty(); return(region); }
public void Exclude(GeometryRegion region2) { lock (SyncRoot) { _gdiRegion.Exclude(region2._gdiRegion); } }
public GeometryGraphicsPath(SerializationInfo info, StreamingContext context) { int ptCount = info.GetInt32("ptCount"); PointF[] pts; byte[] types; if (ptCount == 0) { pts = new PointF[0]; types = new byte[0]; } else { pts = (PointF[])info.GetValue("pts", typeof(PointF[])); types = (byte[])info.GetValue("types", typeof(byte[])); } var fillMode = (FillMode)info.GetValue("fillMode", typeof(FillMode)); Changed(); if (ptCount == 0) { gdiPath = new GraphicsPath(); } else { gdiPath = new GraphicsPath(pts, types, fillMode); } this.tooComplex = false; this.regionCache = null; }
public static GeometryRegion WrapRegion(Region region) { GeometryRegion GeometryRegion = new GeometryRegion(false); GeometryRegion._gdiRegion = region; return(GeometryRegion); }
public void Complement(GeometryRegion region2) { lock (SyncRoot) { Changed(); _gdiRegion.Complement(region2._gdiRegion); } }
public void Intersect(GeometryRegion region2) { lock (SyncRoot) { Changed(); _gdiRegion.Intersect(region2._gdiRegion); } }
public void Union(GeometryRegion region2) { lock (SyncRoot) { Changed(); _gdiRegion.Union(region2._gdiRegion); } }
public void Xor(GeometryRegion region2) { lock (SyncRoot) { Changed(); _gdiRegion.Xor(region2._gdiRegion); } }
internal GeometryRegion GetRegionCache() { if (regionCache == null) { regionCache = new GeometryRegion(this.gdiPath); } return(regionCache); }
private void Changed() { if (regionCache != null) { lock (regionCache.SyncRoot) { regionCache.Dispose(); regionCache = null; } } }
private GeometryRegion(GeometryRegion GeometryRegion) { lock (GeometryRegion.SyncRoot) { this._gdiRegion = GeometryRegion._gdiRegion.Clone(); this._changed = GeometryRegion._changed; this._cachedArea = GeometryRegion._cachedArea; this._cachedRectsF = GeometryRegion._cachedRectsF; this._cachedRects = GeometryRegion._cachedRects; } }
public void Union(RectangleF[] rectsF) { lock (SyncRoot) { Changed(); using (GeometryRegion tempRegion = Utility.RectanglesToRegion(rectsF)) { this.Union(tempRegion); } } }
public GeometryGraphicsPath CreatePixelatedPath() { using (GeometryGraphicsPath path = CreatePath()) //GeometryGraphicsPath path = GetPathReadOnly(); { using (GeometryRegion region = new GeometryRegion(path)) { GeometryGraphicsPath pixellatedPath = GeometryGraphicsPath.FromRegion(region); return(pixellatedPath); } } }
public GeometryRegion CreateRegion() { lock (this.syncRoot) { if (IsEmpty) { return(new GeometryRegion(this.clipRectangle)); } else { GeometryRegion region = CreateRegionRaw(); region.Intersect(this.clipRectangle); return(region); } } }
private void Dispose(bool disposing) { if (disposing) { lock (this) // avoid race condition with GetObjectData() { if (gdiPath != null) { gdiPath.Dispose(); gdiPath = null; } if (regionCache != null) { regionCache.Dispose(); regionCache = null; } } } }
public static GeometryGraphicsPath FromRegion(GeometryRegion region) { Rectangle[] scans = region.GetRegionScansReadOnlyInt(); if (scans.Length == 1) { var path = new GeometryGraphicsPath(); path.AddRectangle(scans[0]); path.CloseFigure(); return(path); } else { Rectangle bounds = region.GetBoundsInt(); var stencil = new BitVector2D(bounds.Width, bounds.Height); for (int i = 0; i < scans.Length; ++i) { Rectangle rect = scans[i]; rect.X -= bounds.X; rect.Y -= bounds.Y; stencil.UnsafeSet(rect, true); } GeometryGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height)); using (Matrix matrix = new Matrix()) { matrix.Reset(); matrix.Translate(bounds.X, bounds.Y); path.Transform(matrix); } return(path); } }
public static GeometryGraphicsPath FromRegions(GeometryRegion lhs, CombineMode combineMode, GeometryRegion rhs) { Rectangle lhsBounds = lhs.GetBoundsInt(); Rectangle rhsBounds = rhs.GetBoundsInt(); int left = Math.Min(lhsBounds.Left, rhsBounds.Left); int top = Math.Min(lhsBounds.Top, rhsBounds.Top); int right = Math.Max(lhsBounds.Right, rhsBounds.Right); int bottom = Math.Max(lhsBounds.Bottom, rhsBounds.Bottom); Rectangle bounds = Rectangle.FromLTRB(left, top, right, bottom); BitVector2D stencil = new BitVector2D(bounds.Width, bounds.Height); Rectangle[] lhsScans = lhs.GetRegionScansReadOnlyInt(); Rectangle[] rhsScans = rhs.GetRegionScansReadOnlyInt(); switch (combineMode) { case CombineMode.Complement: case CombineMode.Intersect: case CombineMode.Replace: throw new ArgumentException("combineMode can't be Complement, Intersect, or Replace"); } for (int i = 0; i < lhsScans.Length; ++i) { Rectangle rect = lhsScans[i]; rect.X -= bounds.X; rect.Y -= bounds.Y; stencil.UnsafeSet(rect, true); } for (int i = 0; i < rhsScans.Length; ++i) { Rectangle rect = rhsScans[i]; rect.X -= bounds.X; rect.Y -= bounds.Y; switch (combineMode) { case CombineMode.Xor: stencil.UnsafeInvert(rect); break; case CombineMode.Union: stencil.UnsafeSet(rect, true); break; case CombineMode.Exclude: stencil.UnsafeSet(rect, false); break; } } GeometryGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height)); using (var matrix = new Matrix()) { matrix.Reset(); matrix.Translate(bounds.X, bounds.Y); path.Transform(matrix); } return(path); }