private void btnEquals(object sender, RoutedEventArgs e) { if (!Double.IsNaN(CalculatorUtil.V1) && !CalculatorUtil.Op.Equals('\0') && !txtResult.Equals("")) { CalculatorUtil.Valued = true; CalculatorUtil.V2 = Double.Parse(txtResult.Text); CalculatorUtil.V1 = CalculatorUtil.Operation(CalculatorUtil.V1, CalculatorUtil.V2, CalculatorUtil.Op); txtResult.Text = CalculatorUtil.V1.ToString(); } }
private void btnOp(object sender, RoutedEventArgs e) { //if (txtResult.Text.Equals("")) { return; } if (Double.IsNaN(CalculatorUtil.V1) && Double.IsNaN(CalculatorUtil.V2) && !CalculatorUtil.Valued) { CalculatorUtil.V1 = Double.Parse(txtResult.Text.ToString()); txtResult.Text = ""; } else if (!Double.IsNaN(CalculatorUtil.V1) && !CalculatorUtil.Valued) { CalculatorUtil.V2 = Double.Parse(txtResult.Text.ToString()); CalculatorUtil.Valued = true; CalculatorUtil.V1 = CalculatorUtil.Operation(CalculatorUtil.V1, CalculatorUtil.V2, CalculatorUtil.Op); txtResult.Text = CalculatorUtil.V1.ToString(); } Button op = (Button)sender; CalculatorUtil.Op = Char.Parse(op.Content.ToString()); }