private void Btn_enter_Click(object sender, RoutedEventArgs e) { string originEquation = resultScreen.Text; string[] splits = currentEquation.Split(' '); // 일반적인 피연산자1 + 연산자 + 피연산자2 수식 if (currentNumber.Length != 0) { currentEquation += currentNumber + manatissa; } // =만 계속 입력하는 경우 else if (currentNumber.Length == 0 && currentEquation.Length == 0) { currentEquation = calculationScreen.Text + priorOperation; } // 마지막 피연산자가 negate인 경우 else if (negateNumber.Length != 0) { priorOperation = ' ' + splits[splits.Length - 2] + ' ' + negateNumber; } // 피연산자1 + 연산자 수식인 경우 else { currentEquation += calculationScreen.Text; } // 연산자 + 피연산자2 부분을 저장해둠 if (splits.Length - 2 >= 0 && negateNumber.Length == 0 && !priorOperation.Contains("negate")) { priorOperation = ' ' + splits[splits.Length - 2] + ' ' + calculationScreen.Text; } // 0으로 나누는 수식이 있을 경우 if (IsDivideByZero()) { Btn_cancel_all_Click(sender, e); DisableOperationButtons(); calculationScreen.Text = "0으로 못 나눔"; } else { // 연산 결과 반환 double result = calculation.ReturnResult(currentEquation); calculationScreen.Text = result.ToString(); // 연산 결과 길이가 길면 텍스트 크기를 조절한다. int increaseRate = outprocessor.DeleteComma(calculationScreen.Text).Length - 12; if (increaseRate >= 1) { calculationScreen.FontSize = Constant.BASIC_FONT_SIZE - (4.3 - increaseRate * 0.3) * increaseRate; } // 중간 연산일 경우에는 초기화하지 않음 if (((Button)sender).Content.Equals("=")) { currentNumber = ""; resultScreen.Text = ""; currentEquation = ""; manatissa = ""; floatState = false; negateNumber = ""; } else { currentEquation = originEquation; } } }