/// <include file='doc\VisualStyleRenderer.uex' path='docs/doc[@for="VisualStyleRenderer.GetMargins"]/*' />
        /// <devdoc>
        ///    <para>
        ///       [See win32 equivalent.]
        ///    </para>
        /// </devdoc>
        public Padding GetMargins(IDeviceContext dc, MarginProperty prop) {
            if( dc == null ){
                throw new ArgumentNullException("dc");
            }
            
            //valid values are 0xe11 to 0xe13
            if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)MarginProperty.SizingMargins, (int)MarginProperty.CaptionMargins))
            {
                throw new InvalidEnumArgumentException("prop", (int)prop, typeof(MarginProperty));
            }

            NativeMethods.MARGINS margins = new NativeMethods.MARGINS();

            using( WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper( dc, AllGraphicsProperties ) ) {
                HandleRef hdc = new HandleRef( wgr, wgr.WindowsGraphics.DeviceContext.Hdc );
                lastHResult = SafeNativeMethods.GetThemeMargins( new HandleRef( this, Handle ), hdc, part, state, (int) prop, ref margins );
            }

            return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
        }
Exemple #2
0
		/// <summary>
		/// Paints the glass effect on the screen.
		/// </summary>
		/// <param name="g"></param>
		protected virtual void PaintGlass(Graphics g)
		{
			if (!GlassUtility.IsGlassEnabled)
				return;

			if (!this.DesignMode)
			{
				// Paint the glass effect.
				NativeMethods.MARGINS m = new NativeMethods.MARGINS(_margin);
				NativeMethods.DwmExtendFrameIntoClientArea(this.Handle, ref m);
			}

			// Paint the glass effect.
			using (Brush b = new SolidBrush(Color.Black))
			{
				if (_fullWindow)
				{
					g.FillRectangle(b, this.ClientRectangle);
				}
				else
				{
					_rects[0] = new Rectangle(0, 0, this.Width, _margin.Top);
					_rects[1] = new Rectangle(this.ClientRectangle.Width - _margin.Right, 0, _margin.Right, this.Height);
					_rects[2] = new Rectangle(0, this.ClientRectangle.Height - _margin.Bottom, this.Width, _margin.Bottom);
					_rects[3] = new Rectangle(0, 0, _margin.Left, this.Height);

					g.FillRectangles(b, _rects);
				}
			}
		}