diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs index 54abb4a..1509888 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.cs @@ -56,8 +56,8 @@ namespace DisplayMagician.UIForms // Apply the Profile if (ProfileRepository.ApplyProfile(_selectedProfile) == ApplyProfileResult.Successful) { - /*logger.Error($"DisplayProfileForm/Apply_Click: Waiting 0.5 sec for the display to apply"); - System.Threading.Thread.Sleep(500);*/ + logger.Error($"DisplayProfileForm/Apply_Click: Waiting 0.5 sec for the display to apply"); + System.Threading.Thread.Sleep(500); ChangeSelectedProfile(_selectedProfile); } } diff --git a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs index 5721da3..b39dbc0 100644 --- a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs +++ b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs @@ -1250,40 +1250,36 @@ namespace DisplayMagicianShared.NVIDIA // Now, we have the current HDR settings, and the existing HDR settings, so we go through and we attempt to set each display color settings foreach (var wantedHdrColorData in displayConfig.HdrConfig.HdrColorData) { - // If we have HDR settings stored for the display, then attempt to set them - if (currentDisplayConfig.HdrConfig.HdrColorData.ContainsKey(wantedHdrColorData.Key)) + // Now we set the HDR colour settings of the display + NV_HDR_COLOR_DATA_V2 hdrColorData = wantedHdrColorData.Value; + NVStatus = NVImport.NvAPI_Disp_HdrColorControl(wantedHdrColorData.Key, ref hdrColorData); + if (NVStatus == NVAPI_STATUS.NVAPI_OK) { - // Now we set the HDR colour settings of the display - NV_HDR_COLOR_DATA_V2 hdrColorData = wantedHdrColorData.Value; - NVStatus = NVImport.NvAPI_Disp_HdrColorControl(wantedHdrColorData.Key, ref hdrColorData); - if (NVStatus == NVAPI_STATUS.NVAPI_OK) - { - SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: NvAPI_Disp_HdrColorControl returned OK. We just successfully set the HDR mode to {hdrColorData.HdrMode.ToString("G")}"); - } - else if (NVStatus == NVAPI_STATUS.NVAPI_INSUFFICIENT_BUFFER) - { - SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input buffer is not large enough to hold it's contents. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); - } - else if (NVStatus == NVAPI_STATUS.NVAPI_INVALID_DISPLAY_ID) - { - SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input monitor is either not connected or is not a DP or HDMI panel. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); - } - else if (NVStatus == NVAPI_STATUS.NVAPI_API_NOT_INITIALIZED) - { - SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The NvAPI API needs to be initialized first. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); - } - else if (NVStatus == NVAPI_STATUS.NVAPI_NO_IMPLEMENTATION) - { - SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: This entry point not available in this NVIDIA Driver. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); - } - else if (NVStatus == NVAPI_STATUS.NVAPI_ERROR) - { - SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: A miscellaneous error occurred. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); - } - else - { - SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {wantedHdrColorData.Key} doesn't support HDR."); - } + SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: NvAPI_Disp_HdrColorControl returned OK. We just successfully set the HDR mode to {hdrColorData.HdrMode.ToString("G")}"); + } + else if (NVStatus == NVAPI_STATUS.NVAPI_INSUFFICIENT_BUFFER) + { + SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input buffer is not large enough to hold it's contents. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); + } + else if (NVStatus == NVAPI_STATUS.NVAPI_INVALID_DISPLAY_ID) + { + SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The input monitor is either not connected or is not a DP or HDMI panel. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); + } + else if (NVStatus == NVAPI_STATUS.NVAPI_API_NOT_INITIALIZED) + { + SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: The NvAPI API needs to be initialized first. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); + } + else if (NVStatus == NVAPI_STATUS.NVAPI_NO_IMPLEMENTATION) + { + SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: This entry point not available in this NVIDIA Driver. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); + } + else if (NVStatus == NVAPI_STATUS.NVAPI_ERROR) + { + SharedLogger.logger.Warn($"NVIDIALibrary/SetActiveConfig: A miscellaneous error occurred. NvAPI_Disp_HdrColorControl() returned error code {NVStatus}"); + } + else + { + SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {wantedHdrColorData.Key} doesn't support HDR."); } }