void Swap_MouseUp(object sender, MouseButtonEventArgs e) { switch (e.ChangedButton) { case MouseButton.Left: Mute_MouseUp(sender, e); LocalSound.ToggleMute(); break; } }
public TrayIcon(RootModel model) { this.model = model; model.PropertyChanged += UpdateTray; ContextMenuStrip trayMenu = new ContextMenuStrip(); ToolStripMenuItem vcItem = new ToolStripMenuItem("Définir le volume", null, delegate { OnVolumeControlClicked(EventArgs.Empty); }); vcItem.Font = new Font(vcItem.Font, vcItem.Font.Style | FontStyle.Bold); trayMenu.Items.Add(vcItem); muteItem = new ToolStripMenuItem("Tout mettre en sourdine", null, delegate { model.Muted = !model.Muted; }); UpdateMuteItemChecked(); trayMenu.Items.Add(muteItem); trayMenu.Items.Add(new ToolStripMenuItem("Basculer depuis/vers son local", null, delegate { foreach (SessionModel session in model.Sessions) { if (session.Valid && session.ShowInMixer && session.CanSwap) { session.Muted = !session.Muted; } } LocalSound.ToggleMute(); })); trayMenu.Items.Add(new ToolStripMenuItem("Réinitialiser", null, delegate { OnResetClicked(EventArgs.Empty); })); trayMenu.Items.Add(new ToolStripMenuItem("Paramètres", null, delegate { OnSettingsClicked(EventArgs.Empty); })); trayMenu.Items.Add(new ToolStripSeparator()); trayMenu.Items.Add(new ToolStripMenuItem("Arrêter EtherSound", null, delegate { if (MessageBox.Show("Voulez-vous vraiment arrêter EtherSound ?", "EtherSound", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Application.ExitThread(); } })); SystemEvents.UserPreferenceChanged += delegate { UpdateTrayIconIcon(); model.UpdateIcon(); }; trayIcon = new NotifyIcon(); trayIcon.MouseClick += (sender, e) => { switch (e.Button) { case MouseButtons.Left: OnVolumeControlClicked(EventArgs.Empty); break; case MouseButtons.Middle: model.Muted = !model.Muted; break; } }; trayIcon.ContextMenuStrip = trayMenu; UpdateTrayIconIcon(); UpdateTrayIconText(); trayIcon.Visible = true; }