public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
 {
     if (dc == null)
     {
         throw new ArgumentNullException("dc");
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_Masked(edges, (int) edges, 0x1f))
     {
         throw new InvalidEnumArgumentException("edges", (int) edges, typeof(Edges));
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_NotSequential(style, (int) style, new int[] { 5, 10, 6, 9 }))
     {
         throw new InvalidEnumArgumentException("style", (int) style, typeof(EdgeStyle));
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_Masked(effects, (int) effects, 0xd800))
     {
         throw new InvalidEnumArgumentException("effects", (int) effects, typeof(EdgeEffects));
     }
     System.Windows.Forms.NativeMethods.COMRECT pContentRect = new System.Windows.Forms.NativeMethods.COMRECT();
     using (WindowsGraphicsWrapper wrapper = new WindowsGraphicsWrapper(dc, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping))
     {
         HandleRef hdc = new HandleRef(wrapper, wrapper.WindowsGraphics.DeviceContext.Hdc);
         this.lastHResult = System.Windows.Forms.SafeNativeMethods.DrawThemeEdge(new HandleRef(this, this.Handle), hdc, this.part, this.state, new System.Windows.Forms.NativeMethods.COMRECT(bounds), (int) style, ((int) (edges | ((Edges) ((int) effects)))) | 0x2000, pContentRect);
     }
     return Rectangle.FromLTRB(pContentRect.left, pContentRect.top, pContentRect.right, pContentRect.bottom);
 }
Exemplo n.º 2
0
		public int UxThemeDrawThemeEdge (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result)
		{
			XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle (bounds);
			XplatUIWin32.RECT retval;

			int hresult = UXTheme.DrawThemeEdge (hTheme, dc.GetHdc (), iPartId, iStateId, ref BoundsRect, (uint)style, (uint)edges + (uint)effects, out retval);
			dc.ReleaseHdc ();
			result = retval.ToRectangle();
			return hresult;
		}
Exemplo n.º 3
0
        public void VisualStyleRenderer_DrawEdge_InvalidEffects_ThrowsInvalidEnumArgumentException(EdgeEffects effects)
        {
            var renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);

            using var bitmap        = new Bitmap(10, 10);
            using Graphics graphics = Graphics.FromImage(bitmap);
            Assert.Throws <InvalidEnumArgumentException>("effects", () => renderer.DrawEdge(graphics, new Rectangle(1, 2, 3, 4), Edges.Bottom, EdgeStyle.Bump, effects));
        }
Exemplo n.º 4
0
        public void VisualStyleRenderer_DrawEdge_Invoke_Success(Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            // Don't verify anything, just make sure the interop call succeeds.
            var renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);

            using var bitmap        = new Bitmap(10, 10);
            using Graphics graphics = Graphics.FromImage(bitmap);
            Rectangle result = renderer.DrawEdge(graphics, bounds, edges, style, effects);

            Assert.Equal(0, renderer.LastHResult);
        }
Exemplo n.º 5
0
        public Rectangle_ DrawEdge(IDeviceContext dc, Rectangle_ bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (dc == null)
            {
                throw new ArgumentNullException("dc");
            }

            Rectangle_ result;

            last_hresult = VisualStyles.UxThemeDrawThemeEdge(theme, dc, this.part, this.state, bounds, edges, style, effects, out result);
            return(result);
        }
Exemplo n.º 6
0
 public System.Drawing.Rectangle DrawEdge(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
 {
 }
        /// <include file='doc\VisualStyleRenderer.uex' path='docs/doc[@for="VisualStyleRenderer.DrawEdge"]/*' />
        /// <devdoc>
        ///    <para>
        ///       [See win32 equivalent.]
        ///    </para>
        /// </devdoc>
        public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects) {
            if (dc == null) {
                throw new ArgumentNullException("dc");
            }

            if (!ClientUtils.IsEnumValid_Masked(edges, (int)edges,(UInt32)(Edges.Left | Edges.Top | Edges.Right | Edges.Bottom | Edges.Diagonal))) {
                throw new InvalidEnumArgumentException("edges", (int)edges, typeof(Edges));
            }

            if (!ClientUtils.IsEnumValid_NotSequential(style, (int)style, (int)EdgeStyle.Raised,(int)EdgeStyle.Sunken,(int)EdgeStyle.Etched,(int)EdgeStyle.Bump )) {
                throw new InvalidEnumArgumentException("style", (int)style, typeof(EdgeStyle));
            }

            if (!ClientUtils.IsEnumValid_Masked(effects, (int)effects, (UInt32)(EdgeEffects.FillInterior | EdgeEffects.Flat | EdgeEffects.Soft | EdgeEffects.Mono))) {
                throw new InvalidEnumArgumentException("effects", (int)effects, typeof(EdgeEffects));
            }

            NativeMethods.COMRECT rect = new NativeMethods.COMRECT();

            using( WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper( dc, AllGraphicsProperties ) ) {
                HandleRef hdc = new HandleRef( wgr, wgr.WindowsGraphics.DeviceContext.Hdc );
                lastHResult = SafeNativeMethods.DrawThemeEdge( new HandleRef( this, Handle ), hdc, part, state, new NativeMethods.COMRECT( bounds ), (int) style, (int) edges | (int) effects | EdgeAdjust, rect );
            }

            return Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom);
        }
