Пример #1
0
        private void ActivateKeepAlive()
        {
            var message = string.Empty;

            if (rdoDeactivateAfter.Checked)
            {
                var minutes  = numDeactivateTimer.Value;
                var interval = (double)minutes * 60 * 1000;

                _deactivateTimer.Interval = interval;
                _deactivateTimer.Start();

                var aliveUntil = DateTime.Now.AddMilliseconds(interval);
                message = string.Format("KeepAlive active until {0}", aliveUntil.ToString("HH:mm:ss"));
            }
            else if (rdoDeactivateAt.Checked)
            {
                var time     = timePicker.Value < DateTime.Now ? timePicker.Value.AddDays(1) : timePicker.Value;
                var timeSpan = time - DateTime.Now;

                _deactivateTimer.Interval = timeSpan.TotalMilliseconds;
                _deactivateTimer.Start();

                message = string.Format("KeepAlive active until {0}", time.ToString("HH:mm:ss"));
            }
            else
            {
                message = "KeepAlive active indefinitely";
            }

            notifyIcon.ShowBalloonTip(10000, _balloonTitle, message, ToolTipIcon.Info);
            SetFormVisibility(false);
            KeepAliveController.Activate();
            _updateRefreshTimer.Start();
        }
Пример #2
0
 private void DeactivateKeepAlive()
 {
     _updateRefreshTimer.Stop();
     _deactivateTimer.Stop();
     notifyIcon.ShowBalloonTip(10000, _balloonTitle, "KeepAlive deactivated", ToolTipIcon.Info);
     KeepAliveController.Deactivate();
 }
Пример #3
0
 private static void Application_ApplicationExit(object sender, EventArgs e)
 {
     KeepAliveController.Deactivate();
 }
Пример #4
0
 private void _updateRefreshTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     KeepAliveController.Activate();
 }