Ejemplo n.º 1
0
        /// <summary>
        /// 指定字符串转换为指定进制的数字形式
        /// </summary>
        /// <param name="str">字符串</param>
        /// <param name="characters">进制格式</param>
        /// <param name="customCharacter">自定义进制字符串</param>
        /// <returns>结果</returns>
        public static long ToNumberLong(this string str, Characters characters = Characters.DECIMAL, string customCharacter = CHARS_PUREUPPERCHAR)
        {
            string DisplayText = characters.DisplayText();

            if (characters == Characters.Custom && !customCharacter.IsNullOrEmpty())
            {
                DisplayText = customCharacter;
            }

            long result = 0;
            int  j      = 0;

            foreach (var ch in new string(str.ToCharArray().Reverse().ToArray()))
            {
                if (!DisplayText.Contains(ch))
                {
                    continue;
                }

                result += DisplayText.IndexOf(ch) * ((long)Math.Pow(DisplayText.Length, j));
                j++;
            }

            return(result);
        }
Ejemplo n.º 2
0
 public void CommaButtonClick()
 {
     if (Operation.result == LastOperationSelected)
     {
         DisplayText           = string.Empty;
         LastOperationSelected = Operation.none;
     }
     if ((DisplayText.Contains(',')) ||
         (0 == DisplayText.Length))
     {
         return;
     }
     DisplayText += ",";
 }
Ejemplo n.º 3
0
 private void btnDot_Click(object sender, RoutedEventArgs e)
 {
     //Check if text is decimal
     if (!DisplayText.Contains("."))
     {
         if (DisplayText.Length != 0)
         {
             DisplayText += ".";
         }
         else
         {
             DisplayText += "0.";
         }
     }
 }