Пример #1
0
 private void FullScreenTimer_Tick(object sender, EventArgs e)
 {
     // This timer is for hiding controls and cursor
     // After every 3 seconds when no mouse movement
     if (IsFullScreen & Player.Media != null)
     {
         shouldHide = User32Interop.GetLastInput() > activityThreshold;
         if (cursorHidden != shouldHide)
         {
             if (shouldHide)
             {
                 ShowCursor(0);
                 PanelBackControls.Visible  = false;
                 tableLayoutPanel1.RowCount = 1;
             }
             else
             {
                 ShowCursor(1);
                 PanelBackControls.Visible  = true;
                 tableLayoutPanel1.RowCount = 2;
             }
             cursorHidden = shouldHide;
         }
     }
     else
     {
         Timer2.Stop();
     }
 }
Пример #2
0
        public async void StartWakeupTime()
        {
            double CallTime = SleepDown.Properties.Settings.Default.AlertTime * 60000;
            await Task.Run(() =>
            {
                while (true)
                {
                    TimeSpan last_input_time = User32Interop.GetLastInput();

                    if ((double)last_input_time.TotalMilliseconds > CallTime)
                    {
                        PlaySound();
                        System.Threading.Thread.Sleep(1000);
                    }
                }
            });
        }
Пример #3
0
    void activityWorker_Tick(object sender, EventArgs e)
    {
        bool shouldHide = User32Interop.GetLastInput() > activityThreshold;

        if (cursorHidden != shouldHide)
        {
            if (shouldHide)
            {
                Cursor.Hide();
            }
            else
            {
                Cursor.Show();
            }

            cursorHidden = shouldHide;
        }
    }
Пример #4
0
        /// <summary>
        /// Handler for the IdleTimer's Tick event.
        /// </summary>
        /// <param name="sender">Object raising event.</param>
        /// <param name="e">Event Arguments.</param>
        private void IdleTimer_Tick(object sender, EventArgs e)
        {
            if (Settings.Default.IdleMinsBeforeLoggingOut != 0)
            {
                bool inactive = User32Interop.GetLastInput() > TimeSpan.FromMinutes(Settings.Default.IdleMinsBeforeLoggingOut);

                if (inactive &
                    Settings.Default.LogOutOnIdle &
                    this.IsLoggedIn)
                {
                    this.Records.Add(new AgentStatusChangeEventArgs(
                                         AgentStatus.Undetermined,
                                         AgentStatus.Undetermined,
                                         DateTime.Now,
                                         "Logging out because of user going into idle status."));

                    this.LogOut();
                    this.LoggedOutBecauseIdle = true;
                    return;
                }
                else
                {
                    if (!this.IsLoggedIn &
                        Settings.Default.LogInAfterIdle &
                        this.LoggedOutBecauseIdle)
                    {
                        this.Records.Add(new AgentStatusChangeEventArgs(
                                             AgentStatus.Undetermined,
                                             AgentStatus.Undetermined,
                                             DateTime.Now,
                                             "Logging back in because of user coming back from idle status."));

                        this.LogIn();
                        this.LoggedOutBecauseIdle = false;
                    }
                }
            }
        }