Example #1
0
 private void InitializeGUI()
 {
     this._initializing = true;
       this._modeStates[DetectorType.WFM] = Utils.GetIntArraySetting("wfmState", MainForm._defaultWFMState);
       this._modeStates[DetectorType.NFM] = Utils.GetIntArraySetting("nfmState", MainForm._defaultNFMState);
       this._modeStates[DetectorType.AM] = Utils.GetIntArraySetting("amState", MainForm._defaultAMState);
       this._modeStates[DetectorType.LSB] = Utils.GetIntArraySetting("lsbState", MainForm._defaultSSBState);
       this._modeStates[DetectorType.USB] = Utils.GetIntArraySetting("usbState", MainForm._defaultSSBState);
       this._modeStates[DetectorType.DSB] = Utils.GetIntArraySetting("dsbState", MainForm._defaultDSBState);
       this._modeStates[DetectorType.CW] = Utils.GetIntArraySetting("cwState", MainForm._defaultCWState);
       this._modeStates[DetectorType.RAW] = Utils.GetIntArraySetting("rawState", MainForm._defaultRAWState);
       ThreadPool.QueueUserWorkItem(new WaitCallback(this.TuneThreadProc));
       this.stepSizeComboBox.Items.AddRange((object[]) Utils.GetStringSetting("stepSizes", "1 Hz,10 Hz,100 Hz,500 Hz,1 kHz,2.5 kHz,5 kHz,6.25 kHz,7.5 kHz,8.33 kHz,9 kHz,10 kHz,12.5 kHz,15 kHz,20 kHz,25 kHz,30 kHz,50 kHz,100 kHz,150 kHz,200 kHz,250 kHz,300 kHz,350 kHz,400 kHz,450 kHz,500 kHz").Split(','));
       this._tuningStyle = (MainForm.TuningStyle) Utils.GetIntSetting("tuningStyle", 0);
       switch (this._tuningStyle)
       {
     case MainForm.TuningStyle.Free:
       this.centerButton.Image = (Image) Resources.free_tuning;
       this._tooltip.SetToolTip((Control) this.centerButton, "Free tuning");
       break;
     case MainForm.TuningStyle.Sticky:
       this.centerButton.Image = (Image) Resources.sticky;
       this._tooltip.SetToolTip((Control) this.centerButton, "Sticky tuning");
       break;
     case MainForm.TuningStyle.Center:
       this.centerButton.Image = (Image) Resources.center_24;
       this._tooltip.SetToolTip((Control) this.centerButton, "Center tuning");
       break;
       }
       int num1 = 0;
       int num2 = -1;
       List<AudioDevice> devices1 = AudioDevice.GetDevices(DeviceDirection.Input);
       string stringSetting1 = Utils.GetStringSetting("inputDevice", string.Empty);
       for (int index = 0; index < devices1.Count; ++index)
       {
     this.inputDeviceComboBox.Items.Add((object) devices1[index]);
     if (devices1[index].IsDefault)
       num1 = index;
     if (devices1[index].ToString() == stringSetting1)
       num2 = index;
       }
       if (this.inputDeviceComboBox.Items.Count > 0)
     this.inputDeviceComboBox.SelectedIndex = num2 >= 0 ? num2 : num1;
       int num3 = 0;
       List<AudioDevice> devices2 = AudioDevice.GetDevices(DeviceDirection.Output);
       string stringSetting2 = Utils.GetStringSetting("outputDevice", string.Empty);
       for (int index = 0; index < devices2.Count; ++index)
       {
     this.outputDeviceComboBox.Items.Add((object) devices2[index]);
     if (devices2[index].IsDefault)
       num3 = index;
     if (devices2[index].ToString() == stringSetting2)
       num2 = index;
       }
       if (this.outputDeviceComboBox.Items.Count > 0)
     this.outputDeviceComboBox.SelectedIndex = num2 >= 0 ? num2 : num3;
       this._streamControl.BufferNeeded += new BufferNeededDelegate(this.ProcessBuffer);
       this.DetectorType = (DetectorType) Utils.GetIntSetting("detectorType", 2);
       this.modeRadioButton_CheckStateChanged((object) null, (EventArgs) null);
       this.filterBandwidthNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.filterOrderNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.filterTypeComboBox_SelectedIndexChanged((object) null, (EventArgs) null);
       this.cwShiftNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.agcCheckBox.Checked = Utils.GetBooleanSetting("useAGC");
       this.agcCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.agcThresholdNumericUpDown.Value = (Decimal) Utils.GetIntSetting("agcThreshold", -100);
       this.agcThresholdNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.agcDecayNumericUpDown.Value = (Decimal) Utils.GetIntSetting("agcDecay", 100);
       this.agcDecayNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.agcSlopeNumericUpDown.Value = (Decimal) Utils.GetIntSetting("agcSlope", 0);
       this.agcSlopeNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.agcUseHangCheckBox.Checked = Utils.GetBooleanSetting("agcHang");
       this.agcUseHangCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.SetCenterFrequency(0L);
       this.frequencyShiftNumericUpDown.Value = (Decimal) Utils.GetLongSetting("frequencyShift", 0L);
       this.frequencyShiftNumericUpDown_ValueChanged((object) null, (EventArgs) null);
       this.frequencyShiftCheckBox.Checked = Utils.GetBooleanSetting("frequencyShiftEnabled");
       this.frequencyShiftCheckBox_CheckStateChanged((object) null, (EventArgs) null);
       this.swapIQCheckBox.Checked = Utils.GetBooleanSetting("swapIQ");
       this.swapIQCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.correctIQCheckBox.Checked = Utils.GetBooleanSetting("correctIQ");
       this.autoCorrectIQCheckBox_CheckStateChanged((object) null, (EventArgs) null);
       this.markPeaksCheckBox.Checked = Utils.GetBooleanSetting("markPeaks");
       this.markPeaksCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.fmStereoCheckBox.Checked = Utils.GetBooleanSetting("fmStereo");
       this.fmStereoCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.filterAudioCheckBox.Checked = Utils.GetBooleanSetting("filterAudio");
       this.filterAudioCheckBox_CheckStateChanged((object) null, (EventArgs) null);
       this.unityGainCheckBox.Checked = Utils.GetBooleanSetting("unityGain");
       this.unityGainCheckBox_CheckStateChanged((object) null, (EventArgs) null);
       this.audioGainTrackBar.Value = Utils.GetIntSetting("audioGain", 50);
       this.audioGainTrackBar_ValueChanged((object) null, (EventArgs) null);
       this._vfo.Muted = Utils.GetBooleanSetting("AudioIsMuted");
       this.UpdateMuteButton();
       this.latencyNumericUpDown.Value = (Decimal) Utils.GetIntSetting("latency", 100);
       this.sampleRateComboBox.Text = Utils.GetStringSetting("sampleRate", "48000 sample/sec");
       this.WindowState = (FormWindowState) Utils.GetIntSetting("windowState", 0);
       this.spectrumAnalyzer.SpectrumWidth = Utils.GetIntSetting("spectrumWidth", 48000);
       this.waterfall.SpectrumWidth = this.spectrumAnalyzer.SpectrumWidth;
       this.lockCarrierCheckBox.Checked = Utils.GetBooleanSetting("lockCarrier");
       this.lockCarrierCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.useAntiFadingCheckBox.Checked = Utils.GetBooleanSetting("useAntiFading");
       this.useAntiFadingCheckBox_CheckedChanged((object) null, (EventArgs) null);
       int[] intArraySetting1 = Utils.GetIntArraySetting("windowPosition", (int[]) null);
       if (intArraySetting1 != null)
       {
     this._lastLocation.X = intArraySetting1[0];
     this._lastLocation.Y = intArraySetting1[1];
     this.Location = this._lastLocation;
       }
       else
     this._lastLocation = this.Location;
       int[] intArraySetting2 = Utils.GetIntArraySetting("windowSize", (int[]) null);
       if (intArraySetting2 != null)
       {
     this._lastSize.Width = intArraySetting2[0];
     this._lastSize.Height = intArraySetting2[1];
     this.Size = this._lastSize;
       }
       else
     this._lastSize = this.Size;
       this.spectrumSplitter.SplitPosition = Utils.GetIntSetting("splitterPosition", this.spectrumSplitter.SplitPosition);
       this._fftTimer = new System.Windows.Forms.Timer(this.components);
       this._fftTimer.Tick += new EventHandler(this.fftTimer_Tick);
       this._fftTimer.Enabled = true;
       this.viewComboBox.SelectedIndex = Utils.GetIntSetting("fftView", 2);
       this.fftResolutionComboBox.SelectedIndex = Utils.GetIntSetting("fftResolution", 6);
       this.fftWindowComboBox.SelectedIndex = Utils.GetIntSetting("fftWindowType", 3);
       this.spectrumStyleComboBox.SelectedIndex = Utils.GetIntSetting("spectrumStyle", 3);
       this.spectrumStyleComboBox_SelectedIndexChanged((object) null, (EventArgs) null);
       this.fftSpeedTrackBar.Value = Utils.GetIntSetting("fftSpeed", 40);
       this.fftSpeedTrackBar_ValueChanged((object) null, (EventArgs) null);
       this.fftContrastTrackBar.Value = Utils.GetIntSetting("fftContrast", 0);
       this.fftContrastTrackBar_Changed((object) null, (EventArgs) null);
       this.spectrumAnalyzer.Attack = (float) Utils.GetDoubleSetting("spectrumAnalyzerAttack", 0.9);
       this.sAttackTrackBar.Value = (int) ((double) this.spectrumAnalyzer.Attack * (double) this.sAttackTrackBar.Maximum);
       this.spectrumAnalyzer.Decay = (float) Utils.GetDoubleSetting("spectrumAnalyzerDecay", 0.3);
       this.sDecayTrackBar.Value = (int) ((double) this.spectrumAnalyzer.Decay * (double) this.sDecayTrackBar.Maximum);
       this.waterfall.Attack = (float) Utils.GetDoubleSetting("waterfallAttack", 0.9);
       this.wAttackTrackBar.Value = (int) ((double) this.waterfall.Attack * (double) this.wAttackTrackBar.Maximum);
       this.waterfall.Decay = (float) Utils.GetDoubleSetting("waterfallDecay", 0.5);
       this.wDecayTrackBar.Value = (int) ((double) this.waterfall.Decay * (double) this.wDecayTrackBar.Maximum);
       this.useTimestampsCheckBox.Checked = Utils.GetBooleanSetting("useTimeMarkers");
       this.useTimestampCheckBox_CheckedChanged((object) null, (EventArgs) null);
       this.fftOffsetTrackBar.Value = Utils.GetIntSetting("fftDisplayOffset", 0);
       this.fftOffsetTrackBar_Scroll((object) null, (EventArgs) null);
       this.fftRangeTrackBar.Value = Utils.GetIntSetting("fftDisplayRange", 13);
       this.fftRangeTrackBar_Scroll((object) null, (EventArgs) null);
       NameValueCollection nameValueCollection = (NameValueCollection) ConfigurationManager.GetSection("frontendPlugins");
       foreach (string key in nameValueCollection.Keys)
       {
     try
     {
       string[] strArray = nameValueCollection[key].Split(',');
       string typeName = strArray[0];
       IFrontendController frontendController = (IFrontendController) Activator.CreateInstance(strArray[1], typeName).Unwrap();
       ISampleRateChangeSource rateChangeSource = frontendController as ISampleRateChangeSource;
       IControlAwareObject controlAwareObject = frontendController as IControlAwareObject;
       if (rateChangeSource != null)
     rateChangeSource.SampleRateChanged += new EventHandler(this.frontendController_SampleRateChanged);
       if (controlAwareObject != null)
     controlAwareObject.Control = (object) this._sharpControlProxy;
       this._frontendControllers.Add(key, frontendController);
       this.iqSourceComboBox.Items.Add((object) key);
     }
     catch (Exception ex)
     {
       int num4 = (int) MessageBox.Show("Error loading '" + nameValueCollection[key] + "' - " + ex.Message);
     }
       }
       string[] files = Directory.GetFiles(".", "ExtIO_*.dll");
       int num5 = this.iqSourceComboBox.Width;
       Graphics graphics = this.iqSourceComboBox.CreateGraphics();
       foreach (string str1 in files)
       {
     try
     {
       ExtIOController extIoController = new ExtIOController(str1);
       extIoController.HideSettingGUI();
       string str2 = string.IsNullOrEmpty(ExtIO.HWName) ? Path.GetFileName(str1) ?? "" : ExtIO.HWName;
       if (!string.IsNullOrEmpty(ExtIO.HWModel))
     str2 = str2 + " (" + ExtIO.HWModel + ")";
       string str3 = str2 + " - " + Path.GetFileName(str1);
       SizeF sizeF = graphics.MeasureString(str3, this.iqSourceComboBox.Font);
       if ((double) sizeF.Width > (double) num5)
     num5 = (int) sizeF.Width;
       this._frontendControllers.Add(str3, (IFrontendController) extIoController);
       this.iqSourceComboBox.Items.Add((object) str3);
     }
     catch (Exception ex)
     {
       int num4 = (int) MessageBox.Show("Error loading '" + Path.GetFileName(str1) + "'\r\n" + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
       }
       this.iqSourceComboBox.DropDownWidth = num5;
       ExtIO.SampleRateChanged += new SampleRateChangedDelegate(this.ExtIO_SampleRateChanged);
       ExtIO.LOFreqChanged += new LOFrequencyChangedDelegate(this.ExtIO_LOFreqChanged);
       this.iqSourceComboBox.Items.Add((object) "IQ file (*.wav)");
       this.iqSourceComboBox.Items.Add((object) "Other (Sound card)");
       this._waveFile = Utils.GetStringSetting("waveFile", string.Empty);
       int intSetting = Utils.GetIntSetting("iqSource", this.iqSourceComboBox.Items.Count - 1);
       this.iqSourceComboBox.SelectedIndex = intSetting < this.iqSourceComboBox.Items.Count ? intSetting : this.iqSourceComboBox.Items.Count - 1;
       this.SetCenterFrequency(Utils.GetLongSetting("centerFrequency", this._centerFrequency));
       this.vfoFrequencyEdit.Frequency = Utils.GetLongSetting("vfo", this._centerFrequency);
       this._tooltip.SetToolTip((Control) this.playStopButton, "Start");
       bool flag = !Utils.GetBooleanSetting("menuIsHidden");
       this.scrollPanel.Visible = flag;
       this.menuSpacerPanel.Visible = flag;
       this._tooltip.SetToolTip((Control) this.toggleMenuButton, "Menu");
       this._initializing = false;
 }
Example #2
0
 private void centerButton_Click(object sender, EventArgs e)
 {
     this._tuningStyle = (MainForm.TuningStyle) ((int) (this._tuningStyle + 1) % 3);
       switch (this._tuningStyle)
       {
     case MainForm.TuningStyle.Free:
       this.centerButton.Image = (Image) Resources.free_tuning;
       this._tooltip.SetToolTip((Control) this.centerButton, "Free tuning");
       break;
     case MainForm.TuningStyle.Sticky:
       this.centerButton.Image = (Image) Resources.sticky;
       this._tooltip.SetToolTip((Control) this.centerButton, "Sticky tuning");
       break;
     case MainForm.TuningStyle.Center:
       this.centerButton.Image = (Image) Resources.center_24;
       this._tooltip.SetToolTip((Control) this.centerButton, "Center tuning");
       if (!this.SourceIsTunable)
     break;
       long frequency = this.Frequency;
       this.SetCenterFrequency(frequency + this._frequencyShift);
       this.Frequency = frequency;
       break;
       }
 }