Ejemplo n.º 1
0
        /// <summary>
        /// Hexa 값에 해당하는 VB Color 값을 리턴함.
        /// </summary>
        public static int GetVbColorByHexa(string Hexa)
        {
            Hexa = NormalizeHexa(Hexa);
            if (Hexa == "")
            {
                return(0);
            }

            int R = CMath.Dec(Hexa.Substring(0, 2));

            if ((R < 0) || (R > 255))
            {
                return(0);
            }

            int G = CMath.Dec(Hexa.Substring(2, 2));

            if ((G < 0) || (G > 255))
            {
                return(0);
            }

            int B = CMath.Dec(Hexa.Substring(4, 2));

            if ((G < 0) || (G > 255))
            {
                return(0);
            }

            return(GetVbRGB(R, G, B));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Hexa 값에 해당하는 Color.Blue, Color.Red 등의 Color structure를 리턴함.
        /// </summary>
        public static Color GetColorByHexa(string Hexa)
        {
            Hexa = NormalizeHexa(Hexa);
            if (string.IsNullOrEmpty(Hexa))
            {
                throw new Exception(Hexa + "는(은) 없는 색입니다.");
            }

            int R = CMath.Dec(Hexa.Substring(0, 2));

            if ((R < 0) || (R > 255))
            {
                throw new Exception(Hexa + "는(은) 없는 색입니다.");
            }

            int G = CMath.Dec(Hexa.Substring(2, 2));

            if ((G < 0) || (G > 255))
            {
                throw new Exception(Hexa + "는(은) 없는 색입니다.");
            }

            int B = CMath.Dec(Hexa.Substring(4, 2));

            if ((G < 0) || (G > 255))
            {
                throw new Exception(Hexa + "는(은) 없는 색입니다.");
            }

            return(Color.FromArgb(R, G, B));
        }