void detach()
        {
            if (_cameraControl != null)
            {
                if (!_isClosing)
                {
                    EZ_Builder.EZBManager.Log("Detaching from {0}", _cameraControl.Text);
                }

                _cameraControl.Camera.OnNewFrame -= Camera_OnNewFrame;

                _cameraControl = null;
            }

            if (!_isClosing)
            {
                Invokers.SetEnabled(btnAttachCamera, true);
                Invokers.SetText(btnAttachCamera, "Attach Camera");
            }
        }
        void attach()
        {
            detach();

            Control[] cameras = EZ_Builder.EZBManager.FormMain.GetControlByType(typeof(EZ_Builder.UCForms.FormCameraDevice));

            if (cameras.Length == 0)
            {
                MessageBox.Show("There are no camera controls in this project.");

                return;
            }

            foreach (EZ_Builder.UCForms.FormCameraDevice camera in cameras)
            {
                if (camera.Camera.IsActive)
                {
                    this.Invoke(new Action(() => {
                        pictureBox1.Image = new Bitmap(camera.Camera.CaptureWidth, camera.Camera.CaptureHeight, EZ_B.Camera.PixelFormat);

                        _cameraControl = camera;

                        Invokers.SetAppendText(tbLog, true, "Attached to: {0}", _cameraControl.Text);

                        btnAttachCamera.Enabled = true;

                        btnAttachCamera.Text = "Detach Camera";

                        _cameraControl.Camera.OnNewFrame += Camera_OnNewFrame;
                    }));

                    return;
                }
            }

            MessageBox.Show("There are no active cameras in this project. This control will connect to the first active camera that it detects in the project");
        }