protected IntPtr ComputeCornerRadiusRectRegion(Int32Rect rect, CornerRadius cornerRadius)
        {
            if (cornerRadius.TopLeft == cornerRadius.TopRight && cornerRadius.TopLeft == cornerRadius.BottomLeft &&
                cornerRadius.BottomLeft == cornerRadius.BottomRight)
            {
                return(ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopLeft));
            }
            var num1  = IntPtr.Zero;
            var num2  = IntPtr.Zero;
            var num3  = IntPtr.Zero;
            var num4  = IntPtr.Zero;
            var num5  = IntPtr.Zero;
            var num6  = IntPtr.Zero;
            var num7  = IntPtr.Zero;
            var num8  = IntPtr.Zero;
            var num9  = IntPtr.Zero;
            var num10 = IntPtr.Zero;

            try
            {
                num1 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopLeft);
                num2 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopRight);
                num3 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height,
                                              (int)cornerRadius.BottomLeft);
                num4 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height,
                                              (int)cornerRadius.BottomRight);
                var point = new Core.Platform.Point
                {
                    X = rect.X + rect.Width / 2,
                    Y = rect.Y + rect.Height / 2
                };
                num5  = NativeMethods.CreateRectRgn(rect.X, rect.Y, point.X + 1, point.Y + 1);
                num6  = NativeMethods.CreateRectRgn(point.X - 1, rect.Y, rect.X + rect.Width, point.Y + 1);
                num7  = NativeMethods.CreateRectRgn(rect.X, point.Y - 1, point.X + 1, rect.Y + rect.Height);
                num8  = NativeMethods.CreateRectRgn(point.X - 1, point.Y - 1, rect.X + rect.Width, rect.Y + rect.Height);
                num9  = NativeMethods.CreateRectRgn(0, 0, 1, 1);
                num10 = NativeMethods.CreateRectRgn(0, 0, 1, 1);
                NativeMethods.CombineRgn(num10, num1, num5, NativeMethods.CombineMode.RgnAnd);
                NativeMethods.CombineRgn(num9, num2, num6, NativeMethods.CombineMode.RgnAnd);
                NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr);
                NativeMethods.CombineRgn(num9, num3, num7, NativeMethods.CombineMode.RgnAnd);
                NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr);
                NativeMethods.CombineRgn(num9, num4, num8, NativeMethods.CombineMode.RgnAnd);
                NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr);
            }
            finally
            {
                if (num1 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num1);
                }
                if (num2 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num2);
                }
                if (num3 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num3);
                }
                if (num4 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num4);
                }
                if (num5 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num5);
                }
                if (num6 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num6);
                }
                if (num7 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num7);
                }
                if (num8 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num8);
                }
                if (num9 != IntPtr.Zero)
                {
                    NativeMethods.DeleteObject(num9);
                }
            }
            return(num10);
        }