示例#1
0
        /// <summary>
        /// Add stations for the current port.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event argument.</param>
        private void addStationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (null == this.listBoxPort.SelectedItem)
            {
                return;
            }

            AddItemDlg dlg = new AddItemDlg();
            dlg.ItemLable = "Station";
            DialogResult res = dlg.ShowDialog();
            if (DialogResult.OK == res)
            {
                uint[] output = dlg.Indices;
                PortParam port = null;
                foreach (PortParam item in ports)
                {
                    if (0 == string.Compare(item.DevName, this.listBoxPort.SelectedItem.ToString(),
                        StringComparison.OrdinalIgnoreCase))
                    {
                        port = item;
                        break;
                    }

                }
                for (int i = 0; i < output.Length; ++i)
                {
                    if (port.AddStation(output[i]))
                    {
                        this.checkedListBoxStations.Items.Add(output[i].ToString(), true);
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Add a port to the UI and the port model.
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event argument.</param>
 private void addPortToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AddItemDlg dlg = new AddItemDlg();
     dlg.ItemLable = "COM";
     DialogResult res = dlg.ShowDialog();
     if (DialogResult.OK == res)
     {
         uint[] output = dlg.Indices;
         for (int i = 0; i < output.Length; ++i)
         {
             if (AddPort(dlg.ItemLable + output[i].ToString()))
             {
                 this.listBoxPort.Items.Add(dlg.ItemLable + output[i].ToString());
             }
         }
     }
 }