예제 #1
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given integer parameter, into a <code>ARGB</code> instance.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source">Integer value</param>
        /// <param name="destination"><code>ARGB</code> instance</param>
        /// <returns>Could operation been performed.</returns>
        public static bool tryIntToARGB(Int16 source, out ARGB destination)
        {
            bool Result = false;
            destination = null;

            String temp = ukt4dotnet.shared.utilities.Hexadecimal.IntToHex(source);
            Result = tryStringToARGB(temp, out destination);

            return Result;
        }
예제 #2
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given string value into the given <code>ARGB</code> parameter.
        /// The string is expected tobe an hexadecimal equivalent value.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source">String value</param>
        /// <param name="destination"></param>
        /// <returns>Could operation been performed.</returns>
        public static bool tryStringToARGB(String source, out ARGB destination)
        {
            bool Result = false;
            destination = null;

            // first, check we didn't get a null value
            Result = (isValidString(source));
            if (Result)
            {
                destination = new ARGB();
                destination.Alpha = Convert.ToByte(StrUtils.LeftCopyByLength(source, 2), 16);
                destination.Red = Convert.ToByte(StrUtils.MidCopy(source, 2, 2), 16);
                destination.Blue = Convert.ToByte(StrUtils.MidCopy(source, 4, 2), 16);
                destination.Green = Convert.ToByte(StrUtils.RightCopyByLength(source, 2), 16);
            }

            return Result;
        }
예제 #3
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given parameter value into a
        /// string hexadecimal value.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source">ARGB instance</param>
        /// <param name="destination">String result</param>
        /// <returns>Could operation been performed</returns>
        public static bool tryARGBToString(ARGB source, out String destination)
        {
            bool Result = false;
            destination = "";

            // first, check we didn't get a null value
            Result = (source != null);
            if (source != null)
            {
                destination = source.ToString();
            }

            return Result;
        }
예제 #4
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given <code>source</code> parameter, into a <code>ARGB</code> instance.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source"><code>Color</code> instance</param>
        /// <param name="destination"><code>ARGB</code> instance</param>
        /// <returns>Could operation been performed.</returns>
        public static bool tryColorToARGB(Color source, out ARGB destination)
        {
            bool Result = false;
            destination = null;

            Result = (source != null);
            if (Result)
            {
                destination = new ARGB(source);
            }

            return Result;
        }
예제 #5
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given <code>ARGB</code> parameter into an integer.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source"><code>ARGB</code> instance</param>
        /// <param name="destination"></param>
        /// <returns>Could operation been performed.</returns>
        public static bool tryARGBToInt(ARGB source, out Int16 destination)
        {
            bool Result = false;
            destination = 0;

            String temp = "";
            Result = tryARGBToString(source, out temp);
            if (!String.IsNullOrEmpty(temp))
            {
                destination = (Int16)ukt4dotnet.shared.utilities.Hexadecimal.HexToInt(temp);
            }

            return Result;
        }
예제 #6
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given <code>ARGB</code> parameter, into a <code>Color</code> instance.
        /// Does not generates an exception, if operation fails.
        /// Note: This is a <code>static</code> function.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="destination"><code>Color</code> instance</param>
        /// <returns>Could operation been performed.</returns>
        public static bool tryARGBToColor(ARGB source, out Color destination)
        {
            bool Result = false;
            destination = Color.Black;

            Result = (source != null);
            if (Result)
            {
                destination = Color.FromArgb(
                    (int)source.Alpha,
                    (int)source.Red,
                    (int)source.Blue,
                    (int)source.Green
                );
            }

            return Result;
        }
예제 #7
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given parameter value into a
        /// string hexadecimal value.
        /// If operation fails, a <code>InvalidCastException</code> exception is generated.
        /// </summary>
        /// <param name="value"><code>ARGB</code> instance</param>
        /// <returns>String Hexadecimal equivalent.</returns>
        public static String ARGBToString(ARGB value)
        {
            String Result = "";

            if (!tryARGBToString(value, out Result))
            {
                throw new InvalidCastException();
            }

            return Result;
        }
예제 #8
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given <code>ARGB</code> parameter value into an integer equivalent.
        /// If operation fails, a <code>InvalidCastException</code> exception is generated.
        /// </summary>
        /// <param name="value"><code>ARGB</code> instance</param>
        /// <returns>Integer equivalent</returns>
        public static Int16 ARGBToInt(ARGB value)
        {
            Int16 Result = 0;

            if (!tryARGBToInt(value, out Result))
            {
                throw new InvalidCastException();
            }

            return Result;
        }
예제 #9
0
파일: ARGB.cs 프로젝트: umlcat/ukt4dotnet
        /// <summary>
        /// Tries to convert the given <code>ARGB</code> parameter value into a
        /// <code>Color</code> equivalent value.
        /// If operation fails, a <code>InvalidCastException</code> exception is generated.
        /// </summary>
        /// <param name="value"><code>ARGB</code> intasnce.</param>
        /// <returns><code>Color</code> equivalent.</returns>
        public static Color ARGBToColor(ARGB value)
        {
            Color Result = Color.Black;

            if (!tryARGBToColor(value, out Result))
            {
                throw new InvalidCastException();
            }

            return Result;
        }