private void BtnDivide_Click(object sender, RoutedEventArgs e) { string trigger = "BtnDivide"; sb.Clear(); if ((subInput.HasValue == true && mainInput.HasValue == true)) { this.Execute(subInput.Value, mainInput.Value); BinaryOperations bin = new BinaryOperations(); SubInput.Text = bin.OperatorReplacer(SubInput.Text, trigger); } else if (subInput == null) { subInput = int.Parse(MainInput.Text); Operator.Text = OperatorConstants.DivideSymbol.ToString(); // SubInput.Text += sb.Append(subInput).ToString() + Operator.Text; if (mainInput != null && subInput != null) { this.Execute(subInput.Value, mainInput.Value); } } else if (subInput != null && mainInput == null) { mainInput = int.Parse(MainInput.Text); SubInput.Text += sb.Append(mainInput).ToString() + Operator.Text; this.Execute(subInput.Value, mainInput.Value); Operator.Text = OperatorConstants.DivideSymbol.ToString();// sb.Clear(); /* Replace operator symbol*/ int subLen = SubInput.Text.Length - 1; if (SubInput.Text != String.Empty && SubInput.Text.Substring(subLen, 1) != OperatorConstants.DivideSymbol.ToString()) // { BinaryOperations bin = new BinaryOperations(); SubInput.Text = bin.OperatorReplacer(SubInput.Text, trigger); } } else { MessageBox.Show("An Error occured", "Warning"); } isClicked = true; equalTrigger = false; }