/// <summary> /// Detect GPU type and update corresponding settings and GUI state /// </summary> private void SetGPUType() { // Detect GPU type GPUDetection.GraphicsCardType detected = GPUDetection.GraphicsCardType.UNKNOWN; try { detected = GPUDetection.Detect(); } catch { // Handle error detecting GPU type Debug.WriteLine("Error detecting GPU type; leaving default set"); return; } // Handle inability to detect GPU type if (detected == GPUDetection.GraphicsCardType.UNKNOWN) { Debug.WriteLine("Unable to detect GPU type; leaving default set"); return; } // If detected GPU type does not match saved GPU type if (Properties.Settings.Default.graphicsCardType != "" && Properties.Settings.Default.graphicsCardType != detected.ToString()) { // Note: this is disabled because the GPU selection menu has been hidden (automatic detection has been 100% reliable) // Common.ShowMessageBox(Common.MSG_GPU_TYPE_DIFFERS, MessageBoxButtons.OK, MessageBoxIcon.Warning); } // Update menu state switch (detected) { case GPUDetection.GraphicsCardType.NVIDIA: NVIDIAToolStripMenuItem.Checked = true; AMDToolStripMenuItem.Checked = false; Properties.Settings.Default.graphicsCardType = GPUDetection.GraphicsCardType.NVIDIA.ToString(); break; case GPUDetection.GraphicsCardType.AMD: AMDToolStripMenuItem.Checked = true; NVIDIAToolStripMenuItem.Checked = false; Properties.Settings.Default.graphicsCardType = GPUDetection.GraphicsCardType.AMD.ToString(); break; } // Save updated setting Properties.Settings.Default.Save(); }
/// <summary> /// Set extended display mode /// </summary> private void SetExtendedMode() { string extended_mode_name = null; GPUDetection.GraphicsCardType gct = GPUDetection.GraphicsCardType.UNKNOWN; try { gct = (GPUDetection.GraphicsCardType)Enum.Parse(typeof(GPUDetection.GraphicsCardType), Properties.Settings.Default.graphicsCardType); } catch (ArgumentException) { } switch (gct) { case GPUDetection.GraphicsCardType.NVIDIA: extended_mode_name = Common.EXTENDED_MODE_NAME_NVIDIA; break; case GPUDetection.GraphicsCardType.AMD: extended_mode_name = Common.EXTENDED_MODE_NAME_AMD; break; case GPUDetection.GraphicsCardType.UNKNOWN: ShowSelectGPUTypeDialog(); return; } string osvrPath = OSVRRegistry.GetInstallDirectoryFromRegistry(); string workingDirectory = osvrPath + Common.SERVICE_PATH; string completeFilePath = workingDirectory + extended_mode_name; Process em_exe = OSVRProcessManager.LaunchExecutable(completeFilePath, workingDirectory, ProcessWindowStyle.Normal, string.Empty); if (em_exe == null) { Common.ShowMessageBox(Common.MSG_MISSING_EM_EXE, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } em_exe.EnableRaisingEvents = true; em_exe.Exited += setExtendedModeProcess_Exited; }