本文整理汇总了C#中Color.ToKnownColor方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToKnownColor方法的具体用法?C# Color.ToKnownColor怎么用?C# Color.ToKnownColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ToKnownColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromSystemColor
// Get a brush for a system color.
public static Brush FromSystemColor(Color c)
{
if(c.IsSystemColor)
{
return GetOrCreateBrush(c.ToKnownColor());
}
else
{
throw new ArgumentException(S._("Arg_NotSystemColor"));
}
}
示例2: ToOle
// Convert a "Color" value into an OLE color value.
public static int ToOle(Color color)
{
if(color.IsKnownColor)
{
int value = (int)(color.ToKnownColor());
if(value >= 1 && value <= oleSystemColors.Length)
{
return (int)(oleSystemColors[value - 1]);
}
}
return ToWin32(color);
}
示例3: ToHtml
// Convert a "Color" value into a HTML color name.
public static String ToHtml(Color color)
{
String ret = "";
int value = (int)(color.ToKnownColor());
if(color.IsKnownColor)//(value>=1) && (value<=167))
{
//int value = (int)(color.ToKnownColor());
if(value >= 1 && value <= oleSystemColors.Length)
{
switch(value)
{
case (int)KnownColor.ActiveCaptionText:
ret = "captiontext";
break;
case (int)KnownColor.Control:
ret = "buttonface";
break;
case (int)KnownColor.ControlDark:
ret = "buttonshadow";
break;
case (int)KnownColor.ControlDarkDark:
ret = "threeddarkshadow";
break;
case (int)KnownColor.ControlLight:
ret = "buttonface";
break;
case (int)KnownColor.ControlLightLight:
ret = "buttonhighlight";
break;
case (int)KnownColor.ControlText:
ret = "buttontext";
break;
case (int)KnownColor.Desktop:
ret = "background";
break;
case (int)KnownColor.HotTrack:
ret = "highlight";
break;
case (int)KnownColor.Info:
ret = "infobackground";
break;
//case (int)KnownColor.LightGray: ret = "LightGrey";break; // -> MS BUG.
// This last case cause a compare error but the good result is
// LightGray. So, never replace LightGray by LightGrey.
default:
ret = color.Name.ToLower();
break;
}
}
else
{
ret = color.Name;
}
}
else if(color.Name != "0")
{
ret = "#" + color.Name.Substring(2).ToUpper();
/// GET R,G,B -> Format to hexa RRGGBB prepend '#'
}
return ret;
}