Exemplo n.º 1
0
        ///<devdoc>
        ///     Creates a new clipping region from the intersection of the current clipping region and
        ///     the specified rectangle.
        ///</devdoc>


        public void IntersectClip(WindowsRegion wr)
        {
            //if the incoming windowsregion is infinite, there is no need to do any intersecting.
            if (wr.HRegion == IntPtr.Zero)
            {
                return;
            }

            WindowsRegion clip = new WindowsRegion(0, 0, 0, 0);

            try {
                int result = IntUnsafeNativeMethods.GetClipRgn(new HandleRef(this, this.Hdc), new HandleRef(clip, clip.HRegion));

                // If the function succeeds and there is a clipping region for the given device context, the return value is 1.
                if (result == 1)
                {
                    Debug.Assert(clip.HRegion != IntPtr.Zero);
                    wr.CombineRegion(clip, wr, RegionCombineMode.AND);  //1 = AND (or Intersect)
                }

                SetClip(wr);
            }
            finally {
                clip.Dispose();
            }
        }
Exemplo n.º 2
0
        public void IntersectClip(WindowsRegion wr)
        {
            //if the incoming windowsregion is infinite, there is no need to do any intersecting.
            if (wr.HRegion == IntPtr.Zero) {
                return;
            }

            WindowsRegion clip = new WindowsRegion(0,0,0,0);
            try {
                 int result = IntUnsafeNativeMethods.GetClipRgn(new HandleRef( this, this.Hdc), new HandleRef(clip, clip.HRegion));

                 // If the function succeeds and there is a clipping region for the given device context, the return value is 1. 
                 if (result == 1) {
                     Debug.Assert(clip.HRegion != IntPtr.Zero);
                     wr.CombineRegion(clip, wr, RegionCombineMode.AND); //1 = AND (or Intersect)
                 }
 
                 SetClip(wr);
            }
            finally {
                 clip.Dispose();
            }
        }