Beispiel #1
0
        /// <summary>
        /// To find the percentage, if other additional operations are applied
        /// </summary>
        /// <remarks>
        /// <para>For operations that do not have a character notation in the expression</para>
        /// <para>In the case of the " % " operation, the change is that the last number or sequence of operations is replaced with a specific percentage of the rest of the expression</para>
        /// </remarks>
        /// <returns>
        /// The string of the current expression with the percentage found
        /// </returns>
        private string ChangeTheSetOfRecentAdditionalOperations(string currentExpression)
        {
            int           pos;
            string        copiedFragment;
            StringBuilder stringBuilderCurExpr = CurrentExpressionChange(currentExpression, out pos, out copiedFragment);
            Calculate     calculate            = new Calculate();
            double        number;

            if (Common.MathSignCheck(currentExpression))
            {
                number = calculate.CalcPercentage(copiedFragment, stringBuilderCurExpr.ToString().Remove(stringBuilderCurExpr.Length - 3, 3));
            }
            else
            {
                number = calculate.CalcPercentage(copiedFragment, stringBuilderCurExpr.ToString());
            }

            if (NumberStandardization.NumberCheck(number.ToString()))
            {
                stringBuilderCurExpr.Insert(pos, number.ToString());
            }
            else
            {
                stringBuilderCurExpr.Insert(pos, ((int)Digits.Zero).ToString());
            }

            return(stringBuilderCurExpr.ToString());
        }
Beispiel #2
0
 /// <summary>
 /// Clears the last digit entered in the current number
 /// </summary>
 public void Backspace()
 {
     if (buttonsState.EqualBtnPressed)
     {
         if (NumberStandardization.NumberCheck(currentData.CurrentNumber))
         {
             currentData.CurrentExpression = ClearExpression(currentData.CurrentExpression);
             buttonsState.NumberPadBtnPressed_Change(true);
             buttonsState.AdditionalOperationBtnPressed_Change(false);
             buttonsState.EqualBtnPressed_Change(false);
         }
         else
         {
             ClearAll();
         }
     }
     else
     {
         currentData.CurrentNumber = Backspace(currentData.CurrentNumber);
     }
 }