Пример #1
0
        private void buttonDelProfile_Click(object sender, EventArgs e)
        {
            ComboBoxAdvancedPortItem item = (ComboBoxAdvancedPortItem)comboBoxAvailableProfiles.SelectedItem;

            UserPortConf newconf;

            newconf.portname          = item.portname;
            newconf.rememberPermanent = false;

            LastUserPort.setLastPortByUserappID(item.appid, newconf);

            refreshProfileList();
        }
Пример #2
0
        private void selectPort(string portname)
        {
            selectedPort = portname;
            if (portname != "COMX")
            {
                UserPortConf port;
                port.portname          = portname;
                port.rememberPermanent = checkBoxRememberPort.Checked;

                LastUserPort.setLastPortByUserappID(userappid, port);
            }
            Console.WriteLine(portname);
            Application.Exit();
        }
Пример #3
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!");
            }
        }