/// <summary> /// Creates a clipping region copy for the given device context. /// </summary> /// <param name="hdc">Handle to a device context to copy the clipping region from.</param> public RegionScope(IntPtr hdc) { HRGN region = default; GetClipRgn(hdc, region); Region = region; }
public RegionHandle(HRGN handle, bool ownsHandle = true) { Debug.Assert(handle.IsInvalid || Imports.GetObjectType(handle) == ObjectType.Region); Handle = handle; _ownsHandle = ownsHandle; }
RegionPlus(HRGN hRgn) { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegionHrgn(hRgn, out region); SetNativeRegion(region); }
public static HRGN CreateRectRgnChecked(int x1, int y1, int x2, int y2) { HRGN region = CreateRectRgn(x1, y1, x2, y2); // todo: is it worth checking? if (region == IntPtr.Zero) { throw new InvalidOperationException($"{nameof(CreateRectRgn)} failed. X1: {x1}, Y1: {y1}, X2: {x2}, Y2: {y2}."); } return(region); }
RegionPlus FromHRGN(HRGN hRgn) { GpRegion region = new GpRegion(); if (NativeMethods.GdipCreateRegionHrgn(hRgn, out region) == GpStatus.Ok) { RegionPlus newRegion = new RegionPlus(region); if (newRegion == null) { NativeMethods.GdipDeleteRegion(region); } return newRegion; } else return null; }
/// <summary> /// Creates a clipping region copy via <see cref="GetClipRgn(HDC, HRGN)"/> for the given device context. /// </summary> /// <param name="hdc">Handle to a device context to copy the clipping region from.</param> public RegionScope(HDC hdc) { HRGN region = CreateRectRgn(0, 0, 0, 0); int result = GetClipRgn(hdc, region); Debug.Assert(result != -1, "GetClipRgn failed"); if (result == 1) { Region = region; } else { // No region, delete our temporary region DeleteObject(region); Region = default; } }
/// <summary> /// Creates a native region from a GDI+ <see cref="Region"/>. /// </summary> public RegionScope(Region region, Graphics graphics) { if (region.IsInfinite(graphics)) { // An infinite region would cover the entire device region which is the same as // not having a clipping region. Observe that this is not the same as having an // empty region, which when clipping to it has the effect of excluding the entire // device region. // // To remove the clip region from a dc the SelectClipRgn() function needs to be // called with a null region ptr - that's why we use the empty constructor here. // GDI+ will return IntPtr.Zero for Region.GetHrgn(Graphics) when the region is // Infinite. Region = default; return; } Region = new HRGN(region.GetHrgn(graphics)); }
public static extern int GetClipRgn(HDC hdc, HRGN hrgn);
public static extern RegionType SelectClipRgn(HDC hdc, HRGN hrgn);
public static extern int CombineRgn(HGDIOBJ hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int nCombineMode);
public HRESULT InvalidateRgn(HRGN hRGN, BOOL fErase) { return(((delegate * unmanaged <IOleInPlaceSiteWindowless *, HRGN, BOOL, int>)(lpVtbl[26]))((IOleInPlaceSiteWindowless *)Unsafe.AsPointer(ref this), hRGN, fErase)); }
public static extern GpStatus GdipGetRegionHRgn(GpRegion region, GpGraphics graphics, out HRGN hRgn);
public static partial int GetClipRgn(HDC hdc, HRGN hrgn);
public static extern int GetRandomRgn(HDC hdc, [In, Out] HRGN hrgn, int i = 4 /* SYSRGN */);
public static extern bool GetMetaRgn(HDC hdc, [In, Out] HRGN hrgn);
public static extern int GetClipRgn(HDC hdc, [In, Out] HRGN hrgn);
public static extern RegionFlags ExtSelectClipRgn(HDC hdc, HRGN hrgn, RegionOp mode);
public static extern BOOL FillRgn(HDC hdc, HRGN hrgn, HBRUSH hbr);
public static extern BOOL PaintRgn(HDC hdc, HRGN hrgn);
public static extern BOOL SetRectRgn(HRGN hrgn, int left, int top, int right, int bottom);
public static extern HRESULT HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, [NativeTypeName("DWORD")] uint dwOptions, [NativeTypeName("LPCRECT")] RECT *pRect, HRGN hrgn, POINT ptTest, [NativeTypeName("WORD *")] ushort *pwHitTestCode);
public RegionScope(Region region, IntPtr hwnd) { using var graphics = Graphics.FromHwndInternal(hwnd); Region = new HRGN(region.GetHrgn(graphics)); }
public static extern RGN_TYPE CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, RGN_COMB iMode);
public static extern GpStatus GdipCreateRegionHrgn(HRGN hRgn, out GpRegion region);
//GpStatus SetClip( GraphicsPlus g, // CombineMode combineMode) //{ // return SetStatus(NativeMethods.GdipSetClipGraphics(nativeGraphics, // g.nativeGraphics, // combineMode)); //} //GpStatus SetClip( GpRectF rect, // CombineMode combineMode) //{ // return SetStatus(NativeMethods.GdipSetClipRect(nativeGraphics, // rect.X, rect.Y, // rect.Width, rect.Height, // combineMode)); //} //GpStatus SetClip( GpRect rect, // CombineMode combineMode) //{ // return SetStatus(NativeMethods.GdipSetClipRectI(nativeGraphics, // rect.X, rect.Y, // rect.Width, rect.Height, // combineMode)); //} //GpStatus SetClip( GraphicsPath path, // CombineMode combineMode ) //{ // return SetStatus(NativeMethods.GdipSetClipPath(nativeGraphics, // path.nativePath, // combineMode)); //} //GpStatus SetClip( RegionPlus region, // CombineMode combineMode) //{ // return SetStatus(NativeMethods.GdipSetClipRegion(nativeGraphics, // region.nativeRegion, // combineMode)); //} // This is different than the other SetClip methods because it assumes // that the HRGN is already in device units, so it doesn't transform // the coordinates in the HRGN. GpStatus SetClip(HRGN hRgn, CombineMode combineMode) { return SetStatus(NativeMethods.GdipSetClipHrgn(nativeGraphics, hRgn, combineMode)); }
public static extern int GetClipRgn(IntPtr hdc, HRGN hrgn);
public HRESULT InvalidateRegion(HRGN rgnInvalid) { return(((delegate * unmanaged <IHTMLPaintSite *, HRGN, int>)(lpVtbl[5]))((IHTMLPaintSite *)Unsafe.AsPointer(ref this), rgnInvalid)); }
public static extern RegionType GetRgnBox(HRGN hRegion, ref RECT clipRect);
public static extern GpStatus GdipSetClipHrgn(GpGraphics graphics, HRGN hRgn, CombineMode combineMode);
public static extern bool SetWindowRgn(HWND hwnd, HRGN hrgn, bool bRedraw);
/// <summary> /// Creates a region with the given rectangle via <see cref="CreateRectRgn(int, int, int, int)"/>. /// </summary> public RegionScope(int x1, int y1, int x2, int y2) { Region = CreateRectRgn(x1, y1, x2, y2); }
public static extern RegionType CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, CombineMode iMode);
public static extern int SelectClipRgn(HDC hdc, HRGN hrgn);
public static partial RegionType SelectClipRgn(HDC hdc, HRGN hrgn);
/// <summary> /// Clears the handle. Use this to hand over ownership to another entity. /// </summary> public void RelinquishOwnership() => Region = default;
/// <summary> /// Creates a region with the given rectangle via <see cref="CreateRectRgn(int, int, int, int)"/>. /// </summary> public RegionScope(Rectangle rectangle) { Region = CreateRectRgn(rectangle.X, rectangle.Y, rectangle.Right, rectangle.Bottom); }
public static partial RegionType CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, RGN iMode);