void MainFormLoad(object sender, EventArgs e) { try { SetCameraControlSourceAndResolution(_config.Camera, _config.Resolution); } catch (Exception ex) { LogError("Error during camera initialization: " + ex.Message); return; } try { _cube.Initialize(); // Set the status LED to bright blue _cube.PostCommand("LO"); _cube.PostCommand("LB200"); } catch (Exception ex) { LogError("Error during sugarcube initialization: " + ex.Message); return; } string le = "38"; try { le = _cube.CubeParameters["LE"]; } catch { LogInfo("35mm Focal Length Equivalent was NOT found in the Z string, defaulting to 38"); } if (String.IsNullOrWhiteSpace(le)) { LogInfo("35mm Focal Length Equivalent was NOT set in the Z string, defaulting to 38"); } else { LogInfo("Setting 35mm Focal Length Equivalent to " + le); _35mmFocalEquivalent = le; } }
void MainFormLoad(object sender, EventArgs e) { if (log.IsInfoEnabled) { log.Info("Running mainform onload"); } if (_config.ConfigFileCreated) //we need to initialize the sugar cube config from our default set of parameters { if (log.IsInfoEnabled) { log.Info("Initializing config file from default.cfg"); } _config.ImportConfigFile("default.cfg"); } // Try and start the Upload Manager try { if (log.IsDebugEnabled) { log.Debug("Trying to start the upload manager"); } Process.Start("SugarCube Uploader.exe"); } catch (FileNotFoundException fnf) { if (log.IsErrorEnabled) { log.Error("SugarCube Uploader.exe is missing"); } LogWriteLn("Unable to start the upload manager, SugarCube Uploader.exe is missing"); } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error("Unable to start upload manager", ex); } LogWriteLn("Unable to start the upload manager: " + ex.Message); } // Get the list of all ports into cbCOMPortList string[] serialPorts = SerialPort.GetPortNames(); if (serialPorts.Length > 0) { cbCOMPortList.Items.AddRange(serialPorts); cbCOMPortList.SelectedIndex = 0; if (log.IsDebugEnabled) { log.Debug("Found " + serialPorts.Length + " serial ports"); } } else { if (log.IsErrorEnabled) { log.Error("No serial ports detected on computer"); } LogWriteLn("Oops, there are no serial ports avaialbe on this computer!"); } // Fill camera list combobox with available cameras FillCameraList(); // Select the first one if (cbCameraList.Items.Count > 0) { if (log.IsDebugEnabled) { log.Debug("Initializing camera control, selecting first available camera"); } LogWriteLn("Initializing camera control, selecting first available camera"); cbCameraList.SelectedIndex = 0; } // Fill the resolutions combo box FillResolutionList(); // Set the options from the config file SetOptionsFromConfig(); // Try and initialize the cube try { _cube.Initialize(); LogWriteLn("Cube initialized, the cube is on port " + _cube.PortName); if (log.IsDebugEnabled) { log.Debug("Cube initialized, the cube is on port " + _cube.PortName); } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error("Failed to initialize cube", ex); } LogWriteLn("Unable to automatically initialize SugarCube: " + ex.Message); return; } // Read the Z string ReadZString(_cube.CubeParameters); }