Example #1
0
        //
        // Converts the number of ions to a unicode subscript value.
        //
        public static string displayIonNumber(int n)
        {
            string           number;
            UnicodeConverter uni = new UnicodeConverter();

            if (n == 1)
            {
                number = "";
            }
            else
            {
                number = uni.convertToSubscript(n).ToString();
            }

            return(number);
        }
Example #2
0
        //
        // Formats the abbreviation of the ion to include subscripts.
        //
        public static string formatIonAbbr(string ionAbbr)
        {
            string           subNum;
            UnicodeConverter uni = new UnicodeConverter();

            for (int x = 0; x < ionAbbr.Length; x++)
            {
                for (int i = 0; i <= 9; i++)
                {
                    if (ionAbbr[x].ToString() == i.ToString())
                    {
                        subNum  = uni.convertToSubscript(i);
                        ionAbbr = ionAbbr.Replace(ionAbbr[x].ToString(), subNum);

                        if (x == ionAbbr.Length - 1)
                        {
                            ionAbbr = "(" + ionAbbr + ")";
                        }
                    }
                }
            }

            return(ionAbbr);
        }