/// <summary> /// Removes sound from the heardSound list. /// </summary> /// <param name="sound">Sound to remove.</param> public void forgetSound(LocalSound sound) { if (heardSounds.Contains(sound)) { heardSounds.Remove(sound); } }
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; }
public void LoadSelectedRow() { IAudioStream audioStream = null; if (grid.Rows.Count > 0) { if (SelectedRow == null) { if (grid.SelectedRows != null && grid.SelectedRows.Count > 0) { SelectedRow = grid.SelectedRows[0]; } else { SelectedRow = grid.Rows[0]; } } MediaItem track = GetSelectedMediaItem(SelectedRow); if (SelectedTrack == null || SelectedTrack.Id != track.Id) { SelectedTrack = track; if (SelectedTrack.Format == "cdda") { string discPath = SelectedTrack.Path.LocalPath.Substring(0, 2); audioStream = new CompactDiscSound(discPath); audioStream.StreamIndex = SelectedTrack.Number - 1; } else { if (SelectedTrack.Path.IsFile) { audioStream = new LocalSound(SelectedTrack.Path.LocalPath); audioStream.StreamIndex = 0; LoadNowPlayingImage(track.Path); } else { string fileName = string.Format("{0}{1:00,2} {2} - {3} - {4}.{5}", tempPath, SelectedTrack.Number, SelectedTrack.Title, SelectedTrack.Artist, SelectedTrack.Album, SelectedTrack.Format); fileName = CleanupFileName(fileName); if (!System.IO.File.Exists(fileName)) { if (!System.IO.Directory.Exists(tempPath)) { System.IO.Directory.CreateDirectory(tempPath); } WebClient client = new WebClient(); Uri address = locker.GetLockerPath(SelectedTrack.Path.ToString()); try { client.DownloadFile(address, fileName); } catch (WebException ex) { throw new ApplicationException("There was an error downloading track : " + selectedTrack.Title, ex); } } audioStream = new LocalSound(fileName); audioStream.StreamIndex = 0; } if (audioStream != null && audioStream.Duration != SelectedTrack.Duration && audioStream.Duration != TimeSpan.Zero) { SelectedRow.Cells[QueueColumns.Duration.Name].Value = audioStream.Duration; } } playbackController.LoadAudioStream(audioStream); SelectedRowStatus = "Loaded"; } } else { SelectedRow = null; SelectedTrack = null; } }