本文整理汇总了C#中System.Drawing.Color.ToKnownColor方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToKnownColor方法的具体用法?C# Color.ToKnownColor怎么用?C# Color.ToKnownColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Color
的用法示例。
在下文中一共展示了Color.ToKnownColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public static void Serialize(SerializationWriter writer, Color color)
{
BitVector32 flags = new BitVector32();
if (color.IsKnownColor)
flags[ColorIsKnown] = true;
else if (color.IsNamedColor)
flags[ColorHasName] = true;
else if (!color.IsEmpty)
{
flags[ColorHasValue] = true;
flags[ColorHasRed] = color.R != 0;
flags[ColorHasGreen] = color.G != 0;
flags[ColorHasBlue] = color.B != 0;
flags[ColorHasAlpha] = color.A != 0;
}
writer.WriteOptimized(flags);
if (color.IsKnownColor)
writer.WriteOptimized((int) color.ToKnownColor());
else if (color.IsNamedColor)
writer.WriteOptimized(color.Name);
else if (!color.IsEmpty)
{
byte component;
if ( (component = color.R) != 0) writer.Write(component);
if ( (component = color.G) != 0) writer.Write(component);
if ( (component = color.B) != 0) writer.Write(component);
if ( (component = color.A) != 0) writer.Write(component);
}
}
示例2: HLSColor
/// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.HLSColor.HLSColor"]/*' />
/// <devdoc>
/// </devdoc>
public HLSColor(Color color)
{
isSystemColors_Control = (color.ToKnownColor() == SystemColors.Control.ToKnownColor());
int r = color.R;
int g = color.G;
int b = color.B;
int max, min; /* max and min RGB values */
int sum, dif;
int Rdelta, Gdelta, Bdelta; /* intermediate value: % of spread from max */
/* calculate lightness */
max = Math.Max(Math.Max(r, g), b);
min = Math.Min(Math.Min(r, g), b);
sum = max + min;
luminosity = (((sum * HLSMax) + RGBMax) / (2 * RGBMax));
dif = max - min;
if (dif == 0)
{ /* r=g=b --> achromatic case */
saturation = 0; /* saturation */
hue = Undefined; /* hue */
}
else
{ /* chromatic case */
/* saturation */
if (luminosity <= (HLSMax / 2))
saturation = (int)(((dif * (int)HLSMax) + (sum / 2)) / sum);
else
saturation = (int)((int)((dif * (int)HLSMax) + (int)((2 * RGBMax - sum) / 2))
/ (2 * RGBMax - sum));
/* hue */
Rdelta = (int)((((max - r) * (int)(HLSMax / 6)) + (dif / 2)) / dif);
Gdelta = (int)((((max - g) * (int)(HLSMax / 6)) + (dif / 2)) / dif);
Bdelta = (int)((((max - b) * (int)(HLSMax / 6)) + (dif / 2)) / dif);
if ((int)r == max)
hue = Bdelta - Gdelta;
else if ((int)g == max)
hue = (HLSMax / 3) + Rdelta - Bdelta;
else /* B == cMax */
hue = ((2 * HLSMax) / 3) + Gdelta - Rdelta;
if (hue < 0)
hue += HLSMax;
if (hue > HLSMax)
hue -= HLSMax;
}
}
示例3: FromSystemColor
public static Brush FromSystemColor(Color c)
{
if (!c.IsSystemColor)
{
throw new ArgumentException(System.Drawing.SR.GetString("ColorNotSystemColor", new object[] { c.ToString() }));
}
Brush[] brushArray = (Brush[]) SafeNativeMethods.Gdip.ThreadData[SystemBrushesKey];
if (brushArray == null)
{
brushArray = new Brush[0x21];
SafeNativeMethods.Gdip.ThreadData[SystemBrushesKey] = brushArray;
}
int index = (int) c.ToKnownColor();
if (index > 0xa7)
{
index -= 0x8d;
}
index--;
if (brushArray[index] == null)
{
brushArray[index] = new SolidBrush(c, true);
}
return brushArray[index];
}
示例4: FromSystemColor
public static Pen FromSystemColor(Color c)
{
if (!c.IsSystemColor)
{
throw new ArgumentException(System.Drawing.SR.GetString("ColorNotSystemColor", new object[] { c.ToString() }));
}
Pen[] penArray = (Pen[]) SafeNativeMethods.Gdip.ThreadData[SystemPensKey];
if (penArray == null)
{
penArray = new Pen[0x21];
SafeNativeMethods.Gdip.ThreadData[SystemPensKey] = penArray;
}
int index = (int) c.ToKnownColor();
if (index > 0xa7)
{
index -= 0x8d;
}
index--;
if (penArray[index] == null)
{
penArray[index] = new Pen(c, true);
}
return penArray[index];
}
示例5: ToHtml
public static string ToHtml (Color c)
{
if (c.IsEmpty)
return String.Empty;
if (c.IsSystemColor) {
KnownColor kc = c.ToKnownColor ();
switch (kc) {
case KnownColor.ActiveBorder:
case KnownColor.ActiveCaption:
case KnownColor.AppWorkspace:
case KnownColor.GrayText:
case KnownColor.Highlight:
case KnownColor.HighlightText:
case KnownColor.InactiveBorder:
case KnownColor.InactiveCaption:
case KnownColor.InactiveCaptionText:
case KnownColor.InfoText:
case KnownColor.Menu:
case KnownColor.MenuText:
case KnownColor.ScrollBar:
case KnownColor.Window:
case KnownColor.WindowFrame:
case KnownColor.WindowText:
return KnownColors.GetName (kc).ToLower (CultureInfo.InvariantCulture);
case KnownColor.ActiveCaptionText:
return "captiontext";
case KnownColor.Control:
return "buttonface";
case KnownColor.ControlDark:
return "buttonshadow";
case KnownColor.ControlDarkDark:
return "threeddarkshadow";
case KnownColor.ControlLight:
return "buttonface";
case KnownColor.ControlLightLight:
return "buttonhighlight";
case KnownColor.ControlText:
return "buttontext";
case KnownColor.Desktop:
return "background";
case KnownColor.HotTrack:
return "highlight";
case KnownColor.Info:
return "infobackground";
default:
return String.Empty;
}
}
if (c.IsNamedColor) {
if (c == Color.LightGray)
return "LightGrey";
else
return c.Name;
}
return FormatHtml (c.R, c.G, c.B);
}
示例6: ToHtml
public static string ToHtml(Color c)
{
string str = string.Empty;
if (!c.IsEmpty)
{
if (!c.IsSystemColor)
{
if (c.IsNamedColor)
{
if (c == Color.LightGray)
{
return "LightGrey";
}
return c.Name;
}
return ("#" + c.R.ToString("X2", null) + c.G.ToString("X2", null) + c.B.ToString("X2", null));
}
switch (c.ToKnownColor())
{
case KnownColor.ActiveBorder:
return "activeborder";
case KnownColor.ActiveCaption:
case KnownColor.GradientActiveCaption:
return "activecaption";
case KnownColor.ActiveCaptionText:
return "captiontext";
case KnownColor.AppWorkspace:
return "appworkspace";
case KnownColor.Control:
return "buttonface";
case KnownColor.ControlDark:
return "buttonshadow";
case KnownColor.ControlDarkDark:
return "threeddarkshadow";
case KnownColor.ControlLight:
return "buttonface";
case KnownColor.ControlLightLight:
return "buttonhighlight";
case KnownColor.ControlText:
return "buttontext";
case KnownColor.Desktop:
return "background";
case KnownColor.GrayText:
return "graytext";
case KnownColor.Highlight:
case KnownColor.HotTrack:
return "highlight";
case KnownColor.HighlightText:
case KnownColor.MenuHighlight:
return "highlighttext";
case KnownColor.InactiveBorder:
return "inactiveborder";
case KnownColor.InactiveCaption:
case KnownColor.GradientInactiveCaption:
return "inactivecaption";
case KnownColor.InactiveCaptionText:
return "inactivecaptiontext";
case KnownColor.Info:
return "infobackground";
case KnownColor.InfoText:
return "infotext";
case KnownColor.Menu:
case KnownColor.MenuBar:
return "menu";
case KnownColor.MenuText:
return "menutext";
case KnownColor.ScrollBar:
return "scrollbar";
case KnownColor.Window:
return "window";
case KnownColor.WindowFrame:
return "windowframe";
case KnownColor.WindowText:
return "windowtext";
}
}
//.........这里部分代码省略.........
示例7: prepWriteDispBoxes
private void prepWriteDispBoxes(Data msg, Color newColor)
{
string msgText = msg.strMessage;
textToDisp = new string[3];
textToDisp[0] = "";
textToDisp[1] = "";
textToDisp[2] = "";
clearDispMsg();
if (newColor.ToKnownColor() != KnownColor.PeachPuff)
setDispMsgColor(newColor);
msgText = msg.strMessage.Substring(msg.strName.Length + 2);
for (int i = 0; i < 3; i++)
{
if (TextRenderer.MeasureText(msgText, displayMsg1.Font).Width > 240)
{
string[] parts = msgText.Split(' ');
string combined = "";
for (int x = 0; x < parts.Length; x++)
{
/* if (i == 2) // test bit of code to try and help me test these stupid loops
{
string test = "";
} */
//TO DO: Add a handler in case a single word is too long, and measure it by characters
if (TextRenderer.MeasureText(parts[x], displayMsg1.Font).Width <= 246)
{
if (TextRenderer.MeasureText(combined + parts[x] + " ", displayMsg1.Font).Width <= 246)
{
combined = combined + parts[x] + " "; // TO DO: Don't add a space after the last word
}
else
{
textToDisp[i] = combined;
msgText = msgText.Substring(combined.Length);
break;
}
}
else
{
for (int y = 0; y < parts[x].Length; y++)
{
if (TextRenderer.MeasureText(combined + parts[x].Substring(0, y), displayMsg1.Font).Width <= 246)
{
combined = combined + parts[x].Substring(0, y); // TO DO: Don't add a space after the last word
}
else
{
textToDisp[i] = combined;
msgText = msgText.Substring(combined.Length);
break;
}
}
}
}
}
else
{
textToDisp[i] = msgText;
break;
}
}
//dispTextRedraw.Enabled = true;
nameLabel.Text = iniParser.GetDispName(latestMsg.strName) ?? latestMsg.strName;
//blipPlayer.Initialize(blipReader);
blipPlayer.Stop();
if (!mute)
blipPlayer.Play();
redraw = true;
}
示例8: WriteDataTime
/// <summary>
/// Write date to container with style.
/// </summary>
/// <param name="writer">HtmlTextWriter.</param>
/// <param name="dwt">Date.</param>
/// <param name="Container">HtmlContainer.</param>
/// <param name="fWriteTime">Write date(false) or time(true).</param>
/// <param name="UserID">ID of user.</param>
private void WriteDataTime(HtmlTextWriter writer,
DayWorkTime dwt,
String Container,
bool fWriteTime,
int? UserID)
{
CalendarItem calItem = new CalendarItem(dwt);
String strValue = fWriteTime
? DateTimePresenter.GetTime(dwt.WorkTime)
: dwt.Date.ToString("dd/MM");
Color cellColor = new Color();
if (UserID != null
&& dwt.WorkTime == TimeSpan.Zero
&& !calItem.IsWeekend)
{
WorkEvent workEvent = WorkEvent.GetCurrentEventOfDate((int) UserID, dwt.Date);
if (workEvent != null)
switch (workEvent.EventType)
{
case WorkEventType.BusinessTrip:
strValue = "Trip";
cellColor = Color.LightSlateGray;
break;
case WorkEventType.Ill:
strValue = "Ill";
cellColor = Color.LightPink;
break;
case WorkEventType.TrustIll:
strValue = "Trust Ill";
cellColor = Color.LightPink;
break;
case WorkEventType.Vacation:
strValue = "Vacation";
cellColor = Color.LightYellow;
break;
}
}
if (calItem.IsWeekend)
writer.WriteLine("<{0} class='weekend'>{1}</{0}>",
Container,
strValue);
else
writer.WriteLine("<{0} style='background-color: {1};' align='center'>{2}</{0}>",
Container,
cellColor.ToKnownColor(),
strValue);
}
示例9: HLSColor
public HLSColor(Color color)
{
this.isSystemColors_Control = color.ToKnownColor() == SystemColors.Control.ToKnownColor();
int r = color.R;
int g = color.G;
int b = color.B;
int num4 = Math.Max(Math.Max(r, g), b);
int num5 = Math.Min(Math.Min(r, g), b);
int num6 = num4 + num5;
this.luminosity = ((num6 * 240) + 0xff) / 510;
int num7 = num4 - num5;
if (num7 == 0)
{
this.saturation = 0;
this.hue = 160;
}
else
{
if (this.luminosity <= 120)
{
this.saturation = ((num7 * 240) + (num6 / 2)) / num6;
}
else
{
this.saturation = ((num7 * 240) + ((510 - num6) / 2)) / (510 - num6);
}
int num8 = (((num4 - r) * 40) + (num7 / 2)) / num7;
int num9 = (((num4 - g) * 40) + (num7 / 2)) / num7;
int num10 = (((num4 - b) * 40) + (num7 / 2)) / num7;
if (r == num4)
{
this.hue = num10 - num9;
}
else if (g == num4)
{
this.hue = (80 + num8) - num10;
}
else
{
this.hue = (160 + num9) - num8;
}
if (this.hue < 0)
{
this.hue += 240;
}
if (this.hue > 240)
{
this.hue -= 240;
}
}
}
示例10: UpdateItemColor
private void UpdateItemColor(int itemIndex, int subItemIndex, Color fore, Color back)
{
if (lvAttributes.Items.Count <= itemIndex || lvAttributes.Items[itemIndex].SubItems.Count <= subItemIndex)
return;
if (fore.ToKnownColor() == (KnownColor)0)
fore = AttrData.defaultForeground;
lvAttributes.Items[itemIndex].SubItems[subItemIndex].ForeColor = fore;
if (back.ToKnownColor() == (KnownColor)0)
back = AttrData.defaultBackground;
lvAttributes.Items[itemIndex].SubItems[subItemIndex].BackColor = back;
}
示例11: GetHtmlColor
private string GetHtmlColor(Color color)
{
if (color.IsEmpty == true)
{
return string.Empty;
}
if (color.IsNamedColor == true)
{
return color.ToKnownColor().ToString();
}
if (color.IsSystemColor == true)
{
return color.ToString();
}
return "#" + color.ToArgb().ToString("x").Substring(2);
}
示例12: ToHtml
/// <include file='doc\ColorTranslator.uex' path='docs/doc[@for="ColorTranslator.ToHtml"]/*' />
/// <devdoc>
/// <para>
/// Translates the specified <see cref='System.Drawing.Color'/> to an Html string color representation.
/// </para>
/// </devdoc>
public static string ToHtml(Color c) {
string colorString = String.Empty;
if (c.IsEmpty)
return colorString;
if (c.IsSystemColor) {
switch (c.ToKnownColor()) {
case KnownColor.ActiveBorder: colorString = "activeborder"; break;
case KnownColor.GradientActiveCaption:
case KnownColor.ActiveCaption: colorString = "activecaption"; break;
case KnownColor.AppWorkspace: colorString = "appworkspace"; break;
case KnownColor.Desktop: colorString = "background"; break;
case KnownColor.Control: colorString = "buttonface"; break;
case KnownColor.ControlLight: colorString = "buttonface"; break;
case KnownColor.ControlDark: colorString = "buttonshadow"; break;
case KnownColor.ControlText: colorString = "buttontext"; break;
case KnownColor.ActiveCaptionText: colorString = "captiontext"; break;
case KnownColor.GrayText: colorString = "graytext"; break;
case KnownColor.HotTrack:
case KnownColor.Highlight: colorString = "highlight"; break;
case KnownColor.MenuHighlight:
case KnownColor.HighlightText: colorString = "highlighttext"; break;
case KnownColor.InactiveBorder: colorString = "inactiveborder"; break;
case KnownColor.GradientInactiveCaption:
case KnownColor.InactiveCaption: colorString = "inactivecaption"; break;
case KnownColor.InactiveCaptionText: colorString = "inactivecaptiontext"; break;
case KnownColor.Info: colorString = "infobackground"; break;
case KnownColor.InfoText: colorString = "infotext"; break;
case KnownColor.MenuBar:
case KnownColor.Menu: colorString = "menu"; break;
case KnownColor.MenuText: colorString = "menutext"; break;
case KnownColor.ScrollBar: colorString = "scrollbar"; break;
case KnownColor.ControlDarkDark: colorString = "threeddarkshadow"; break;
case KnownColor.ControlLightLight: colorString = "buttonhighlight"; break;
case KnownColor.Window: colorString = "window"; break;
case KnownColor.WindowFrame: colorString = "windowframe"; break;
case KnownColor.WindowText: colorString = "windowtext"; break;
}
}
else if (c.IsNamedColor) {
if (c == Color.LightGray) {
// special case due to mismatch between Html and enum spelling
colorString = "LightGrey";
}
else {
colorString = c.Name;
}
}
else {
colorString = "#" + c.R.ToString("X2", null) +
c.G.ToString("X2", null) +
c.B.ToString("X2", null);
}
return colorString;
}
示例13: ToHtml
/// <summary>Translates the specified <see cref="T:System.Drawing.Color" /> structure to an HTML string color representation.</summary>
/// <returns>The string that represents the HTML color.</returns>
/// <param name="c">The <see cref="T:System.Drawing.Color" /> structure to translate. </param>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
public static string ToHtml(Color c)
{
string result = string.Empty;
if (c.IsEmpty)
{
return result;
}
if (c.IsSystemColor)
{
KnownColor knownColor = c.ToKnownColor();
switch (knownColor)
{
case KnownColor.ActiveBorder:
result = "activeborder";
return result;
case KnownColor.ActiveCaption:
break;
case KnownColor.ActiveCaptionText:
result = "captiontext";
return result;
case KnownColor.AppWorkspace:
result = "appworkspace";
return result;
case KnownColor.Control:
result = "buttonface";
return result;
case KnownColor.ControlDark:
result = "buttonshadow";
return result;
case KnownColor.ControlDarkDark:
result = "threeddarkshadow";
return result;
case KnownColor.ControlLight:
result = "buttonface";
return result;
case KnownColor.ControlLightLight:
result = "buttonhighlight";
return result;
case KnownColor.ControlText:
result = "buttontext";
return result;
case KnownColor.Desktop:
result = "background";
return result;
case KnownColor.GrayText:
result = "graytext";
return result;
case KnownColor.Highlight:
case KnownColor.HotTrack:
result = "highlight";
return result;
case KnownColor.HighlightText:
goto IL_12F;
case KnownColor.InactiveBorder:
result = "inactiveborder";
return result;
case KnownColor.InactiveCaption:
goto IL_145;
case KnownColor.InactiveCaptionText:
result = "inactivecaptiontext";
return result;
case KnownColor.Info:
result = "infobackground";
return result;
case KnownColor.InfoText:
result = "infotext";
return result;
case KnownColor.Menu:
goto IL_171;
case KnownColor.MenuText:
result = "menutext";
return result;
case KnownColor.ScrollBar:
result = "scrollbar";
return result;
case KnownColor.Window:
result = "window";
return result;
case KnownColor.WindowFrame:
result = "windowframe";
return result;
case KnownColor.WindowText:
result = "windowtext";
return result;
default:
switch (knownColor)
{
case KnownColor.GradientActiveCaption:
break;
case KnownColor.GradientInactiveCaption:
goto IL_145;
case KnownColor.MenuBar:
goto IL_171;
//.........这里部分代码省略.........
示例14: StoreColor
//Color
/// <summary>
/// Stores the specified Color Object as a setting in the current SettingsKey.
/// </summary>
///
/// <param name="settingName">
/// The name of the setting to store.
/// </param>
///
/// <param name="settingValue">
/// The Color to store for this setting.
/// </param>
///
/// <exception cref="UnauthorizedAccessException">
/// This current SettingsKey is the root SettingsKey or is read-only.
/// </exception>
///
/// <exception cref="ArgumentNullException">
/// The specified 'settingName'
/// is a null reference or an empty string or the specified
/// 'settingValue' is null.
/// </exception>
///
/// <remarks>
/// To retrieve a stored Color from the settings file use the <see cref="GetColor"/> method.
/// <para>
/// Since many settings can be stored in each SettingsKey,
/// the 'settingName' parameter specifies the particular setting you wish to manipulate.
/// </para>
///
/// <para>
/// The key that is opened with the setting being set must have been
/// opened with write access, and not be a read-only key.
/// Once you have been granted write-access to a key, you can change
/// the data associated with any of the settings in that key.
/// </para>
///
/// <para>
/// The parameter 'settingName' is case-sensitive.
/// </para>
///
/// <para>
/// If the specified setting name does not exist in the key,
/// it will be created, and the sepecified settingValue is stored.
/// </para>
/// </remarks>
public void StoreColor(string settingName, Color settingValue)
{
//encode name to a valid XML Name
settingName = XmlConvert.EncodeName(settingName);
#region conditions
// is the settingValue parameter null
if (settingValue.IsEmpty)
{
this.throwParameterNullException("setting");
}
#endregion
if (settingValue.IsKnownColor)
{
StringBuilder str = new StringBuilder(settingValue.ToKnownColor().ToString());
str.Insert(0,RES_KnownColorStartString);
str.Append(RES_ColorEndChar);
StoreSetting(settingName,str.ToString());
}
else
{
StringBuilder str = new StringBuilder(settingValue.ToArgb().ToString());
str.Insert(0,RES_UnKnownColorStartString);
str.Append(RES_ColorEndChar);
StoreSetting(settingName,str.ToString());
}
}
示例15: switch
// Draw a simple button border.
public virtual void DrawBorder
(Graphics graphics, Rectangle bounds,
Color color, ButtonBorderStyle style)
{
Pen pen;
switch(style)
{
case ButtonBorderStyle.Dotted:
{
pen = new Pen(color, 1.0f);
pen.EndCap = LineCap.Square;
pen.DashStyle = DashStyle.Dot;
graphics.DrawRectangle(pen, bounds);
pen.Dispose();
}
break;
case ButtonBorderStyle.Dashed:
{
pen = new Pen(color, 1.0f);
pen.EndCap = LineCap.Square;
pen.DashStyle = DashStyle.Dash;
graphics.DrawRectangle(pen, bounds);
pen.Dispose();
}
break;
case ButtonBorderStyle.Solid:
{
pen = new Pen(color, 1.0f);
pen.EndCap = LineCap.Square;
Rectangle r = new Rectangle(bounds.X,
bounds.Y, bounds.Width - 1, bounds.Height - 1);
graphics.DrawRectangle(pen, r);
pen.Color = ControlPaint.LightLight(color);
graphics.DrawLine(pen, bounds.X + 1,
bounds.Y + bounds.Height - 1,
bounds.X + bounds.Width - 1,
bounds.Y + bounds.Height - 1);
graphics.DrawLine(pen, bounds.X + bounds.Width - 1,
bounds.Y + bounds.Height - 2,
bounds.X + bounds.Width - 1,
bounds.Y + 1);
pen.Dispose();
}
break;
case ButtonBorderStyle.Inset:
{
pen = new Pen(ControlPaint.DarkDark(color), 1.0f);
pen.EndCap = LineCap.Square;
graphics.DrawLine(pen, bounds.X,
bounds.Y + bounds.Height - 1,
bounds.X, bounds.Y);
graphics.DrawLine(pen, bounds.X + 1, bounds.Y,
bounds.X + bounds.Width - 1,
bounds.Y);
pen.Color = ControlPaint.LightLight(color);
graphics.DrawLine(pen, bounds.X + 1,
bounds.Y + bounds.Height - 1,
bounds.X + bounds.Width - 1,
bounds.Y + bounds.Height - 1);
graphics.DrawLine(pen, bounds.X + bounds.Width - 1,
bounds.Y + bounds.Height - 2,
bounds.X + bounds.Width - 1,
bounds.Y + 1);
pen.Color = ControlPaint.Light(color);
graphics.DrawLine(pen, bounds.X + 1,
bounds.Y + bounds.Height - 2,
bounds.X + 1, bounds.Y + 1);
graphics.DrawLine(pen, bounds.X + 2, bounds.Y + 1,
bounds.X + bounds.Width - 2,
bounds.Y + 1);
if(color.ToKnownColor() == KnownColor.Control)
{
pen.Color = SystemColors.ControlLight;
graphics.DrawLine(pen, bounds.X + 1,
bounds.Y + bounds.Height - 2,
bounds.X + bounds.Width - 2,
bounds.Y + bounds.Height - 2);
graphics.DrawLine(pen, bounds.X + bounds.Width - 2,
bounds.Y + bounds.Height - 3,
bounds.X + bounds.Width - 2,
bounds.Y + 1);
}
pen.Dispose();
}
break;
case ButtonBorderStyle.Outset:
{
pen = new Pen(ControlPaint.LightLight(color), 1.0f);
pen.EndCap = LineCap.Square;
graphics.DrawLine(pen, bounds.X,
bounds.Y + bounds.Height - 2,
bounds.X, bounds.Y);
graphics.DrawLine(pen, bounds.X + 1, bounds.Y,
bounds.X + bounds.Width - 2,
bounds.Y);
//.........这里部分代码省略.........