Exemplo n.º 1
0
        /// <summary>
        /// The function called any time an event from one of the listeners is triggered.
        /// </summary>
        /// <param name="sender">The class that sent the event</param>
        /// <param name="e">The event</param>
        private void ListenerEvent(object sender, CustomEventArgs e)
        {
            switch (sender.GetType().Name)
            {
            case "ProgramSwitchListener":
                if (ActivitySwitched((string)e.Value))
                {
                    ChangeActivity();
                }
                break;

            case "MachineStateListener":
                if ((bool)e.Value)     // True means the machine has been unlocked/woken up
                {
                    if (Settings.Default.OfflineTracking && AppStateTracker.LastLocked != null)
                    {
                        ShowAwayFromPCDialog?.Invoke(this, new CustomEventArgs(AppStateTracker.LastLocked));
                        AppStateTracker.LastLocked = null;
                    }
                    AppStateTracker.Pause(false);
                }
                else     // False means the machine has been locked/put to sleep.
                {
                    AppStateTracker.Pause(true);
                    AppStateTracker.LastLocked = DateTime.Now;
                }
                break;

            case "HotkeyListener":
                ChangeActivity(true);
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets up the taskbar menu, attaching all relevant menu items and events.
        /// </summary>
        private void CreateContextMenu()
        {
            NotifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
            NotifyIcon.ContextMenuStrip.Items.Add("Open").Click            += (s, e) => new HTMLDataWindow(StorageHandler, AppStateTracker).Show();
            NotifyIcon.ContextMenuStrip.Items.Add("Change Activity").Click += (s, e) => ASDL.ChangeActivity();
            NotifyIcon.ContextMenuStrip.Items.Add("Pause").Click           += (s, e) => AppStateTracker.Pause(null);
            NotifyIcon.ContextMenuStrip.Items.Add("Do not Disturb").Click  += (s, e) => DoNotDisturb();
            NotifyIcon.ContextMenuStrip.Items.Add("Edit Activities").Click += (s, e) => new ManualEdit(StorageHandler).Show();
            NotifyIcon.ContextMenuStrip.Items.Add("Exit").Click            += (s, e) => ExitApplication();

            ToolStripItem Item = NotifyIcon.ContextMenuStrip.Items[0];

            Item.Font = new Font(Item.Font, System.Drawing.FontStyle.Bold);
        }