public NotifyIconContext() { level = new MenuItem("&Level"); BuildLevelMenu(level); autoStart = new MenuItem("&Auto Start", ToggleAutoStart); autoMute = new MenuItem("Auto mute on key presses", ToggleAutoMute); mapCapsLock = new MenuItem("Map &CapsLock"); mapCapsLockSet = new MenuItem("To F13", MapCapsLock); mapCapsLockReset = new MenuItem("Reset CapsLock", ResetCapsLock); mapCapsLock.MenuItems.Add(mapCapsLockSet); mapCapsLock.MenuItems.Add(mapCapsLockReset); mute = new MenuItem("&Mute", (s, e) => ConfigManager.ToggleMute()); showNotifications = new MenuItem("Show notifications", ToggleShowNotifications); var about = new MenuItem("About", (s, e) => Process.Start("https://github.com/SilentOrbit/FixedMicrophoneLevel")); var exit = new MenuItem("E&xit", (s, e) => Application.Exit()); trayIcon = new NotifyIcon() { Icon = StartupInactive, ContextMenu = new ContextMenu(new MenuItem[] { level, mute, autoMute, autoStart, mapCapsLock, showNotifications, about, exit }), Visible = true }; trayIcon.ContextMenu.Popup += (object sender, EventArgs e) => { autoStart.Checked = RegAutoStart.Get(); autoMute.Checked = ConfigManager.MuteOnKeyPress; mute.Checked = ConfigManager.Target == 0; showNotifications.Checked = ConfigManager.ShowNotifications; }; trayIcon.Click += TrayIcon_Click; }
void ToggleAutoStart(object sender, EventArgs e) { var val = RegAutoStart.Get(); if (val) { RegAutoStart.Remove(); } else { RegAutoStart.Set(); } }