Exemplo n.º 8
0
 public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
 {
     if (dc == null)
     {
         throw new ArgumentNullException("dc");
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_Masked(edges, (int)edges, 0x1f))
     {
         throw new InvalidEnumArgumentException("edges", (int)edges, typeof(Edges));
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_NotSequential(style, (int)style, new int[] { 5, 10, 6, 9 }))
     {
         throw new InvalidEnumArgumentException("style", (int)style, typeof(EdgeStyle));
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid_Masked(effects, (int)effects, 0xd800))
     {
         throw new InvalidEnumArgumentException("effects", (int)effects, typeof(EdgeEffects));
     }
     System.Windows.Forms.NativeMethods.COMRECT pContentRect = new System.Windows.Forms.NativeMethods.COMRECT();
     using (WindowsGraphicsWrapper wrapper = new WindowsGraphicsWrapper(dc, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping))
     {
         HandleRef hdc = new HandleRef(wrapper, wrapper.WindowsGraphics.DeviceContext.Hdc);
         this.lastHResult = System.Windows.Forms.SafeNativeMethods.DrawThemeEdge(new HandleRef(this, this.Handle), hdc, this.part, this.state, new System.Windows.Forms.NativeMethods.COMRECT(bounds), (int)style, ((int)(edges | ((Edges)((int)effects)))) | 0x2000, pContentRect);
     }
     return(Rectangle.FromLTRB(pContentRect.left, pContentRect.top, pContentRect.right, pContentRect.bottom));
 }
Exemplo n.º 9
0
        internal Rectangle DrawEdge(Gdi32.HDC dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            SourceGenerated.EnumValidator.Validate(edges, nameof(edges));
            SourceGenerated.EnumValidator.Validate(style, nameof(style));
            SourceGenerated.EnumValidator.Validate(effects, nameof(effects));

            RECT destRect    = bounds;
            var  contentRect = new RECT();

            _lastHResult = DrawThemeEdge(
                this,
                dc,
                Part,
                State,
                ref destRect,
                (User32.EDGE)style,
                (User32.BF)edges | (User32.BF)effects | User32.BF.ADJUST,
                ref contentRect);

            return(contentRect);
        }
Exemplo n.º 10
0
 public int UxThemeDrawThemeEdge(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result) => throw new InvalidOperationException();
		public Rectangle DrawEdge (IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
		{
			if (dc == null)
				throw new ArgumentNullException ("dc");
			
			Rectangle result;
			last_hresult = VisualStyles.UxThemeDrawThemeEdge (theme, dc, this.part, this.state, bounds, edges, style, effects, out result);
			return result;
		}
Exemplo n.º 12
0
        internal Rectangle DrawEdge(Gdi32.HDC dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (!ClientUtils.IsEnumValid_Masked(edges, (int)edges, (uint)(Edges.Left | Edges.Top | Edges.Right | Edges.Bottom | Edges.Diagonal)))
            {
                throw new InvalidEnumArgumentException(nameof(edges), (int)edges, typeof(Edges));
            }

            if (!ClientUtils.IsEnumValid_NotSequential(style, (int)style, (int)EdgeStyle.Raised, (int)EdgeStyle.Sunken, (int)EdgeStyle.Etched, (int)EdgeStyle.Bump))
            {
                throw new InvalidEnumArgumentException(nameof(style), (int)style, typeof(EdgeStyle));
            }

            if (!ClientUtils.IsEnumValid_Masked(effects, (int)effects, (uint)(EdgeEffects.FillInterior | EdgeEffects.Flat | EdgeEffects.Soft | EdgeEffects.Mono)))
            {
                throw new InvalidEnumArgumentException(nameof(effects), (int)effects, typeof(EdgeEffects));
            }

            RECT destRect    = bounds;
            var  contentRect = new RECT();

            _lastHResult = DrawThemeEdge(
                this,
                dc,
                Part,
                State,
                ref destRect,
                (User32.EDGE)style,
                (User32.BF)edges | (User32.BF)effects | User32.BF.ADJUST,
                ref contentRect);

            return(contentRect);
        }
Exemplo n.º 13
0
 public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
 {
     throw null;
 }
Exemplo n.º 14
0
        /// <summary>
        ///  [See win32 equivalent.]
        /// </summary>
        public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            ArgumentNullException.ThrowIfNull(dc);

            using var hdc = new DeviceContextHdcScope(dc);
            return(DrawEdge(hdc, bounds, edges, style, effects));
        }
		public int UxThemeDrawThemeEdge (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle result)
		{
			result = Rectangle.Empty;
			return (int)S.S_FALSE;
		}
