Exemple #1
0
        private void Set_the_Load(object sender, EventArgs e)
        {
            LoadData();
            CaptureDevice = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo Device in CaptureDevice)
            {
                comboBoxCAM1.Items.Add(Device.Name);
                comboBoxCAM2.Items.Add(Device.Name);
            }
            comboBoxCAM1.SelectedIndex = 0;
            comboBoxCAM2.SelectedIndex = 0;

            string[] ComList       = SerialPort.GetPortNames();
            int[]    ComNumberList = new int[ComList.Length];
            for (int i = 0; i < ComList.Length; i++)
            {
                ComNumberList[i] = int.Parse(ComList[i].Substring(3));
            }

            Array.Sort(ComNumberList);

            foreach (int ComNumber in ComNumberList)
            {
                comboBoxRF1.Items.Add("COM" + ComNumber.ToString());
                comboBoxRF2.Items.Add("COM" + ComNumber.ToString());
            }
        }
 private void Form1_Load(object sender, EventArgs e)
 {
     string[] ComList       = SerialPort.GetPortNames();
     int[]    ComNumberList = new int[ComList.Length];
     for (int i = 0; i < ComList.Length; i++)
     {
         ComNumberList[i] = int.Parse(ComList[i].Substring(3));
     }
     Array.Sort(ComNumberList);
     foreach (int ComNumber in ComNumberList)
     {
         cbxComlist.Items.Add("COM" + ComNumber.ToString());
     }
 }
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            string[] ComList = SerialPort.GetPortNames();

            int[] ComNumberList = new int[ComList.Length];
            for (int i = 0; i < ComList.Length; i++)
            {
                ComNumberList[i] = int.Parse(ComList[i].Substring(3));
            }

            Array.Sort(ComNumberList);
            cbxComList.Items.Clear();
            foreach (int ComNumber in ComNumberList)
            {
                cbxComList.Items.Add("COM" + ComNumber.ToString());
            }

            bool found = false;

            foreach (string str in cbxComList.Items)
            {
                if (str == Properties.Settings.Default.PortName)
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                cbxComList.Text = Properties.Settings.Default.PortName;
            }

            chkAutoConnect.Checked = Properties.Settings.Default.AutoConnect;
            if (Properties.Settings.Default.AutoConnect)
            {
                if (e == null)
                {
                    button1_Click(null, null);
                }
            }
        }