Example #1
0
 private void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e)
 {
     if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionLock)
     {
         isLocked = LockScreenStatus.Locked;
     }
     else if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionUnlock)
     {
         isLocked = LockScreenStatus.Unlocked;
     }
 }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            botToken.Text         = Properties.Settings.Default.ApiKey;
            maxDelayBox.Text      = Properties.Settings.Default.MaxDelay.ToString();
            userIdBox.Text        = Properties.Settings.Default.ApiUser;
            vwifiNameBox.Text     = Properties.Settings.Default.VWiFiName;
            vwifiPasswordBox.Text = Properties.Settings.Default.VWiFiPassword;

            var delayIdx = maxDelayBox.Items.IndexOf(Properties.Settings.Default.MaxDelay.ToString());

            if (delayIdx == -1)
            {
                maxDelayBox.SelectedIndex = 0;
            }
            else
            {
                maxDelayBox.SelectedIndex = delayIdx;
            }

            if (botEnabled)
            {
                bot.OnMessage += BotOnMessageReceived;

                InitApp();
                MinimizeTimer();
            }
            else
            {
                Opacity = 1;
            }

            trayIcon.Text = Text;

            Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
            isLocked = LockScreenStatus.Unlocked;
        }