// Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // Copyright (c) 2004 Novell, Inc. // // Authors: // Jordi Mas i Hernandez, jordi@ximian.com // Peter Bartok, pbartok@novell.com // // // // $Revision: 1.1 $ // $Modtime: $ // $Log: ThemeWin32Classic.cs,v $ // Revision 1.1 2004/07/26 17:42:03 jordi // Theme support // // using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; namespace System.Windows.Forms { internal class ThemeWin32Classic : ITheme { // TODO: Use System.Colors instead when possible static private Color light = Color.FromArgb (255, 255, 255, 255); static private Color disabled = Color.FromArgb (255, 172, 168, 153); static private Color dark = Color.FromArgb (255, 113, 111, 100); static private Color main = Color.FromArgb (255, 236, 233, 216); static private Color focus = Color.Black; static private SolidBrush br_light = new SolidBrush (light); static private SolidBrush br_main = new SolidBrush (main); static private SolidBrush br_dark = new SolidBrush (dark); static private Pen pen_light = new Pen (light); static private Pen pen_dark = new Pen (dark); static private Pen pen_ticks = new Pen (Color.Black); static private Pen pen_disabled = new Pen (disabled); static private SolidBrush br_arrow = new SolidBrush (Color.Black); static private SolidBrush br_disabled = new SolidBrush (disabled); static private HatchBrush br_focus = new HatchBrush (HatchStyle.Percent50, main, focus); static private Color shadow = Color.FromArgb (255, 172, 168, 153); /* ScrollBar control */ static private Color lighttop = Color.FromArgb (255, 241, 239, 226); static private SolidBrush br_shadow = new SolidBrush (shadow); static private SolidBrush br_bar = new SolidBrush (Color.FromArgb (255, 49, 106, 197)); static private Pen pen_shadow = new Pen (shadow); static private HatchBrush br_backgr = new HatchBrush (HatchStyle.Percent50, light, main); static private SolidBrush br_lighttop = new SolidBrush (lighttop); static private Pen pen_arrow = new Pen (Color.Black); private enum DrawFrameControlStates { ButtonCheck = 0x0000, ButtonRadioImage = 0x0001, ButtonRadioMask = 0x0002, ButtonRadio = 0x0004, Button3State = 0x0008, ButtonPush = 0x0010, CaptionClose = 0x0000, CaptionMin = 0x0001, CaptionMax = 0x0002, CaptionRestore = 0x0004, CaptionHelp = 0x0008, MenuArrow = 0x0000, MenuCheck = 0x0001, MenuBullet = 0x0002, MenuArrowRight = 0x0004, ScrollUp = 0x0000, ScrollDown = 0x0001, ScrollLeft = 0x0002, ScrollRight = 0x0003, ScrollComboBox = 0x0005, ScrollSizeGrip = 0x0008, ScrollSizeGripRight = 0x0010, Inactive = 0x0100, Pushed = 0x0200, Checked = 0x0400, Transparent = 0x0800, Hot = 0x1000, AdjustRect = 0x2000, Flat = 0x4000, Mono = 0x8000 } private enum DrawFrameControlTypes { Caption = 1, Menu = 2, Scroll = 3, Button = 4 } /* Methods that mimic ControlPaint signature and draw basic objects */ public void DrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth, ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle, Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle) { DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left); DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top); DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right); DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom); } public void DrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) { Pen penTopLeft; Pen penTopLeftInner; Pen penBottomRight; Pen penBottomRightInner; Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); bool doInner = false; if ((style & Border3DStyle.Adjust)!=0) { rect.Y-=2; rect.X-=2; rect.Width+=4; rect.Height+=4; } /* default to flat */ penTopLeft=SystemPens.ControlDark; penTopLeftInner=SystemPens.ControlDark; penBottomRight=SystemPens.ControlDark; penBottomRightInner=SystemPens.ControlDark; if ((style & Border3DStyle.RaisedOuter)!=0) { penTopLeft=SystemPens.ControlLightLight; penBottomRight=SystemPens.ControlDarkDark; if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) { doInner=true; } } else if ((style & Border3DStyle.SunkenOuter)!=0) { penTopLeft=SystemPens.ControlDarkDark; penBottomRight=SystemPens.ControlLightLight; if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) { doInner=true; } } if ((style & Border3DStyle.RaisedInner)!=0) { if (doInner) { penTopLeftInner=SystemPens.ControlLight; penBottomRightInner=SystemPens.ControlDark; } else { penTopLeft=SystemPens.ControlLightLight; penBottomRight=SystemPens.ControlDarkDark; } } else if ((style & Border3DStyle.SunkenInner)!=0) { if (doInner) { penTopLeftInner=SystemPens.ControlDark; penBottomRightInner=SystemPens.ControlLight; } else { penTopLeft=SystemPens.ControlDarkDark; penBottomRight=SystemPens.ControlLightLight; } } if ((sides & Border3DSide.Middle)!=0) { graphics.FillRectangle(SystemBrushes.Control, rect); } if ((sides & Border3DSide.Left)!=0) { graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-1, rect.Left, rect.Top); if (doInner) { graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-1, rect.Left+1, rect.Top); } } if ((sides & Border3DSide.Top)!=0) { graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-1, rect.Top); if (doInner) { if ((sides & Border3DSide.Left)!=0) { graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-1, rect.Top+1); } else { graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-1, rect.Top+1); } } } if ((sides & Border3DSide.Right)!=0) { graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1); if (doInner) { if ((sides & Border3DSide.Top)!=0) { graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-1); } else { graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-1); } } } if ((sides & Border3DSide.Bottom)!=0) { int left=rect.Left; if ((sides & Border3DSide.Left)!=0) { left+=1; } graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1); if (doInner) { if ((sides & Border3DSide.Right)!=0) { graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2); } else { graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-1, rect.Bottom-2); } } } } public void DrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) { DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush; if ((state & ButtonState.Pushed)!=0) { dfcs |= DrawFrameControlStates.Pushed; } if ((state & ButtonState.Checked)!=0) { dfcs |= DrawFrameControlStates.Checked; } if ((state & ButtonState.Flat)!=0) { dfcs |= DrawFrameControlStates.Flat; } if ((state & ButtonState.Inactive)!=0) { dfcs |= DrawFrameControlStates.Inactive; } DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs); } public void DrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) { Rectangle captionRect; int lineWidth; DrawButton(graphics, rectangle, state); if (rectangle.Width127) { foreColor=Color.Black; } else { foreColor=Color.White; } #if false /* Commented out until I take the time and figure out which HatchStyle will match requirements. The code below is only correct for Percent50. */ if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) { HatchBrush brush=null; switch(pixelsBetweenDots.Width) { case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break; case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break; case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break; default: { /* Have to do it the slow way */ break; } } if (brush!=null) { graphics.FillRectangle(brush, area); pen.Dispose(); brush.Dispose(); return; } } #endif /* Slow method */ Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics); for (int x=0; x 256 colors on the display. */ ImageAttributes imageAttributes=new ImageAttributes(); ColorMatrix colorMatrix=new ColorMatrix(new float[][] { // This table would create a perfect grayscale image, based on luminance // new float[]{0.3f,0.3f,0.3f,0,0}, // new float[]{0.59f,0.59f,0.59f,0,0}, // new float[]{0.11f,0.11f,0.11f,0,0}, // new float[]{0,0,0,1,0,0}, // new float[]{0,0,0,0,1,0}, // new float[]{0,0,0,0,0,1} // This table generates a image that is grayscaled and then // brightened up. Seems to match MS close enough. new float[]{0.2f,0.2f,0.2f,0,0}, new float[]{0.41f,0.41f,0.41f,0,0}, new float[]{0.11f,0.11f,0.11f,0,0}, new float[]{0.15f,0.15f,0.15f,1,0,0}, new float[]{0.15f,0.15f,0.15f,0,1,0}, new float[]{0.15f,0.15f,0.15f,0,0,1} }); imageAttributes.SetColorMatrix(colorMatrix); graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageAttributes.Dispose(); } public void DrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) { Pen penBorder; Pen penInside; if (primary) { penBorder=new Pen(Color.White, 2); penInside=new Pen(Color.Black, 1); } else { penBorder=new Pen(Color.Black, 2); penInside=new Pen(Color.White, 1); } penBorder.Alignment=PenAlignment.Inset; penInside.Alignment=PenAlignment.Inset; graphics.DrawRectangle(penBorder, rectangle); graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5); penBorder.Dispose(); penInside.Dispose(); } public void DrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph) { Rectangle rect; int lineWidth; // MS seems to draw the background white graphics.FillRectangle(new SolidBrush(Color.White), rectangle); switch(glyph) { case MenuGlyph.Arrow: { Point[] arrow = new Point[3]; Point P1; Point P2; Point P3; int centerX; int centerY; int shiftX; int shiftY; rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2); centerX=rect.Left+rect.Width/2; centerY=rect.Top+rect.Height/2; shiftX=Math.Max(1, rect.Width/8); shiftY=Math.Max(1, rect.Height/8); rect.X-=shiftX; centerX-=shiftX; P1=new Point(centerX, rect.Top-1); P2=new Point(centerX, rect.Bottom); P3=new Point(rect.Right, centerY); arrow[0]=P1; arrow[1]=P2; arrow[2]=P3; graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding); return; } case MenuGlyph.Bullet: { SolidBrush sb; lineWidth=Math.Max(2, rectangle.Width/3); rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2); sb=new SolidBrush(SystemColors.MenuText); graphics.FillEllipse(sb, rect); sb.Dispose(); return; } case MenuGlyph.Checkmark: { int Scale; lineWidth=Math.Max(2, rectangle.Width/6); Scale=Math.Max(1, rectangle.Width/12); rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2); for (int i=0; i= pixel_len) dc.DrawLine (pen_ticks, thumb_pos.X + 23, thumb_area.Y + space_from_bottom - 2 + inc, thumb_pos.X + 26, thumb_area.Y + space_from_bottom - 2 + inc); else dc.DrawLine (pen_ticks, thumb_pos.X + 23, thumb_area.Y + space_from_bottom - 2 + inc, thumb_pos.X + 25, thumb_area.Y + space_from_bottom - 2 + inc); } } if ((style & TickStyle.TopLeft) == TickStyle.TopLeft || ((style & TickStyle.Both) == TickStyle.Both)) { float pixel_len = thumb_area.Height - 10; float ticks_to_draw = pixel_len / ticks; if (ticks_to_draw < 0) ticks_to_draw = 1; for (int inc = 0; inc < pixel_len; inc += (int) ticks_to_draw) if (inc == 0 || (inc + (int) ticks_to_draw) >= pixel_len) dc.DrawLine (pen_ticks, area.X + 4, thumb_area.Y + 5 + inc, area.X + 8, thumb_area.Y + 5 + inc); else dc.DrawLine (pen_ticks, area.X + 5, thumb_area.Y + 5 + inc, area.X + 8, thumb_area.Y + 5 + inc); } } /* Horizontal trackbar */ static internal void DrawTrackBar_Horitonzal (Graphics dc, Rectangle area, ref Rectangle thumb_pos, ref Rectangle thumb_area, TickStyle style, int ticks, bool focused) { /* Background */ dc.FillRectangle (br_main, area); if (focused) { dc.FillRectangle (br_focus, area.X, area.Y, area.Width - 1, 1); dc.FillRectangle (br_focus, area.X, area.Y + area.Height - 1, area.Width - 1, 1); dc.FillRectangle (br_focus, area.X, area.Y, 1, area.Height - 1); dc.FillRectangle (br_focus, area.X + area.Width - 1, area.Y, 1, area.Height - 1); } int space_from_right = 8; int space_from_left = 7; int x = space_from_left; int y = area.Y; switch (style) { case TickStyle.BottomRight: case TickStyle.None: y += (area.Height / 4); break; case TickStyle.TopLeft: y += (area.Height / 2); break; case TickStyle.Both: y += 18; break; default: break; } thumb_area.X = area.X + space_from_left; thumb_area.Y = area.Y + 2; thumb_area.Width = area.Width - space_from_right - space_from_left; thumb_area.Height = 4; /* Draw channel */ dc.FillRectangle (br_disabled, x, y, area.Width - (x - area.X) - space_from_right, 1); dc.FillRectangle (br_dark, x, y + 1, area.Width - (x - area.X) - space_from_right, 1); dc.FillRectangle (br_light, x, y + 3, area.Width - (x - area.X) - space_from_right, 1); /* Draw thumb fixed 10x22 size */ thumb_pos.Width = 10; thumb_pos.Height = 22; switch (style) { case TickStyle.BottomRight: case TickStyle.None: { thumb_pos.Y = area.Y + 2; dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y); dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16); dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y, thumb_pos.X +9, thumb_pos.Y +16); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4); dc.DrawLine (pen_dark, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16); dc.DrawLine (pen_dark, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5); dc.FillRectangle (br_main, thumb_pos.X + 1, thumb_pos.Y + 1, 9, 16); break; } case TickStyle.TopLeft: { thumb_pos.Y = y - 10; dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16); dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19); dc.DrawLine (pen_dark, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16); dc.DrawLine (pen_dark, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1); dc.DrawLine (pen_dark, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20); dc.FillRectangle (br_main, thumb_pos.X + 1, thumb_pos.Y + 5, 8, 14); break; } case TickStyle.Both: { thumb_pos.Y = area.Y + 10; dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y); dc.DrawLine (pen_light, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 20); dc.DrawLine (pen_disabled, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 20); dc.DrawLine (pen_disabled, thumb_pos.X + 1, thumb_pos.Y + 20, thumb_pos.X + 8, thumb_pos.Y + 20); dc.DrawLine (pen_dark, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 21); dc.DrawLine (pen_dark, thumb_pos.X, thumb_pos.Y + 21, thumb_pos.X + 9, thumb_pos.Y + 21); dc.FillRectangle (br_main, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 19); break; } default: break; } /* Draw ticks*/ if ((style & TickStyle.BottomRight) == TickStyle.BottomRight || ((style & TickStyle.Both) == TickStyle.Both)) { float pixel_len = thumb_area.Width - 10; float ticks_to_draw = pixel_len / ticks; if (ticks_to_draw < 0) ticks_to_draw = 1; for (int inc = 0; inc < pixel_len; inc += (int) ticks_to_draw) if (inc == 0 || (inc + (int) ticks_to_draw) >= pixel_len) dc.DrawLine (pen_ticks, thumb_area.X + space_from_left - 2 + inc, thumb_pos.Y + 25, thumb_area.X + space_from_left - 2 + inc, thumb_pos.Y + 28); else dc.DrawLine (pen_ticks, thumb_area.X + space_from_left - 2 + inc, thumb_pos.Y + 25, thumb_area.X + space_from_left - 2 + inc, thumb_pos.Y + 27); } if ((style & TickStyle.TopLeft) == TickStyle.TopLeft || ((style & TickStyle.Both) == TickStyle.Both)) { float pixel_len = thumb_area.Width - 10; float ticks_to_draw = pixel_len / ticks; if (ticks_to_draw < 0) ticks_to_draw = 1; for (int inc = 0; inc < pixel_len; inc += (int) ticks_to_draw) if (inc == 0 || (inc + (int) ticks_to_draw) >= pixel_len) dc.DrawLine (pen_ticks, thumb_area.X + 5 + inc, area.Y + 5, thumb_area.X + 5 + inc, area.Y + 9); else dc.DrawLine (pen_ticks, thumb_area.X + 5 + inc, area.Y + 6, thumb_area.X + 5 + inc, area.Y + 8); } } public void DrawTrackBar (Graphics dc, Rectangle area, ref Rectangle thumb_pos, ref Rectangle thumb_area, TickStyle style, int ticks, Orientation orientation, bool focused) { if (orientation == Orientation.Vertical) DrawTrackBar_Vertical (dc, area, ref thumb_pos, ref thumb_area, style, ticks, focused); else DrawTrackBar_Horitonzal (dc, area, ref thumb_pos, ref thumb_area, style, ticks, focused); } public void DrawProgressBar (Graphics dc, Rectangle area, Rectangle client_area, int barpos_pixels, int block_width) { int space_betweenblocks = 2; int increment = block_width + space_betweenblocks; int x = client_area.X; /* Background*/ dc.FillRectangle (br_main, area); /* Draw background*/ while ((x - client_area.X) < barpos_pixels) { dc.FillRectangle (br_bar, x, client_area.Y, block_width, client_area.Height); x = x + increment; } /* Draw border */ dc.FillRectangle (br_shadow, area.X, area.Y, area.Width, 1); dc.FillRectangle (br_shadow, area.X, area.Y, 1, area.Height); dc.FillRectangle (br_light, area.X, area.Y + area.Height - 1, area.Width, 1); dc.FillRectangle (br_light, area.X + area.Width - 1, area.Y, 1, area.Height); } /* Private methods */ private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY, int width, Color color, ButtonBorderStyle style, Border3DSide side) { Pen pen=new Pen(color, 1); switch(style) { case ButtonBorderStyle.Solid: { pen.DashStyle=DashStyle.Solid; break; } case ButtonBorderStyle.Dashed: { pen.DashStyle=DashStyle.Dash; break; } case ButtonBorderStyle.Dotted: { pen.DashStyle=DashStyle.Dot; break; } case ButtonBorderStyle.Inset: { pen.DashStyle=DashStyle.Solid; break; } case ButtonBorderStyle.Outset: { pen.DashStyle=DashStyle.Solid; break; } default: case ButtonBorderStyle.None: { pen.Dispose(); return; } } switch(style) { case ButtonBorderStyle.Outset: { Color colorGrade; int hue, brightness, saturation; int brightnessSteps; int brightnessDownSteps; ControlPaint.Color2HBS(color, out hue, out brightness, out saturation); brightnessDownSteps=brightness/width; if (brightness>127) { brightnessSteps=Math.Max(6, (160-brightness)/width); } else { brightnessSteps=(127-brightness)/width; } for (int i=0; i127) { brightnessSteps=Math.Max(6, (160-brightness)/width); } else { brightnessSteps=(127-brightness)/width; } for (int i=0; i