예제 #1
0
        public static HexColor Contrast(HexColor color)
        {
            Color sc  = (Color)color;
            float yiq = ((sc.R * 299) + (sc.G * 587) + (sc.B * 114)) / 1000;

            return((yiq >= 128) ? Black : White);
        }
 public virtual void Add(HexColor color)
 {
     Expect.IsTrue(IsValidHexColor(color.Hex));
     if (!_colorsByName.ContainsKey(color.Name))
     {
         _colorsByName.Add(color.Name, color);
     }
 }
 public void Set(HexColor color)
 {
     Expect.IsTrue(IsValidHexColor(color.Hex));
     if (!_colorsByName.ContainsKey(color.Name))
     {
         _colorsByName.Add(color.Name, color);
     }
     else
     {
         _colorsByName[color.Name] = color;
     }
 }
        public void Set(string colorName, string hexColor)
        {
            HexColor color = new HexColor(colorName, hexColor);

            Set(color);
        }
        /// <summary>
        /// Adds the specified color if one with the same name
        /// has not already been added.
        /// </summary>
        /// <param name="colorName"></param>
        /// <param name="hexColor"></param>
        public void Add(string colorName, string hexColor)
        {
            HexColor color = new HexColor(colorName, hexColor);

            Add(color);
        }