Example #1
0
        /// <summary> Convert a space delimited color tuple string to a color.
        /// <p>
        /// Converts a string value like "255 255 0" to a color constant,
        /// in this case, yellow.
        /// 
        /// </summary>
        /// <param name="key">the name of the property
        /// </param>
        /// <returns> a Color object equivalent to the provided string contents. 
        /// Returns white if the string is null or can't be converted.
        /// </returns>
        //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
        public static System.Drawing.Color getColorProperty(System.Collections.Specialized.NameValueCollection properties, System.Object key)
        {
            System.String string_Renamed = (System.String) properties[(System.String) key];

            if (string_Renamed == null)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                System.Console.Error.WriteLine("WARN: couldn't find color tuplet under '" + key + "'");
                return System.Drawing.Color.White;
            }

            SupportClass.Tokenizer st = new SupportClass.Tokenizer(string_Renamed, " ");
            System.Drawing.Color c;
            try
            {
                c = System.Drawing.Color.FromArgb(System.Int32.Parse(st.NextToken()), System.Int32.Parse(st.NextToken()), System.Int32.Parse(st.NextToken()));
            }
            catch (System.ArgumentOutOfRangeException e)
            {
                c = System.Drawing.Color.White;
                System.Console.Error.WriteLine("WARN: invalid color spec '" + string_Renamed + "' in property file");
            }

            return c;
        }
Example #2
0
        /// <summary> Convert a space delimited color tuple string to a color.
        /// <p>
        /// Converts a string value like "255 255 0" to a color constant,
        /// in this case, yellow.
        ///
        /// </summary>
        /// <param name="key">the name of the property
        /// </param>
        /// <returns> a Color object equivalent to the provided string contents.
        /// Returns white if the string is null or can't be converted.
        /// </returns>
        //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.Properties' and 'System.Collections.Specialized.NameValueCollection' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
        public static System.Drawing.Color getColorProperty(System.Collections.Specialized.NameValueCollection properties, System.Object key)
        {
            System.String string_Renamed = (System.String)properties[(System.String)key];

            if (string_Renamed == null)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                System.Console.Error.WriteLine("WARN: couldn't find color tuplet under '" + key + "'");
                return(System.Drawing.Color.White);
            }

            SupportClass.Tokenizer st = new SupportClass.Tokenizer(string_Renamed, " ");
            System.Drawing.Color   c;
            try
            {
                c = System.Drawing.Color.FromArgb(System.Int32.Parse(st.NextToken()), System.Int32.Parse(st.NextToken()), System.Int32.Parse(st.NextToken()));
            }
            catch (System.ArgumentOutOfRangeException)
            {
                c = System.Drawing.Color.White;
                System.Console.Error.WriteLine("WARN: invalid color spec '" + string_Renamed + "' in property file");
            }
            return(c);
        }