public DemodulationDialog(DemodulationState demod) { InitializeComponent(); DemodState = demod; foreach (var v in Enum.GetValues(typeof(DemodulationState.eSourceFrequency))) { this.cmbSourceFrequency.Items.Add(SourceFrequencyDesc[(int)v]); } UpdateTimer = new Timer(); UpdateTimer.Tick += new EventHandler(UpdateTimer_Tick); UpdateTimer.Interval = 500; UpdateTimer.Start(); DemodState.DataUpdated += new EventHandler(Demod_DataUpdated); lock (DemodState.SoundSinkInfos) { foreach (SoundSinkInfo info in DemodState.SoundSinkInfos) { tabSoundOut.Controls.Add(info.Page); } } UpdateFromConfig(); }
void lstMarkers_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { try { switch (e.Button) { case MouseButtons.Right: FrequencyMarker marker = GetSelected(); Tuner tuner = GetTuner(); if (marker != null) { ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem; menuItem = new MenuItem("Marker: " + marker.Label); menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("Jump to"); menuItem.Enabled = (tuner == null); menuItem.Click += (object s, EventArgs a) => { tuner.SetFrequency(marker.Frequency); }; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("Edit..."); menuItem.Click += (object s, EventArgs a) => { MarkerDetailsDialog dlg = new MarkerDetailsDialog(marker); dlg.ShowDialog(); UpdateMarkerList(); }; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("Delete"); menuItem.Click += (object s, EventArgs a) => { MarkerList.Remove(marker); UpdateMarkerList(); }; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); bool demodulation = MainScreen.MarkerDemodulators.ContainsKey(marker); AudioDemodulator Demod = null; DemodulationState DemodState = null; if (demodulation) { Demod = MainScreen.MarkerDemodulators[marker]; DemodState = Demod.DemodState; menuItem = new MenuItem("Demodulate"); menuItem.Checked = true; menuItem.Click += (object s, EventArgs a) => { if (DemodState.Dialog != null) { DemodState.Dialog.Close(); DemodState.Dialog = null; } Demod.Stop(); Demod.Close(); MainScreen.MarkerDemodulators.Remove(marker); }; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("Demodulation Options..."); menuItem.Checked = (DemodState.Dialog != null); menuItem.Click += (object s, EventArgs a) => { if (DemodState.Dialog != null) { DemodState.Dialog.Close(); DemodState.Dialog = null; } else { DemodState.Dialog = new DemodulationDialog(DemodState); DemodState.Dialog.FrequencyFixed = true; DemodState.Dialog.Show(); } }; contextMenu.MenuItems.Add(menuItem); } else { menuItem = new MenuItem("Demodulate"); menuItem.Click += (object s, EventArgs a) => { Demod = new AudioDemodulator(); DemodState = Demod.DemodState; DemodState.BaseFrequency = tuner.GetFrequency(); DemodState.DemodulationFrequencyMarker = marker.Frequency; DemodState.Description = marker.Label; MainScreen.MarkerDemodulators.Add(marker, Demod); DemodState.Dialog = new DemodulationDialog(DemodState); DemodState.Dialog.FrequencyFixed = true; DemodState.Dialog.Show(); DemodState.Dialog.UpdateInformation(); Demod.Start(MainScreen.AudioShmem); }; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("Demodulation Options..."); menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); } Point popupPos = this.PointToClient(MousePosition); popupPos.X -= 20; popupPos.Y -= 20; contextMenu.Show(this, popupPos); } break; } } catch (Exception) { } }