Ejemplo n.º 1
0
        internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ColorData colors)
        {
            using (WindowsGraphics wg = WindowsGraphics.FromGraphics(g)) {
                using (WindowsPen high = new WindowsPen(wg.DeviceContext, colors.highlight),
                       shadow = new WindowsPen(wg.DeviceContext, colors.buttonShadow),
                       face = new WindowsPen(wg.DeviceContext, colors.buttonFace)) {
                    wg.DrawLine(high, r.Right - 1, r.Top, r.Right - 1, r.Bottom);
                    wg.DrawLine(high, r.Left, r.Bottom - 1, r.Right, r.Bottom - 1);

                    wg.DrawLine(shadow, r.Left, r.Top, r.Left, r.Bottom);
                    wg.DrawLine(shadow, r.Left, r.Top, r.Right - 1, r.Top);

                    wg.DrawLine(face, r.Right - 2, r.Top + 1, r.Right - 2, r.Bottom - 1);
                    wg.DrawLine(face, r.Left + 1, r.Bottom - 2, r.Right - 1, r.Bottom - 2);
                }
            }
            r.Inflate(-1, -1);
            return(r);
        }
 internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ButtonBaseAdapter.ColorData colors)
 {
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(g))
     {
         using (WindowsPen pen = new WindowsPen(graphics.DeviceContext, colors.highlight))
         {
             using (WindowsPen pen2 = new WindowsPen(graphics.DeviceContext, colors.buttonShadow))
             {
                 using (WindowsPen pen3 = new WindowsPen(graphics.DeviceContext, colors.buttonFace))
                 {
                     graphics.DrawLine(pen, r.Right - 1, r.Top, r.Right - 1, r.Bottom);
                     graphics.DrawLine(pen, r.Left, r.Bottom - 1, r.Right, r.Bottom - 1);
                     graphics.DrawLine(pen2, r.Left, r.Top, r.Left, r.Bottom);
                     graphics.DrawLine(pen2, r.Left, r.Top, r.Right - 1, r.Top);
                     graphics.DrawLine(pen3, r.Right - 2, r.Top + 1, r.Right - 2, r.Bottom - 1);
                     graphics.DrawLine(pen3, r.Left + 1, r.Bottom - 2, r.Right - 1, r.Bottom - 2);
                 }
             }
         }
     }
     r.Inflate(-1, -1);
     return(r);
 }
Ejemplo n.º 3
0
        // Helper method to overcome the poor GDI ellipse drawing routine
        // VSWhidbey #334097
        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));
        }
 private static void DrawAndFillEllipse(WindowsGraphics wg, WindowsPen borderPen, WindowsBrush fieldBrush, Rectangle bounds)
 {
     if (wg != null)
     {
         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), new Point(bounds.X + 8, bounds.Y));
         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, bounds.Y + 4), new Point(bounds.X, 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));
     }
 }