private void AutostartMenuEventHandler(object sender, EventArgs e)
 {
     if (mnuAutostart.Checked)
     {
         // remove autostart entry
         Autostart.DeleteStartupFolderShortcut();
     }
     else
     {
         // create autostart entry
         Autostart.CreateStartupFolderShortcut();
     }
     mnuAutostart.Checked = Autostart.CheckStartupFolderShortcutsExists();
 }
        /// <summary>
        /// Creates notify icon and menu.
        /// </summary>
        private void CreateNotifyIcon()
        {
            System.Windows.Forms.NotifyIcon notifyicon;

            notifyicon = new System.Windows.Forms.NotifyIcon();
            var currentBrightness = WmiFunctions.GetBrightnessLevel();

            //System.Windows.Forms.MenuItem mnuPin = new System.Windows.Forms.MenuItem("Pin", new EventHandler(this.PinMenuEventHandler));
            System.Windows.Forms.MenuItem mnuMonitorOff  = new System.Windows.Forms.MenuItem("Power off display", new EventHandler(this.MonitorOffMenuEventHandler));
            System.Windows.Forms.MenuItem mnuScreenSaver = new System.Windows.Forms.MenuItem("Start screen saver", new EventHandler(this.StartScreenSaverMenuEventHandler));
            System.Windows.Forms.MenuItem mnuSleep       = new System.Windows.Forms.MenuItem("Enter sleep mode", new EventHandler(this.SleepMenuEventHandler));
            System.Windows.Forms.MenuItem mnuCaffeine    = new System.Windows.Forms.MenuItem("Caffeine", new EventHandler(this.CaffeineMenuEventHandler));
            mnuAutostart         = new System.Windows.Forms.MenuItem("Autostart", new EventHandler(this.AutostartMenuEventHandler));
            mnuAutostart.Checked = Autostart.CheckStartupFolderShortcutsExists();

            System.Windows.Forms.MenuItem mnuExit = new System.Windows.Forms.MenuItem("Close", new EventHandler(this.ExitMenuEventHandler));
            mnuLabel         = new System.Windows.Forms.MenuItem("");
            mnuLabel.Enabled = false; // greyed-out style label

            System.Windows.Forms.MenuItem[] menuitems = new System.Windows.Forms.MenuItem[]
            {
                mnuLabel, new System.Windows.Forms.MenuItem("-"), mnuMonitorOff, mnuScreenSaver, mnuSleep, new System.Windows.Forms.MenuItem("-"), mnuCaffeine, new System.Windows.Forms.MenuItem("-"), mnuAutostart, new System.Windows.Forms.MenuItem("-"), mnuExit
            };

            System.Windows.Forms.ContextMenu contextmenu = new System.Windows.Forms.ContextMenu(menuitems);
            contextmenu.Popup += this.ContextMenuPopup;

            notifyicon.ContextMenu = contextmenu;

            notifyicon.MouseClick       += this.NotifyIconClick;
            notifyicon.MouseDoubleClick += this.NotifyIconClick;

            notifyicon.Visible = true;

            DrawIcon.updateNotifyIcon(notifyicon, currentBrightness);

            this.NotifyIcon = notifyicon;
        }