public FormConfiguration(CameraSummary summary) { this.summary = summary; InitializeComponent(); tbAlias.AutoSize = false; tbAlias.Height = 20; tbAlias.Text = summary.Alias; lblSystemName.Text = summary.Name; btnIcon.BackgroundImage = summary.Icon; SpecificInfo specific = summary.Specific as SpecificInfo; if (specific == null || specific.Camera == null || !specific.Camera.IsOpened) { return; } camera = specific.Camera; int temp; camera.Device.GetDeviceID(out temp); deviceId = (long)temp; cameraProperties = CameraPropertyManager.Read(camera, deviceId); if (cameraProperties.Count != specific.CameraProperties.Count) { specificChanged = true; } Populate(); }
private void ReloadProperty(string key) { if (!propertiesControls.ContainsKey(key) || !cameraProperties.ContainsKey(key)) { return; } // Reload the property in case the range or current value changed. CameraProperty prop = CameraPropertyManager.Read(camera, deviceId, key); if (prop == null) { return; } cameraProperties[key] = prop; propertiesControls[key].Repopulate(prop); }
public FormConfiguration(CameraSummary summary, Action disconnect, Action connect) { this.summary = summary; this.disconnect = disconnect; this.connect = connect; InitializeComponent(); tbAlias.AutoSize = false; tbAlias.Height = 20; tbAlias.Text = summary.Alias; lblSystemName.Text = summary.Name; btnIcon.BackgroundImage = summary.Icon; btnReconnect.Text = CameraLang.FormConfiguration_Reconnect; btnImport.Text = CameraLang.FormConfiguration_ImportParameters; SpecificInfo specific = summary.Specific as SpecificInfo; if (specific == null || specific.Camera == null || !specific.Camera.IsOpened) { return; } camera = specific.Camera; int temp; camera.Device.GetDeviceID(out temp); deviceId = (long)temp; cameraProperties = CameraPropertyManager.Read(camera, deviceId); if (cameraProperties.Count != specific.CameraProperties.Count) { specificChanged = true; } Populate(); this.Text = CameraLang.FormConfiguration_Title; btnApply.Text = CameraLang.Generic_Apply; }
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(); }