Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            SweepModeCurvesList.Clear();
            SweepModeCurvesList.Add(new CCurve());

            CurveListComboBox.DataSource           = null;
            CurveListComboBox.DataSource           = SweepModeCurvesList;
            CurveListComboBox.SelectedItem         = SweepModeCurvesList[0];
            CurveConfigPropertyGrid.SelectedObject = SweepModeCurvesList[0];


            AutodetectCOMcheckBox.Checked = Program.Save.SerialPortAutodetectAtLaunch;
            RawCaptureCheckBox.Checked    = Program.Save.RawCapture;

            //SerialPortComboBox.SelectedValueChanged -= DevicesComboBox_SelectedValueChanged;
            RefreshCOMPortList();
            //SerialPortComboBox.SelectedValueChanged += DevicesComboBox_SelectedValueChanged;


            Text = Program.Version;
            OutputModeComboBox.DataSource   = Enum.GetValues(typeof(OutputMode));
            FilterComboBox.DataSource       = Enum.GetValues(typeof(FilterMode));
            OutputModeComboBox.SelectedItem = Program.Save.Output;
            FilterComboBox.SelectedItem     = Program.Save.Filter;


            AttLevelcomboBox.SelectedIndexChanged -= AttLevelcomboBox_SelectedIndexChanged;
            AttLevelcomboBox.DataSource            = Enum.GetValues(typeof(AttLevel));
            AttLevelcomboBox.SelectedIndexChanged += AttLevelcomboBox_SelectedIndexChanged;

            DetectorCombobox.DataSource = Enum.GetValues(typeof(NWTDevice.DetectorUsed));
            MyNotifier.SetProgressBar(SweepProgressBar);
            MyNotifier.SetForm(this);

            DeviceManagerInit();
            //SerialPortComboBox.Items.AddRange(SerialPort.GetPortNames());
            //AutoDetectserialPort();
            DeviceListMenuRefresh();

            bMuteDeviceComboBoxEvent = true;

            int nDeviceIndex = GetDeviceIndex(Program.Save.LastUsedDevice);

            if (nDeviceIndex >= 0)
            {
                SelectecDeviceComboBox.SelectedIndex = nDeviceIndex;
            }
            else
            {
                SelectecDeviceComboBox.SelectedIndex = 0;
            }

            bMuteDeviceComboBoxEvent = false;

            SetAnalyzer(SelectecDeviceComboBox.SelectedIndex, true);


            if (Program.Save.LastUsedCOMPort != null)
            {
                // we try to initalize this com port
                bool bSuccess = SerialPortInitialize(Program.Save.LastUsedCOMPort);

                if (bSuccess)
                {
                    SerialPortComboBox.SelectedItem = Program.Save.LastUsedCOMPort;
                }


                if (!bSuccess && Program.Save.SerialPortAutodetectAtLaunch)
                {
                    AutoDetectSerialPort();
                }
            }
            else
            {
                if (Program.Save.SerialPortAutodetectAtLaunch)
                {
                    AutoDetectSerialPort();
                }
            }

            AttCalCheckBox.Checked = Program.Save.AttCal;
            SpectrumPictureBox.SetOwnedForm(this);

            SetSampleCount(Program.Save.SampleCount);

            if (DeviceInterface.GetDevice().Attenuator)
            {
                if (Program.Save.AttCal)
                {
                    DeviceInterface.SetAttenuatorLevel((AttLevel)AttLevelcomboBox.SelectedItem, (AttLevel)AttLevelcomboBox.SelectedItem);
                }
                else
                {
                    DeviceInterface.SetAttenuatorLevel((AttLevel)AttLevelcomboBox.SelectedItem, AttLevel._0dB);
                }
            }

            VFOFrequencyTextBox.Text = Utility.GetStringWithSeparators(Program.Save.LastVFOFrequency, " ");
        }