Exemple #1
0
        private void RefreshElapsed()
        {
            if (goalDateInt != 0)
            {
                // Call GuardTime
                GuardTime guard = new GuardTime();

                // Tell GuardTime to give us the DateTime of the last event and set that to our lastEvent dateTime.
                lastEvent = guard.EpochToDateTime(eventDateInt);

                // Create a new timer
                Timer timeSince = new Timer();

                // Set the Interval
                timeSince.Interval = 100;

                // Set the event handler
                timeSince.Tick += new EventHandler(timeSince_Tick);

                // Declare a DateTime of now
                DateTime now = DateTime.Now;

                // Set the timespan equal to the time now, minus the time of the last event.
                TimeSpan ts = now - lastEvent;

                timeSinceLabel.Text = ts.ToString("");
                timeSince.Start();
            }
        }
Exemple #2
0
        private void RefreshCountdown()
        {
            if (goalDateInt != 0)
            {
                // Call GuardTime
                GuardTime guard = new GuardTime();

                // Tell GuardTime to convert the epoch time into our goal date time object declared at the start of the MainWindow.
                goal = guard.EpochToDateTime(goalDateInt);

                // Create a new timer
                Timer countDown = new Timer();

                // Set the Interval
                countDown.Interval = 100;

                // Set the event handler
                countDown.Tick += new EventHandler(countDown_Tick);

                TimeSpan ts = goal.Subtract(DateTime.Now);


                timeLeftLabel.Text = ts.ToString("");
                countDown.Start();
            }
        }