public Size GetPartPreferredSize(Graphics g, Rectangle bounds, ThemeSizeType type)
        {
            if (this.currentElement == null || this.currentHTheme == IntPtr.Zero)
            {
                return(Size.Empty);
            }
            RadHdcWrapper radHdcWrapper = new RadHdcWrapper(g, false);
            IntPtr        hdc           = radHdcWrapper.GetHdc();

            NativeMethods.SIZE psz = new NativeMethods.SIZE();
            UXTheme.GetThemePartSize(this.currentHTheme, hdc, this.currentElement.Part, this.currentElement.State, IntPtr.Zero, type, psz);
            radHdcWrapper.Dispose();
            return(new Size(psz.cx, psz.cy));
        }
        public void PaintCurrentElement(Graphics g, Rectangle bounds)
        {
            if (this.currentHTheme == IntPtr.Zero)
            {
                return;
            }
            RadHdcWrapper radHdcWrapper = new RadHdcWrapper(g, true);
            IntPtr        hdc           = radHdcWrapper.GetHdc();

            NativeMethods.RECT rect = new NativeMethods.RECT()
            {
                left = bounds.Left,
                top  = bounds.Top
            };
            rect.bottom = rect.top + bounds.Height;
            rect.right  = rect.left + bounds.Width;
            UXTheme.DrawThemeBackground(this.currentHTheme, hdc, this.currentElement.Part, this.currentElement.State, ref rect, IntPtr.Zero);
            radHdcWrapper.Dispose();
        }
Beispiel #3
0
 public IntPtr GetHdc()
 {
     this.hdc     = this.graphics.GetHdc();
     this.dcState = RadHdcWrapper.SaveDC(this.hdc);
     if (this.useTransform)
     {
         this.graphicsMode = RadHdcWrapper.SetGraphicsMode(this.hdc, 2);
         RadHdcWrapper.GetWorldTransform(this.hdc, ref this.oldTransform);
         RadHdcWrapper.ModifyWorldTransform(this.hdc, ref this.transform, 2);
     }
     if (this.clipRegion != IntPtr.Zero)
     {
         this.origRegion = RadHdcWrapper.CreateRectRgn(0, 0, 0, 0);
         if (RadHdcWrapper.GetClipRgn(this.hdc, this.origRegion) == 1)
         {
             RadHdcWrapper.CombineRgn(this.clipRegion, this.origRegion, this.clipRegion, 1);
         }
         RadHdcWrapper.SelectClipRgn(this.hdc, this.clipRegion);
     }
     return(this.hdc);
 }
Beispiel #4
0
 public void ReleaseHdc()
 {
     if (this.hdc == IntPtr.Zero)
     {
         return;
     }
     RadHdcWrapper.RestoreDC(this.hdc, this.dcState);
     if (this.useTransform)
     {
         RadHdcWrapper.SetGraphicsMode(this.hdc, this.graphicsMode);
         RadHdcWrapper.SetWorldTransform(this.hdc, ref this.oldTransform);
     }
     if (this.clipRegion != IntPtr.Zero)
     {
         NativeMethods.DeleteObject(new HandleRef((object)null, this.clipRegion));
         NativeMethods.DeleteObject(new HandleRef((object)null, this.origRegion));
         this.clipRegion = IntPtr.Zero;
         this.origRegion = IntPtr.Zero;
     }
     this.graphics.ReleaseHdc(this.hdc);
     this.hdc = IntPtr.Zero;
 }