Exemplo n.º 1
0
        /// <summary>
        /// Define action that occurs each timer tick.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void windowUpdateTimer_Tick(object sender, EventArgs e)
        {
            if (active > -1)
            {
                currentDiff = StaticUtility.SubTime(DateTime.Now, activeTimeStamp);
                DISPLAY.disUpd1Row(active, StaticUtility.AddTime(activeTimeArray[active], currentDiff));

                TimeSpan newTotal = StaticUtility.AddTime(StaticUtility.SubTime(StaticUtility.AddTime(tempTotal, currentDiff), activeTimeArray[active]), activeTimeArray[active]);
                DISPLAY.disUpdTotal(newTotal);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Changes the running timer or current action to a different action.
        /// </summary>
        /// <param name="newActive">Action to change to.</param>
        public void changeActive(int newActive)
        {
            if (active == newActive)
            {
                return;                      //nothing changed
            }
            currentDiff = StaticUtility.SubTime(DateTime.Now, activeTimeStamp);

            if (active > -1) // At button press something was running. Turn the active timer off and write to file.
            {
                DISPLAY.disSetRunTimer(active, false);
                activeTimeArray[active] = StaticUtility.AddTime(currentDiff, activeTimeArray[active]);
                DISPLAY.disUpd1Row(active, activeTimeArray[active]);
                FILEMECH.writeRow(DateTime.Now, activeTimeStamp, currentDiff, "[TIME]", active, stopElapsed);
            }

            if (active == -1) // system was stopped
            {
                stopElapsed = StaticUtility.AddTime(currentDiff, stopElapsed);
                FILEMECH.writeRow(DateTime.Now, activeTimeStamp, currentDiff, "[STOP]", active, stopElapsed);
                DISPLAY.disSetStopped(false);
            }

            // Update the total to window
            DISPLAY.disUpdTotal(engCalcArrayTotal());

            activeTimeStamp = DateTime.Now;
            active          = newActive;

            if (newActive > -1) // Thing to go to is a timer
            {
                tempTotal = engCalcArrayTotal();
                DISPLAY.disUpd1Row(active, activeTimeArray[active]);
                DISPLAY.disSetRunTimer(active, true);
                windowUpdateTimer.Start();
            }

            if (newActive == -1) // Thing to go to is stopped
            {
                DISPLAY.disSetStopped(true);
                windowUpdateTimer.Stop();
            }
        }