Exemplo n.º 16
0
        public int UxThemeDrawThemeEdge(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle_ bounds, Edges edges, EdgeStyle style, EdgeEffects effects, out Rectangle_ result)
        {
            XplatUIWin32.RECT BoundsRect = XplatUIWin32.RECT.FromRectangle(bounds);
            XplatUIWin32.RECT retval;

            int hresult = UXTheme.DrawThemeEdge(hTheme, dc.GetHdc(), iPartId, iStateId, ref BoundsRect, (uint)style, (uint)edges + (uint)effects, out retval);

            dc.ReleaseHdc();
            result = retval.ToRectangle();
            return(hresult);
        }
Exemplo n.º 17
0
        /// <summary>
        ///  [See win32 equivalent.]
        /// </summary>
        public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (dc is null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            using var hdc = new DeviceContextHdcScope(dc);
            return(DrawEdge(hdc, bounds, edges, style, effects));
        }
Exemplo n.º 18
0
        public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            if (!ClientUtils.IsEnumValid_Masked(edges, (int)edges, (uint)(Edges.Left | Edges.Top | Edges.Right | Edges.Bottom | Edges.Diagonal)))
            {
                throw new InvalidEnumArgumentException(nameof(edges), (int)edges, typeof(Edges));
            }

            if (!ClientUtils.IsEnumValid_NotSequential(style, (int)style, (int)EdgeStyle.Raised, (int)EdgeStyle.Sunken, (int)EdgeStyle.Etched, (int)EdgeStyle.Bump))
            {
                throw new InvalidEnumArgumentException(nameof(style), (int)style, typeof(EdgeStyle));
            }

            if (!ClientUtils.IsEnumValid_Masked(effects, (int)effects, (uint)(EdgeEffects.FillInterior | EdgeEffects.Flat | EdgeEffects.Soft | EdgeEffects.Mono)))
            {
                throw new InvalidEnumArgumentException(nameof(effects), (int)effects, typeof(EdgeEffects));
            }

            using var wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties);
            var  hdc         = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc);
            RECT destRect    = bounds;
            var  contentRect = new RECT();

            lastHResult = UxTheme.DrawThemeEdge(this, hdc, part, state, ref destRect, (User32.EDGE)style, (User32.BF)edges | (User32.BF)effects | User32.BF.ADJUST, ref contentRect);
            return(contentRect);
        }
Exemplo n.º 19
0
        /// <summary>
        ///  [See win32 equivalent.]
        /// </summary>
        public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            if (!ClientUtils.IsEnumValid_Masked(edges, (int)edges, (uint)(Edges.Left | Edges.Top | Edges.Right | Edges.Bottom | Edges.Diagonal)))
            {
                throw new InvalidEnumArgumentException(nameof(edges), (int)edges, typeof(Edges));
            }

            if (!ClientUtils.IsEnumValid_NotSequential(style, (int)style, (int)EdgeStyle.Raised, (int)EdgeStyle.Sunken, (int)EdgeStyle.Etched, (int)EdgeStyle.Bump))
            {
                throw new InvalidEnumArgumentException(nameof(style), (int)style, typeof(EdgeStyle));
            }

            if (!ClientUtils.IsEnumValid_Masked(effects, (int)effects, (uint)(EdgeEffects.FillInterior | EdgeEffects.Flat | EdgeEffects.Soft | EdgeEffects.Mono)))
            {
                throw new InvalidEnumArgumentException(nameof(effects), (int)effects, typeof(EdgeEffects));
            }

            NativeMethods.COMRECT rect = new NativeMethods.COMRECT();

            using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties))
            {
                HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc);
                lastHResult = SafeNativeMethods.DrawThemeEdge(new HandleRef(this, Handle), hdc, part, state, new NativeMethods.COMRECT(bounds), (int)style, (int)edges | (int)effects | EdgeAdjust, rect);
            }

            return(Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom));
        }
 public System.Drawing.Rectangle DrawEdge(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
 {
 }