private void ctxMenuPortsTable_Opening(object sender, CancelEventArgs e) { //Don't show the "KILL" menu if the serial port is not opened. if (listPortTable.SelectedIndices.Count < 0) { menuKill.Visible = false; return; } string strPort = listPortTable.SelectedItems[0].SubItems[0].Text; ComPortItem item = ComPortControlTable.GetItemByPortName(strPort); if (item == null || item.OwnProcessId <= 0) { menuKill.Visible = false; return; } menuKill.Visible = true; menuEnableAutoRefresh.Checked = AppConfig.EnableAutoRefresh; menuOwnerFormatDomainUser.Checked = (AppConfig.OwnerFormat == OwnerShowFormat.DomainUser); menuOwnerFormatFullName.Checked = (AppConfig.OwnerFormat == OwnerShowFormat.FullName); menuOwnerFormatShortName.Checked = (AppConfig.OwnerFormat == OwnerShowFormat.ShortName || AppConfig.OwnerFormat == OwnerShowFormat.Default); menuOwnerFormatPhone.Checked = (AppConfig.OwnerFormat == OwnerShowFormat.Phone); }
private void listPortTable_DoubleClick(object sender, EventArgs e) { if (listPortTable.SelectedIndices.Count <= 0) { return; } string portName = listPortTable.SelectedItems[0].Text; ComPortItem item = ComPortControlTable.GetItemByPortName(portName); if (item == null || item.OwnProcessId < 0 || item.OwnUser == null) { return; } new ComPortShowDialog(item).ShowDialog(); }
/// <summary> /// Create row for each COM port and initialize it to empty except port name. /// </summary> private void CreateRows() { listPortTable.BeginUpdate(); listPortTable.Items.Clear(); string[] ports = ComPortControlTable.AllPortNames; comboBoxGotoPort.Items.Clear(); comboBoxGotoPort.Items.AddRange(ports); foreach (string port in ports) { ListViewItem lvi = new ListViewItem(new string[] { port, string.Empty, string.Empty, string.Empty }); listPortTable.Items.Add(lvi); ComPortItem item = ComPortControlTable.GetItemByPortName(port); if (item != null) { item.GuiItem = lvi; } } listPortTable.EndUpdate(); }