Exemplo n.º 1
0
        private void IdleDetectionCheck(object sender, ElapsedEventArgs e)
        {
            if (!modelHelpers.Gallifrey.Settings.AppSettings.TrackIdleTime || !modelHelpers.Gallifrey.IsInitialised)
            {
                return;
            }

            if (machineLocked)
            {
                machineIdle = false;
                return;
            }

            var idleTimeInfo = IdleTimeDetector.GetIdleTimeInfo();

            if (idleTimeInfo.IdleTime.TotalMilliseconds >= modelHelpers.Gallifrey.Settings.AppSettings.IdleTimeThresholdMilliseconds && !machineIdle)
            {
                machineIdle = true;
                modelHelpers.Gallifrey.StartLockTimer(idleTimeInfo.IdleTime);
            }
            else if (idleTimeInfo.IdleTime.TotalMilliseconds < modelHelpers.Gallifrey.Settings.AppSettings.IdleTimeThresholdMilliseconds && machineIdle)
            {
                machineIdle = false;
                Dispatcher.Invoke(() => StopLockTimer(modelHelpers.Gallifrey.Settings.AppSettings.IdleTimeThresholdMilliseconds));
            }
        }
Exemplo n.º 2
0
        private void IdleTimer_Tick(object sender, EventArgs e)
        {
            var idleTime = IdleTimeDetector.GetIdleTimeInfo();

            if (idleTime.IdleTime.TotalMinutes >= 20)
            {
                MainWindow mainWindow = new MainWindow();
                Close();
                mainWindow.Show();
            }
        }
Exemplo n.º 3
0
        private void InactiveTimerOnElapsed(object sender, ElapsedEventArgs e)
        {
            var idleLastInputTime = IdleTimeDetector.GetIdleTimeInfo().LastInputTime;

            TryUpdateLastActivityTime(idleLastInputTime);

            if (DateTime.Now - LastActivityTime > _settings.InactiveModeTime)
            {
                if (IsActiveNow)
                {
                    UpdateActiveStatus(false);
                    OnStateChangedToInactive?.Invoke();
                }
            }
        }
 private void SetIdleWindow()
 {
     Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(5))
     .Subscribe(x =>
     {
         var idle = IdleTimeDetector.GetIdleTimeInfo();
         if (idle.IdleTime.TotalSeconds > SettingsData.Client.TotalSecondsToLogOut)
         {
             if (DictionaryViews != null && CurrentView != DictionaryViews[StatusScreen.Login])
             {
                 ChangeCurrentView(StatusScreen.Login, false);
             }
         }
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Monitors the idle time
 /// </summary>
 public static void MonitorIdleTime()
 {
     while (true)
     {
         var idleTime = IdleTimeDetector.GetIdleTimeInfo();
         if (idleTime.IdleTime.TotalMinutes >= idleThresholdMinutes)
         {
             isIdle = true;
         }
         else
         {
             isIdle = false;
         }
         Thread.Sleep(2000);
     }
 }
Exemplo n.º 6
0
        private Task PerformSaveOnIdle()
        {
            var idleTime = IdleTimeDetector.GetIdleTimeInfo();

            var isUserInactive = idleTime >= this.Configuration.InactivityPeriod;
            var isFileSaved    = DateTime.Now - lastSaveDateTime < idleTime;

            if (isUserInactive && !isFileSaved && !this.IsPaused)
            {
                this.lastSaveDateTime = DateTime.Now;
                return(this.fileManager.SaveAllDocuments());
            }
            else
            {
                return(Task.CompletedTask);
            }
        }
Exemplo n.º 7
0
        private void NavigateAction(object obj)
        {
            try
            {
                var idleTime = IdleTimeDetector.GetIdleTimeInfo();

                if (idleTime.IdleTime.TotalMinutes >= Constants.SystemIdleTimeout)
                {
                    idleTimer.Dispose();
                    this.Dispatcher.Invoke(() =>
                    {
                        NavigationService.Navigate(new Pages.MainPage());
                    });
                }
            }
            catch (Exception ex)
            {
                log.Error("Error TicketTypePage -> DateTimeTimerAction() : " + ex.ToString());
            }
        }
Exemplo n.º 8
0
        private void OnInactivityCheckTick(object sender, EventArgs e)
        {
            if (IdleTimeDetector.GetIdleTimeInfo().IdleTime > TimeSpan.FromSeconds(60))
            {
                if (!_isSystemInactive)
                {
                    _isSystemInactive = true;
                    PublishSystemActivityEvent();
                }
            }
            else
            {
                if (_isSystemInactive)
                {
                    _isSystemInactive = false;
                    PublishSystemActivityEvent();
                }
            }

            if (DateTime.Now.Subtract(_lastAppicationInputActivity) > TimeSpan.FromSeconds(10))
            {
                if (!_isApplicationInactive)
                {
                    _isApplicationInactive = true;
                    PublishApplicationActivityEvent();
                }
            }
            else
            {
                if (_isApplicationInactive)
                {
                    _isApplicationInactive = false;
                    PublishApplicationActivityEvent();
                }
            }
        }