public override bool Configure(CameraSummary summary, Action disconnect, Action connect)
        {
            bool         needsReconnection = false;
            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null)
            {
                return(false);
            }

            FormConfiguration form = new FormConfiguration(summary, disconnect, connect);

            FormsHelper.Locate(form);
            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.AliasChanged)
                {
                    summary.UpdateAlias(form.Alias, form.PickedIcon);
                }

                if (form.SpecificChanged)
                {
                    info.StreamFormat     = form.SelectedStreamFormat.Symbol;
                    info.Bayer8Conversion = form.Bayer8Conversion;
                    info.CameraProperties = form.CameraProperties;

                    summary.UpdateDisplayRectangle(Rectangle.Empty);
                    needsReconnection = true;
                }

                CameraTypeManager.UpdatedCameraSummary(summary);
            }

            form.Dispose();
            return(needsReconnection);
        }
        private void Thumbnail_SummaryUpdated(object sender, EventArgs e)
        {
            ThumbnailCamera thumbnail = sender as ThumbnailCamera;

            CameraTypeManager.UpdatedCameraSummary(thumbnail.Summary);
        }
Example #3
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            // Locate an .ini file.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title = CameraLang.FormConfiguration_ImportParameters;
            //openFileDialog.InitialDirectory = Path.GetDirectoryName(ProfileHelper.GetProfileFilename(summary.Identifier));
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Filter           = "Ini file (*.ini)" + "|*.ini;";
            openFileDialog.FilterIndex      = 0;
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string filename = openFileDialog.FileName;

            if (string.IsNullOrEmpty(filename) || !File.Exists(filename))
            {
                return;
            }

            // The timing here is finnicky.
            // connect() will start the delay buffer allocation on the current image size and start receiving frames.
            // disconnect prevents reading the new values from the camera.
            // Load with new sizes while the camera is streaming will fail because the buffers are wrong.
            // So we need to load the new values with the camera opened but not streaming.

            this.SuspendLayout();

            disconnect();
            ProfileHelper.Replace(summary.Identifier, filename);

            // Reopen the camera but do not start grabbing.
            uEye.Defines.Status status = camera.Init((Int32)deviceId | (Int32)uEye.Defines.DeviceEnumeration.UseDeviceID);
            if (status != uEye.Defines.Status.SUCCESS)
            {
                log.ErrorFormat("Error trying to open IDS uEye camera.");
                return;
            }

            // Load new parameters.
            ProfileHelper.Load(camera, summary.Identifier);
            cameraProperties = CameraPropertyManager.Read(camera, deviceId);
            SpecificInfo info = summary.Specific as SpecificInfo;

            PopulateStreamFormat();
            info.StreamFormat     = this.SelectedStreamFormat.Value;
            info.CameraProperties = cameraProperties;
            summary.UpdateDisplayRectangle(Rectangle.Empty);
            CameraTypeManager.UpdatedCameraSummary(summary);

            // Reconnect.
            camera.Exit();
            connect();

            // Reload UI.
            RemoveCameraControls();
            PopulateCameraControls();

            this.ResumeLayout();
        }