void Result(string msg, bool isInput) { if (isInput) { isPoint = true; calcState = CalcState.Result; PerformCalculation(); operation = ""; changeTextDelegate.Invoke(resultNumber); } else { if (Rules.IsOperation(msg)) { Operation(msg, true); } else if (Rules.IsNonZeroDigit(msg)) { tempNumber = ""; resultNumber = ""; changeTextDelegate.Invoke(tempNumber); AccumulateDigits(msg, true); } else if (Rules.IsResult(msg)) { Result(msg, true); } else if (Rules.IsQuickOperation(msg)) { QuickOperation(msg, true); } } }
void AccumulateDigits(string msg, bool isInput) { if (isInput) { calcState = CalcState.AccumulateDigits; tempNumber += msg; changeTextDelegate.Invoke(tempNumber); } else { if (Rules.IsDigit(msg)) { AccumulateDigits(msg, true); } else if (Rules.IsOperation(msg)) { Operation(msg, true); } else if (Rules.IsResult(msg)) { Result(msg, true); } else if (Rules.IsQuickOperation(msg)) { QuickOperation(msg, true); } else if (Rules.IsPoint(msg) && isPoint) { isPoint = false; AccumulateDigits(msg, true); } } }
void QuickOperation(string msg, bool isInput) { if (isInput) { if (resultNumber != "") { tempNumber = resultNumber; resultNumber = ""; } isPoint = true; calcState = CalcState.QuickOperation; operation = msg; QuickCalulation(); changeTextDelegate(tempNumber); } else { if (Rules.IsNonZeroDigit(msg)) { tempNumber = ""; resultNumber = ""; changeTextDelegate.Invoke(tempNumber); AccumulateDigits(msg, true); } else if (Rules.IsOperation(msg)) { Operation(msg, true); } else if (Rules.IsQuickOperation(msg)) { QuickOperation(msg, true); } } }