Example #1
0
        private void ConnectToCamera()
        {
            var chooser = new ASCOM.Utilities.Chooser();

            chooser.DeviceType = VIDEO_DEVICE_TYPE;
            string progId = chooser.Choose(VIDEO_DRIVER_NAME);

            if (!string.IsNullOrEmpty(progId))
            {
                videoObject = VideoWrapper.CreateVideoWrapper(progId);

                try
                {
                    Cursor = Cursors.WaitCursor;
                    videoObject.Connected = true;

                    if (videoObject.Connected)
                    {
                        if (videoObject.SupporstFreeStyleGain)
                        {
                            videoObject.SetFreeRangeGainIntervals(Settings.Default.FreeRangeGainIntervals);
                        }

                        imageWidth       = videoObject.Width;
                        imageHeight      = videoObject.Height;
                        pictureBox.Image = new Bitmap(imageWidth, imageHeight);

                        ResizeVideoFrameTo(imageWidth, imageHeight);
                    }
                }
                finally
                {
                    Cursor = Cursors.Default;
                }


                pictureBox.Width  = videoObject.Width;
                pictureBox.Height = videoObject.Height;

                UpdateCameraState(true);
            }
        }