Example #1
0
        private void AddDeviceForm()
        {
            if (InvokeRequired)
            {
                try
                {
                    Invoke((Delegate) new AddDeviceFormDelegate(AddDeviceForm));
                }
                catch { }
            }
            else
            {
                m_mutex.WaitOne();
                DeviceForm deviceForm = new DeviceForm();
                if (deviceForm == null)
                {
                    return;
                }
                deviceForm.BDAddressNotify     += new EventHandler(DeviceBDAddressNotify);
                deviceForm.ConnectionNotify    += new EventHandler(DeviceConnectionNotify);
                deviceForm.DisconnectionNotify += new EventHandler(DeviceDisconnectionNotify);
                deviceForm.ChangeActiveRoot    += new EventHandler(DeviceChangeActiveRoot);
                deviceForm.CloseActiveDevice   += new EventHandler(DeviceCloseActiveDevice);

                if (deviceForm.DeviceFormInit())
                {
                    deviceForm.TopLevel = false;
                    deviceForm.Parent   = plDevice;
                    deviceForm.Dock     = DockStyle.Fill;
                    foreach (Control control in plDevice.Controls)
                    {
                        if (control.GetType().BaseType == typeof(Form))
                        {
                            Form form = (Form)control;
                            if (form.Visible)
                            {
                                form.Hide();
                                break;
                            }
                        }
                    }
                    deviceForm.Show();
                    AddToTreeDeviceInfo(deviceForm.devInfo, deviceForm);
                    comPortTreeForm.ClearSelectedNode();
                    deviceForm.SendGAPDeviceInit();
                }
                else
                {
                    deviceForm.DeviceFormClose(false);
                }

                m_mutex.ReleaseMutex();
            }
        }
Example #2
0
        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();
        }
Example #3
0
        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);
        }