Ejemplo n.º 1
0
        ///Constructor that connects the reference of an object of MathEngine
        ///to the methods in this class
        public Logger(MathEngine pMathEngine)
        {
            math = pMathEngine;

            math.NegativeNumber += negativeNumber;
            math.C_Pressed += cancelled;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Define startvalues of the form
        /// </summary>
        private void initializeGUI()
        {

            mathEngine = new MathEngine();

            Logger logg = new Logger(mathEngine);

            previousCalculations = new List<History>();

            txtEnterdNumber.Text = ""; ///Startvalue

            firstNumberEntered = false;
            resultInTextbox = false;

            loadState(); ///Load previous instance of the calculator
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create SaveFile with data from the Form
 /// </summary>
 public SaveFile(MathEngine mathEngine, double oldNumber, double newNumber,
     bool firstNumberEntered, bool resultInTextbox, bool calcButtonClicked,
     string calculationSign, string currentCalculation, string currentInput,
     List<History> previousCalculations)
 {
     Math = mathEngine;
     OldNumber = oldNumber;
     NewNumber = newNumber;
     FirstNumberEntered = firstNumberEntered;
     ResultInTextbox = resultInTextbox;
     CalcButtonClicked = calcButtonClicked;
     CalculationSign = calculationSign;
     CurrentCalculation = currentCalculation;
     CurrentInput = currentInput;
     PreviousCalculations = previousCalculations;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Load the state.bin with data from previous runs
        /// of the program, if there is one
        /// </summary>
        private void loadState()
        {
            SaveLoad tmpLoader = new SaveLoad();
            SaveFile tmpLoadFile = tmpLoader.LoadState();

            ///If the tmpFile.Math == null, there was no successfull load
            ///of the bin-file
            if (tmpLoadFile.Math != null)
            {

                ///Load all fields with data from tmpFile
                mathEngine = tmpLoadFile.Math;

                oldNumber = tmpLoadFile.OldNumber;
                newNumber = tmpLoadFile.NewNumber;

                firstNumberEntered = tmpLoadFile.FirstNumberEntered;
                resultInTextbox = tmpLoadFile.ResultInTextbox;
                calcButtonClicked = tmpLoadFile.CalcButtonClicked;

                calculationSign = tmpLoadFile.CalculationSign;
                currentCalculation = tmpLoadFile.CurrentCalculation;
                currentInput = tmpLoadFile.CurrentInput;

                previousCalculations = tmpLoadFile.PreviousCalculations;

                ///Put the history to the listBox
                foreach(History tmpHistory in previousCalculations)
                {
                    lstHistory.Items.Add(tmpHistory);
                }

                ///Update
                updateCalculationTextBox();
                updateInputTextBox();
            }

        }