using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace DevComponents.DotNetBar.Layout.Design
{
    internal static class ColorHelpers
    {
        /// 
        /// Converts hex string to Color type.
        /// 
        /// Hexadecimal color representation.
        /// Reference to Color object.
        public static Color GetColor(string rgbHex)
        {
            if (string.IsNullOrEmpty(rgbHex))
                return Color.Empty;
            if (rgbHex.Length == 8)
                return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
                Convert.ToInt32(rgbHex.Substring(2, 2), 16),
                Convert.ToInt32(rgbHex.Substring(4, 2), 16),
                Convert.ToInt32(rgbHex.Substring(6, 2), 16));
            return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
                Convert.ToInt32(rgbHex.Substring(2, 2), 16),
                Convert.ToInt32(rgbHex.Substring(4, 2), 16));
        }
        /// 
        /// Converts hex string to Color type.
        /// 
        /// Color representation as 32-bit RGB value.
        /// Reference to Color object.
        public static Color GetColor(int rgb)
        {
            if (rgb == -1) return Color.Empty;
            return Color.FromArgb((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
        }
        /// 
        /// Converts hex string to Color type.
        /// 
        /// Color representation as 32-bit RGB value.
        /// Reference to Color object.
        public static Color GetColor(int alpha, int rgb)
        {
            if (rgb == -1) return Color.Empty;
            return Color.FromArgb(alpha, (rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
        }
    }
}