Пример #1
0
        void refreshProfileList()
        {
            comboBoxAvailableProfiles.Items.Clear();

            string[] appids = LastUserPort.getAllAppids();
            foreach (string appid in appids)
            {
                UserPortConf portconf = LastUserPort.getLastPortByUserappID(appid);
                if (portconf.rememberPermanent)
                {
                    comboBoxAvailableProfiles.Items.Add(new ComboBoxAdvancedPortItem(portconf.portname, appid, portconf.portname + " (Application \"" + appid + "\")"));
                }
            }

            if (comboBoxAvailableProfiles.Items.Count == 0)
            {
                comboBoxAvailableProfiles.Items.Add("No ports are saved permanently!");
                buttonDelProfile.Enabled = false;
            }
            else
            {
                buttonDelProfile.Enabled = true;
            }

            comboBoxAvailableProfiles.SelectedIndex = 0;
        }
Пример #2
0
        private void refreshPorts()
        {
            comboBoxPorts.Items.Clear();
            string[] apps  = LastUserPort.getAllAppids();
            string[] ports = SerialPort.GetPortNames();
            if (ports.Length == 0)
            {
                MessageBox.Show("No COM-Ports are available on this system!");
                selectPort("COMX");
            }

            UserPortConf previousPort = LastUserPort.getLastPortByUserappID(userappid);

            checkBoxRememberPort.Checked = previousPort.rememberPermanent;

            //set to true if we've found a port that the user has selected before
            bool foundPreviousPort = false;

            foreach (string port in ports)
            {
                PortInfo portinfo = PortInfo.getPortInfoByPortname(port);

                ComboBoxPortItem item = new ComboBoxPortItem(port, portinfo.beautifulFormatted());
                comboBoxPorts.Items.Add(item);
                if (port == previousPort.portname)
                {
                    comboBoxPorts.SelectedItem = item;
                    foundPreviousPort          = true;
                }
            }

            if ((comboBoxPorts.Items.Count > 0) && !foundPreviousPort)
            {
                comboBoxPorts.SelectedIndex = 0;
            }

            //user checked to use this port permanently
            if (previousPort.rememberPermanent && foundPreviousPort)
            {
                selectPort(previousPort.portname);
            }
            else if (previousPort.rememberPermanent && !foundPreviousPort)
            {
                checkBoxRememberPort.Checked   = false;
                previousPort.rememberPermanent = false;
                LastUserPort.setLastPortByUserappID(userappid, previousPort);
                MessageBox.Show("Previously selected port is not available anymore!");
            }
        }