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 mnuSleep = new System.Windows.Forms.MenuItem("Enter sleep mode", new EventHandler(this.SleepMenuEventHandler));
System.Windows.Forms.MenuItem mnuCaffiene = new System.Windows.Forms.MenuItem("Caffiene", new EventHandler(this.CaffieneMenuEventHandler));
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, mnuSleep, new System.Windows.Forms.MenuItem("-"), mnuCaffiene, 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;
}