示例#1
0
        private void Camera_ConnectionLost(object sender, EventArgs e)
        {
            CameraDisconnected?.Invoke(this, EventArgs.Empty);

            ConnectedCamera = null;
            StartPortsMonitoring();
        }
示例#2
0
        private void Monitor(object state)
        {
            var availableCameras = CameraFinder.Enumerate();

            if (availableCameras.Any() && ConnectedCamera == null)
            {
                try
                {
                    var camera = new Camera();
                    camera.Open();
                    ConnectedCamera = new CameraBasler(camera);
                    ConnectedCamera.SetDefaultSettings();
                    ConnectedCamera.Camera.ConnectionLost += Camera_ConnectionLost;
                    OnCameraConnected();
                    timer.Dispose();
                }
                catch (Exception)
                {
                    OnCameraFailed("The camera is in use by another application. Close the other application to start recording");
                }
            }
            else
            {
                OnCameraFailed("Camera not found");
            }
        }