private void tsmiCloseDevice_Click(object sender, EventArgs e) { m_mutex.WaitOne(); DeviceForm activeDeviceForm = GetActiveDeviceForm(); if (activeDeviceForm != null) { activeDeviceForm.DeviceFormClose(true); activeDeviceForm.Close(); comPortTreeForm.RemovePort(activeDeviceForm.devInfo.ComPortInfo.ComPort); } comPortTreeForm.FindNodeToOpen(); m_mutex.ReleaseMutex(); }
public bool RemoveAll() { bool flag = false; if (tvPorts.Nodes != null) { foreach (TreeNode treeNode in tvPorts.Nodes) { if (treeNode != null) { DeviceForm deviceForm = ((DeviceInfo)treeNode.Tag).DevForm; deviceForm.DeviceFormClose(true); deviceForm.Close(); treeViewUtils.RemoveTextFromTree((TreeView)tvPorts, deviceForm.devInfo.ComPortInfo.ComPort); } } } else { flag = false; } return(flag); }