本文整理汇总了C#中KnownColor.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# KnownColor.GetType方法的具体用法?C# KnownColor.GetType怎么用?C# KnownColor.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KnownColor
的用法示例。
在下文中一共展示了KnownColor.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
KnownColor enumColor = new KnownColor();
Array Colors = Enum.GetValues(enumColor.GetType());
ArrayList ALColor = new ArrayList();
Color knownColor;
string hexColor;
ListItem item;
try
{
foreach (object clr in Colors)
{
if (!Color.FromKnownColor((KnownColor)clr).IsSystemColor)
{
knownColor = ColorTranslator.FromHtml(clr.ToString());
hexColor = String.Format("{0:X2}{1:X2}{2:X2}", knownColor.R, knownColor.G, knownColor.B);
item = new ListItem(clr.ToString(), hexColor);
item.Attributes.Add("style", "color:#" + hexColor);
drpLstColorCodes.Items.Add(item);
ALColor.Add(clr.ToString());
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
示例2: GetColorCodes
public static List<string> GetColorCodes()
{
KnownColor enumColor = new KnownColor();
Array Colors = Enum.GetValues(enumColor.GetType());
Color knownColor;
string hexColor;
List<string> colorCodes = null;
try
{
colorCodes = new List<string>();
foreach (object clr in Colors)
{
if (!Color.FromKnownColor((KnownColor)clr).IsSystemColor)
{
knownColor = ColorTranslator.FromHtml(clr.ToString());
hexColor = String.Format("{0:X2}{1:X2}{2:X2}", knownColor.R, knownColor.G, knownColor.B);
colorCodes.Add(hexColor);
}
}
}
catch (Exception ex)
{
throw new Exception("Error in ColorCodeHelper.GetColorCodes:" + ex.Message);
}
return colorCodes;
}