Esempio n. 1
0
        /// <summary>
        /// toolStripMenuItemSerialPort DropDownItemClicke event to select baud rate.
        /// </summary>
        private void toolStripMenuItemBaudRate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if ((ToolStripMenuItem)e.ClickedItem == toolStripMenuItemOther)
            {
                FormGetValue formGetValue = new FormGetValue();
                formGetValue.ShowDialog();
                ((ToolStripMenuItem)e.ClickedItem).Text    = "Other (" + formGetValue.value + ")";
                ((ToolStripMenuItem)e.ClickedItem).Checked = false;
            }

            // Do nothing if baud already selected
            if (((ToolStripMenuItem)e.ClickedItem).Checked)
            {
                return;
            }

            // Check only selected item
            foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemBaudRate).DropDownItems)
            {
                toolStripMenuItem.Checked = false;
            }
            ((ToolStripMenuItem)e.ClickedItem).Checked = true;

            // Open serial port
            if (!OpenSerialPort())
            {
                RefreshSerialPortList();    // refresh port list if open fails, this also ensures port object is closed
            }
        }
        /// <summary>
        /// toolStripMenuItemSerialPort DropDownItemClicke event to select baud rate.
        /// </summary>
        private void toolStripMenuItemBaudRate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if ((ToolStripMenuItem)e.ClickedItem == toolStripMenuItemOther)
            {
                FormGetValue formGetValue = new FormGetValue();
                formGetValue.ShowDialog();
                ((ToolStripMenuItem)e.ClickedItem).Text = "Other (" + formGetValue.value + ")";
                ((ToolStripMenuItem)e.ClickedItem).Checked = false;
            }

            // Do nothing if baud already selected
            if (((ToolStripMenuItem)e.ClickedItem).Checked)
            {
                return;
            }

            // Check only selected item
            foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemBaudRate).DropDownItems)
            {
                toolStripMenuItem.Checked = false;
            }
            ((ToolStripMenuItem)e.ClickedItem).Checked = true;

            // Open serial port
            if (!OpenSerialPort())
            {
                RefreshSerialPortList();    // refresh port list if open fails, this also ensures port object is closed
            }
        }