protected void TryToAddPoint(CalculatorCore core)
 {
     if (!core.TextBoxValue.Contains("."))
     {
         core.TextBoxValue += ".";
     }
 }
 protected void RemoveLastDigit(CalculatorCore core)
 {
     core.TextBoxValue = core.TextBoxValue.Remove(core.TextBoxValue.Length - 1);
     if (!decimal.TryParse(core.TextBoxValue, NumberStyles.Any, core.Culture, out _))
     {
         core.TextBoxValue = "0";
     }
 }
 protected void AddValueToEndOfTextBox(string input, CalculatorCore core)
 {
     if (core.TextBoxValue == "0")
     {
         core.TextBoxValue = input;
     }
     else
     {
         if (core.TextBoxValue.Length < TextBoxCapacity)
         {
             core.TextBoxValue += input;
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalculatorForm"/> class.
 /// </summary>
 public CalculatorForm()
 {
     InitializeComponent();
     core = new CalculatorCore();
 }
Пример #5
0
 public MainWindow()
 {
     InitializeComponent();
     CalculatorCore.Calculate(this);
 }
 protected void ResetAll(CalculatorCore core)
 {
     core.TextBoxValue = "0";
     core.LabelValue   = "";
 }
 protected void ResetTextBox(CalculatorCore core)
 {
     core.TextBoxValue = "0";
 }
 protected void AssignEnteredValueToTextBox(string value, CalculatorCore core)
 {
     core.TextBoxValue = value;
 }
 protected void SetState(CalculatorCore core, CalculatorCoreState state)
 {
     core.currentState = state;
 }
 /// <summary>
 /// Simulate pressing negate button for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressNegateButton(CalculatorCore core);
 /// <summary>
 /// Simulate pressing equal button for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressEqualButton(CalculatorCore core);
 /// <summary>
 /// Simulate pressing point button for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressButtonPoint(CalculatorCore core);
 /// <summary>
 /// Simulate pressing button with specified binary operation for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="binaryOperation">Specified binary operation.</param>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressBinaryOperationButton(BinaryOperations binaryOperation, CalculatorCore core);
 /// <summary>
 /// Simulate pressing button backspace for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressButtonBack(CalculatorCore core);
 /// <summary>
 /// Simulate pressing button with specified digit for target instance of the <see cref="CalculatorCore"/> class.
 /// </summary>
 /// <param name="digit">Specified digit.</param>
 /// <param name="core">Target instance of <see cref="CalculatorCore"/> class.</param>
 public abstract void PressButtonDigits(byte digit, CalculatorCore core);
 protected void NegateTextBox(CalculatorCore core)
 {
     if (core.TextBoxValue[^ 1] == '.')