コード例 #1
0
 protected void TryToAddPoint(CalculatorCore core)
 {
     if (!core.TextBoxValue.Contains("."))
     {
         core.TextBoxValue += ".";
     }
 }
コード例 #2
0
 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";
     }
 }
コード例 #3
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);
 }
コード例 #6
0
 protected void ResetAll(CalculatorCore core)
 {
     core.TextBoxValue = "0";
     core.LabelValue   = "";
 }
コード例 #7
0
 protected void ResetTextBox(CalculatorCore core)
 {
     core.TextBoxValue = "0";
 }
コード例 #8
0
 protected void AssignEnteredValueToTextBox(string value, CalculatorCore core)
 {
     core.TextBoxValue = value;
 }
コード例 #9
0
 protected void SetState(CalculatorCore core, CalculatorCoreState state)
 {
     core.currentState = state;
 }
コード例 #10
0
 /// <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);
コード例 #11
0
 /// <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);
コード例 #12
0
 /// <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);
コード例 #13
0
 /// <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);
コード例 #14
0
 /// <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);
コード例 #15
0
 /// <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);
コード例 #16
0
 protected void NegateTextBox(CalculatorCore core)
 {
     if (core.TextBoxValue[^ 1] == '.')