// FillRectangle overloads

        /// <include file='doc\WindowsGraphics.uex' path='docs/doc[@for="WindowsGraphics.FillRectangle"]/*' />
        public void FillRectangle(WindowsBrush brush, Rectangle rect)
        {
            FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
        }
        /// <include file='doc\WindowsGraphics.uex' path='docs/doc[@for="WindowsGraphics.FillRectangle3"]/*' />
        public void FillRectangle(WindowsBrush brush, int x, int y, int width, int height)
        {
            Debug.Assert( brush != null, "brush == null" );

            HandleRef hdc  = new HandleRef(this.dc, this.dc.Hdc);
            IntPtr hBrush  = brush.HBrush;  // We don't delete this handle since we didn't create it.   
            IntNativeMethods.RECT rect = new IntNativeMethods.RECT(x, y, x + width, y + height );

#if WINFORMS_PUBLIC_GRAPHICS_LIBRARY
            if (brush is WindowsHatchBrush)
            { 
                int clr = ColorTranslator.ToWin32(((WindowsHatchBrush)brush).BackGroundColor);
                IntUnsafeNativeMethods.SetBkColor(hdc, clr );
                IntUnsafeNativeMethods.SetBkMode(hdc, (int)DeviceContextBackgroundMode.Transparent);
            }
#endif
            IntUnsafeNativeMethods.FillRect(hdc, ref rect, new HandleRef(brush, hBrush));
        }
        private void DrawEllipse(WindowsPen pen, WindowsBrush brush,
            int nLeftRect,  // x-coord of upper-left corner of rectangle
            int nTopRect,   // y-coord of upper-left corner of rectangle
            int nRightRect, // x-coord of lower-right corner of rectangle
            int nBottomRect ) 
        { // y-coord of lower-right corner of rectangle
            HandleRef hdc = new HandleRef( this.dc, this.dc.Hdc);

            if (pen != null)
            {
                // 1. Select the pen in the DC
                IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(pen, pen.HPen));
            }

            if (brush != null)
            {
                IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(brush, brush.HBrush));
            }

            // 2. call the function
            IntUnsafeNativeMethods.Ellipse(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
        }
 public void DrawAndFillEllipse(WindowsPen pen, WindowsBrush brush, Rectangle bounds) 
 {
     DrawEllipse(pen, brush, bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
 }
Пример #5
0
 public WindowsPen(DeviceContext dc, WindowsBrush windowsBrush) :
     this(dc, WindowsPenStyle.Default, cosmeticPenWidth, windowsBrush)
 {
 }
        private static void DrawAndFillEllipse(WindowsGraphics wg, WindowsPen borderPen, WindowsBrush fieldBrush, Rectangle bounds)
        {
            Debug.Assert(wg != null, "Calling DrawAndFillEllipse with null wg");
            if (wg == null)
            {
                return;
            }

            wg.FillRectangle(fieldBrush, new Rectangle(bounds.X + 2, bounds.Y + 2, 8, 8));
            wg.FillRectangle(fieldBrush, new Rectangle(bounds.X + 4, bounds.Y + 1, 4, 10));
            wg.FillRectangle(fieldBrush, new Rectangle(bounds.X + 1, bounds.Y + 4, 10, 4));

            wg.DrawLine(borderPen, new Point(bounds.X + 4, bounds.Y + 0), new Point(bounds.X + 8, bounds.Y + 0));
            wg.DrawLine(borderPen, new Point(bounds.X + 4, bounds.Y + 11), new Point(bounds.X + 8, bounds.Y + 11));

            wg.DrawLine(borderPen, new Point(bounds.X + 2, bounds.Y + 1), new Point(bounds.X + 4, bounds.Y + 1));
            wg.DrawLine(borderPen, new Point(bounds.X + 8, bounds.Y + 1), new Point(bounds.X + 10, bounds.Y + 1));

            wg.DrawLine(borderPen, new Point(bounds.X + 2, bounds.Y + 10), new Point(bounds.X + 4, bounds.Y + 10));
            wg.DrawLine(borderPen, new Point(bounds.X + 8, bounds.Y + 10), new Point(bounds.X + 10, bounds.Y + 10));

            wg.DrawLine(borderPen, new Point(bounds.X + 0, bounds.Y + 4), new Point(bounds.X + 0, bounds.Y + 8));
            wg.DrawLine(borderPen, new Point(bounds.X + 11, bounds.Y + 4), new Point(bounds.X + 11, bounds.Y + 8));

            wg.DrawLine(borderPen, new Point(bounds.X + 1, bounds.Y + 2), new Point(bounds.X + 1, bounds.Y + 4));
            wg.DrawLine(borderPen, new Point(bounds.X + 1, bounds.Y + 8), new Point(bounds.X + 1, bounds.Y + 10));

            wg.DrawLine(borderPen, new Point(bounds.X + 10, bounds.Y + 2), new Point(bounds.X + 10, bounds.Y + 4));
            wg.DrawLine(borderPen, new Point(bounds.X + 10, bounds.Y + 8), new Point(bounds.X + 10, bounds.Y + 10));
        }
Пример #7
0
        // FillRectangle overloads

        public void FillRectangle(WindowsBrush brush, Rectangle rect)
        {
            FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
        }
Пример #8
0
 public void DrawAndFillEllipse(WindowsPen pen, WindowsBrush brush, Rectangle bounds)
 {
     DrawEllipse(pen, brush, bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
 }
Пример #9
0
 public WindowsPen(DeviceContext dc, WindowsPenStyle style, int width, WindowsBrush windowsBrush )
 {
     Debug.Assert(windowsBrush != null, "null windowsBrush" );
     
     this.style    = style;
     this.wndBrush = (WindowsBrush) windowsBrush.Clone();
     this.width    = width;
     this.color    = windowsBrush.Color;
     this.dc       = dc;
     
     // CreatePen() created on demand.
 }
Пример #10
0
 public WindowsPen(DeviceContext dc, WindowsBrush windowsBrush ) :
     this( dc, WindowsPenStyle.Default, cosmeticPenWidth, windowsBrush )
 {
 }
Пример #11
0
        void Dispose(bool disposing)
        {
            if (this.nativeHandle != IntPtr.Zero && dc != null)
            {
                DbgUtil.AssertFinalization(this, disposing);

                dc.DeleteObject(this.nativeHandle, GdiObjectType.Pen);
                this.nativeHandle = IntPtr.Zero;
            }

            if (this.wndBrush != null)
            {
                this.wndBrush.Dispose();
                this.wndBrush = null;
            }

            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
        }