本文整理汇总了C#中KnownColor.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# KnownColor.ToString方法的具体用法?C# KnownColor.ToString怎么用?C# KnownColor.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KnownColor
的用法示例。
在下文中一共展示了KnownColor.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromKnownName
/// <summary>
/// 根据颜色名获得对应的笔刷
/// </summary>
/// <param name="colorName"></param>
/// <returns></returns>
public static Brush FromKnownName(KnownColor colorName)
{
Brush brush;
if (!_brushes.TryGetValue(colorName, out brush))
{
lock (_lockKey)
{
if (!_brushes.TryGetValue(colorName, out brush))
{
var type = typeof (Brushes);
var p = type.GetProperty(colorName.ToString(), BindingFlags.Static | BindingFlags.Public);
if (p != null)
{
brush = (Brush)p.GetValue(null, null);
}
_brushes.Add(colorName, brush);
}
}
}
return brush;
}
示例2: FromKnownColor
/// <include file='doc\Color.uex' path='docs/doc[@for="Color.FromKnownColor"]/*' />
/// <devdoc>
/// <para>
/// Creates a <see cref='System.Drawing.Color'/> from the specified <see cref='System.Drawing.KnownColor'/> .
/// </para>
/// </devdoc>
public static Color FromKnownColor(KnownColor color) {
if( !ClientUtils.IsEnumValid( color, unchecked((int) color), (int) KnownColor.ActiveBorder, (int) KnownColor.MenuHighlight ) ) {
return Color.FromName(color.ToString());
}
return new Color(color);
}
示例3: FromKnownColor
public static Color FromKnownColor (KnownColor kc)
{
Color c;
short n = (short)kc;
if ((n <= 0) || (n >= ArgbValues.Length)) {
// This is what it returns!
c = Color.FromArgb (0, 0, 0, 0);
#if ONLY_1_1
c.name = kc.ToString ();
#endif
c.state |= (short) Color.ColorType.Named;
} else {
c = new Color ();
c.state = (short) (Color.ColorType.ARGB | Color.ColorType.Known | Color.ColorType.Named);
if ((n < 27) || (n > 169))
c.state |= (short) Color.ColorType.System;
c.Value = ArgbValues [n];
#if ONLY_1_1
c.name = GetName (n);
#endif
}
c.knownColor = n;
return c;
}
示例4: FromKnownColor
public static Color FromKnownColor(KnownColor color)
{
var value = (int)color;
if (value < (int)KnownColor.ActiveBorder || value > (int)KnownColor.MenuHighlight)
{
return Color.FromName(color.ToString());
}
return new Color(color);
}
示例5: DisplayText
public void DisplayText(string txt, KnownColor col = KnownColor.Black, bool force= false)
{
if (DisableLog_checkBox.Checked && !force)
{
return;
}
// intermediate step to get the invoke... work with calls with one or two parameters
AppCol = Color.FromName(col.ToString());
DisplayTxt(txt);
}
示例6: Compare
private void Compare (KnownColor kc, GetSysColorIndex index)
{
// we get BGR than needs to be converted into ARGB
Color sc = ColorTranslator.FromWin32 ((int)GDIPlus.Win32GetSysColor (index));
Assert.AreEqual (Color.FromKnownColor (kc).ToArgb (), sc.ToArgb (), kc.ToString ());
}
示例7: FromKnownColor
public static Color FromKnownColor(KnownColor c)
{
if (c < KnownColor.ActiveBorder || c > KnownColor.MenuHighlight) {
// This is what it returns!
Color d = new Color(0, 0, 0, 0);
d.myname = c.ToString();
d.colorType |= ColorType.Named;
d.knownColor = c;
return d;
}
object color = typeof(Colors).InvokeMember(c.ToString(), System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.GetProperty| System.Reflection.BindingFlags.Public, null, null, null);
return (Color)color;
}
示例8: FromKnownColor
public static Color FromKnownColor (KnownColor kc) {
int n = (int) kc;
if ((n <= 0) || (n >= Values.Length)) {
// This is what it returns!
Color c = Color.FromArgb (0, 0, 0, 0);
c.name = kc.ToString ();
c.state |= (short) Color.ColorType.Named;
c.knownColor = (short) kc;
return c;
}
return Values [n];
}
示例9: FromKnownColor
/// <summary>Creates a <see cref="T:System.Drawing.Color" /> structure from the specified predefined color.</summary>
/// <returns>The <see cref="T:System.Drawing.Color" /> that this method creates.</returns>
/// <param name="color">An element of the <see cref="T:System.Drawing.KnownColor" /> enumeration. </param>
/// <filterpriority>1</filterpriority>
public static Color FromKnownColor(KnownColor color)
{
if (!(color >= (KnownColor)1 && color <= (KnownColor)174))
{
return Color.FromName(color.ToString());
}
return new Color(color);
}
示例10: FromKnownColor
public static Color FromKnownColor(KnownColor color)
{
if (!System.Drawing.ClientUtils.IsEnumValid(color, (int) color, 1, 0xae))
{
return FromName(color.ToString());
}
return new Color(color);
}