Exemplo n.º 1
0
            /// <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;
            }
Exemplo n.º 2
0
        public RegionHandle(HRGN handle, bool ownsHandle = true)
        {
            Debug.Assert(handle.IsInvalid || Imports.GetObjectType(handle) == ObjectType.Region);

            Handle      = handle;
            _ownsHandle = ownsHandle;
        }
Exemplo n.º 3
0
        RegionPlus(HRGN hRgn)
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegionHrgn(hRgn, out region);

            SetNativeRegion(region);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
            /// <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;
                }
            }
Exemplo n.º 7
0
            /// <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));
            }
Exemplo n.º 8
0
 public static extern int GetClipRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 9
0
 public static extern RegionType SelectClipRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 10
0
 public static extern int CombineRgn(HGDIOBJ hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int nCombineMode);
Exemplo n.º 11
0
 public HRESULT InvalidateRgn(HRGN hRGN, BOOL fErase)
 {
     return(((delegate * unmanaged <IOleInPlaceSiteWindowless *, HRGN, BOOL, int>)(lpVtbl[26]))((IOleInPlaceSiteWindowless *)Unsafe.AsPointer(ref this), hRGN, fErase));
 }
Exemplo n.º 12
0
 public static extern GpStatus GdipGetRegionHRgn(GpRegion region, GpGraphics graphics, out HRGN hRgn);
Exemplo n.º 13
0
 public static partial int GetClipRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 14
0
 public static extern int GetRandomRgn(HDC hdc, [In, Out] HRGN hrgn, int i = 4 /* SYSRGN */);
Exemplo n.º 15
0
 public static extern bool GetMetaRgn(HDC hdc, [In, Out] HRGN hrgn);
Exemplo n.º 16
0
 public static extern int GetClipRgn(HDC hdc, [In, Out] HRGN hrgn);
Exemplo n.º 17
0
 public static extern RegionFlags ExtSelectClipRgn(HDC hdc, HRGN hrgn, RegionOp mode);
Exemplo n.º 18
0
 public static extern BOOL FillRgn(HDC hdc, HRGN hrgn, HBRUSH hbr);
Exemplo n.º 19
0
 public static extern BOOL PaintRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 20
0
 public static extern BOOL SetRectRgn(HRGN hrgn, int left, int top, int right, int bottom);
Exemplo n.º 21
0
 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);
Exemplo n.º 22
0
 public RegionScope(Region region, IntPtr hwnd)
 {
     using var graphics = Graphics.FromHwndInternal(hwnd);
     Region             = new HRGN(region.GetHrgn(graphics));
 }
Exemplo n.º 23
0
 public static extern RGN_TYPE CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, RGN_COMB iMode);
Exemplo n.º 24
0
 public static extern GpStatus GdipCreateRegionHrgn(HRGN hRgn, out GpRegion region);
Exemplo n.º 25
0
 //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));
 }
Exemplo n.º 26
0
 public static extern int GetClipRgn(IntPtr hdc, HRGN hrgn);
Exemplo n.º 27
0
 public HRESULT InvalidateRegion(HRGN rgnInvalid)
 {
     return(((delegate * unmanaged <IHTMLPaintSite *, HRGN, int>)(lpVtbl[5]))((IHTMLPaintSite *)Unsafe.AsPointer(ref this), rgnInvalid));
 }
Exemplo n.º 28
0
 public static extern RegionType GetRgnBox(HRGN hRegion, ref RECT clipRect);
Exemplo n.º 29
0
 public static extern GpStatus GdipSetClipHrgn(GpGraphics graphics, HRGN hRgn, CombineMode combineMode);
Exemplo n.º 30
0
 public static extern bool SetWindowRgn(HWND hwnd, HRGN hrgn, bool bRedraw);
Exemplo n.º 31
0
 /// <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);
 }
Exemplo n.º 32
0
 public static extern RegionType CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, CombineMode iMode);
Exemplo n.º 33
0
 public static extern int SelectClipRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 34
0
 public static partial RegionType SelectClipRgn(HDC hdc, HRGN hrgn);
Exemplo n.º 35
0
 /// <summary>
 ///  Clears the handle. Use this to hand over ownership to another entity.
 /// </summary>
 public void RelinquishOwnership() => Region = default;
Exemplo n.º 36
0
 /// <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);
 }
Exemplo n.º 37
0
 public static partial RegionType CombineRgn(HRGN hrgnDst, HRGN hrgnSrc1, HRGN hrgnSrc2, RGN iMode);