Inheritance: GDIObject
Example #1
0
 public RegionCombineType Combine(GDIRegion aRegion, GDIRegion bRegion, RegionCombineStyles combineStyle)
 {
     int retValue = GDI32.CombineRgn(DangerousGetHandle(), aRegion.DangerousGetHandle(), bRegion.DangerousGetHandle(), (int)combineStyle);
     
     RegionCombineType result = (RegionCombineType)retValue;
     return result;
 }
 public virtual void FillRegion(GDIRegion region, GDIBrush aBrush)
 {
     bool success = GDI32.FillRgn(this, region, aBrush.DangerousGetHandle());
 }
 public virtual void DrawRegion(GDIRegion region)
 {
     bool success = GDI32.PaintRgn(this, region);
 }
Example #4
0
 public virtual void SetClip(GDIRegion clipRegion)
 {
     GDI32.SelectClipRgn(DeviceContext, clipRegion.DangerousGetHandle());
 }
Example #5
0
 public virtual void InvertRegion(GDIRegion region)
 {
     DeviceContext.InvertRegion(region);
 }
Example #6
0
 public virtual void FrameRegion(GDIRegion region, GDIBrush aBrush, Size strokeSize)
 {
     DeviceContext.FrameRegion(region, aBrush, strokeSize);
 }
Example #7
0
 public virtual void FillRegion(GDIRegion region, GDIBrush aBrush)
 {
     DeviceContext.FillRegion(region, aBrush);
 }
Example #8
0
        public static GDIRegion CreateFromPolygon(Point[] points, PolygonFillMode aMode, Guid uniqueID)
        {
            TOAPI.Types.POINT[] pts = new POINT[points.Length];
            for (int i = 0; i < pts.Length; i++)
            {
                pts[i].X = points[i].X;
                pts[i].Y = points[i].Y;
            }

            IntPtr regionHandle = GDI32.CreatePolygonRgn(pts, pts.Length, (int)aMode);

            GDIRegion newRegion = new GDIRegion(regionHandle, true, uniqueID);

            return newRegion;
        }
Example #9
0
        public bool Equals(GDIRegion aRegion)
        {
            bool isEqual = GDI32.EqualRgn(DangerousGetHandle(), aRegion.DangerousGetHandle());

            return isEqual;
        }
Example #10
0
        public GDIRegion Intersect(GDIRegion aRegion)
        {
            RegionCombineType retValue = (RegionCombineType)GDI32.CombineRgn(DangerousGetHandle(), DangerousGetHandle(), aRegion.DangerousGetHandle(), (int)RegionCombineStyles.AND);

            return this;
        }
Example #11
0
        public GDIRegion Subtract(GDIRegion aRegion)
        {
            RegionCombineType retValue = (RegionCombineType)GDI32.CombineRgn(DangerousGetHandle(), DangerousGetHandle(), aRegion.DangerousGetHandle(), (int)RegionCombineStyles.Diff);

            return this;
        }
Example #12
0
        public static GDIRegion CreateFromRectangles(Rectangle[] rects, Guid uniqueID)
        {
            // 1.  Create a header
            RGNDATAHEADER header = new RGNDATAHEADER();
            header.dwSize = Marshal.SizeOf(header);
            header.iType = 1;
            header.nCount = (uint)rects.Length;
            header.nRgnSize = (uint)Marshal.SizeOf(typeof(RECT)) * header.nCount;
            //header.rcBound = 

            // 2. Allocate memory to hold the header plus the data for the rectangles
            int dataLengthNeeded = (int)(header.dwSize + header.nRgnSize);
            IntPtr memoryPtr = Marshal.AllocCoTaskMem((int)dataLengthNeeded);
            UnmanagedPointer structPtr = new UnmanagedPointer(memoryPtr);

            // 4. Copy the Header into the memory buffer
            Marshal.StructureToPtr(header, structPtr, false);

            // 5. Increment the memory buffer pointer to write the rectangles
            structPtr = structPtr + header.dwSize;

            // The nRgnSize / nCount will tell us how many bytes per rectangle structure
            // and therefore how much to advance the pointer as we turn the buffer
            // into a set of rectangles using PtrToStructure.
            int structIncrement = (int)(header.nRgnSize / header.nCount);

            // 6. Write the rectangles
            for (int i = 0; i < header.nCount; i++)
            {
                RECT aRect = new RECT(rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
                Marshal.StructureToPtr(aRect, structPtr, false);

                // Increment the structure pointer to the next position
                structPtr = structPtr + structIncrement;
            }

            // 7. Create the region
            IntPtr regionHandle = GDI32.ExtCreateRegion(IntPtr.Zero, (uint)rects.Length, memoryPtr);
            GDIRegion newRegion = new GDIRegion(regionHandle, true, uniqueID);

            // 8. Free the memory
            Marshal.FreeCoTaskMem(memoryPtr);
        
            return newRegion;
        }
Example #13
0
        public static GDIRegion CreateFromRectangle(int left, int top, int right, int bottom, Guid uniqueID)
        {
            RECT newRect = RECT.FromLTRB(left, top, right, bottom);
            IntPtr regionHandle = GDI32.CreateRectRgnIndirect(ref newRect);

            GDIRegion newRegion = new GDIRegion(regionHandle, true, uniqueID);

            return newRegion;
        }
 public virtual void FrameRegion(GDIRegion region, GDIBrush aBrush, Size strokeSize)
 {
     bool success = GDI32.FrameRgn(this, region, aBrush.DangerousGetHandle(), strokeSize.Width, strokeSize.Height);
 }
Example #15
0
        //public virtual void PlgBlt(GDIContext srcDC, Rectangle srcRect, 
        //    System.Drawing.Point[] lpPOINT,
        //    IntPtr hbmMask, int xMask, int yMask)
        //{
        //    bool result = DeviceContext.PlgBlt(srcDC, srcRect, lpPOINT, hbmMask, xMask, yMask);
        //}
        #endregion

        #region Drawing Regions
        public virtual void DrawRegion(GDIRegion region)
        {
            DeviceContext.DrawRegion(region);
        }
 public virtual void InvertRegion(GDIRegion region)
 {
     bool success = GDI32.InvertRgn(this, region);
 }
Example #17
0
        public static GDIRegion CreateFromPath(GPath aPath, Guid uniqueID)
        {
            // 1. Create a simple device context
            GDIContext deviceContext = GDIContext.CreateForDefaultDisplay();

            // 2. Replay the path into the context
            deviceContext.ReplayPath(aPath);

            // 3. Create a region from the replayed path
            IntPtr regionHandle = GDI32.PathToRegion(deviceContext);

            GDIRegion newRegion = new GDIRegion(regionHandle, true, uniqueID);

            return newRegion;
        }