Exemplo n.º 1
0
        /// <summary>
        ///     Print number to TextAns TextBox in proper format.
        /// </summary>
        /// <param name="number">Pressed number in string format.</param>
        /// <returns>True, if number was printed, false otherwise.</returns>
        public bool PrintNumber(string number)
        {
            // remove "NumPad" from converted string number if NumPad numbers are used
            if (number.Contains("NumPad"))
            {
                number = number.Remove(0, 6);
            }

            // if result is in log, then clear log
            if (this.ResultInLog)
            {
                this.ClearLog();
                MathProcessor.ClearResult();
            }
            this.ResultInLog = false;

            // max length was reached
            if (this.textAns.Text.Length > TextAnsMaxLength && !this.IsAnswer)
            {
                return(false);
            }

            if (this.textAns.Text == "0" || this.IsAnswer || this.IsMemoryOperator)
            {
                this.textAns.Text = number;
            }
            else
            {
                this.textAns.Text += number;
            }

            this.textAns.Text = this.FormatNumericValue(this.textAns.Text);
            this.FixAnsFontSize();
            this.IsAnswer                  = false;
            this.IsMemoryOperator          = false;
            MathProcessor.WaitingForNumber = false;

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     MainWindow construct.
 /// </summary>
 public MainWindow()
 {
     this.InitializeComponent();
     this.outputProcessor = new OutputProcessor(this.TextAns, this.TextLog);
     this.mathProcessor   = new MathProcessor(this.outputProcessor);
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Process C button click.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonC_Click(object sender, RoutedEventArgs e)
 {
     this.outputProcessor.ClearAns();
     this.outputProcessor.ClearLog();
     MathProcessor.ClearResult();
 }