diff --git a/app/Display/ScreenNative.cs b/app/Display/ScreenNative.cs index e2346aaa5..1b62de449 100644 --- a/app/Display/ScreenNative.cs +++ b/app/Display/ScreenNative.cs @@ -166,7 +166,8 @@ string pProfileName { try { - var devices = GetAllDevices().ToArray(); + var devicesList = GetAllDevices(); + var devices = devicesList.ToArray(); string internalName = AppConfig.GetString("internal_display"); foreach (var device in devices) diff --git a/app/Helpers/ClamshellModeControl.cs b/app/Helpers/ClamshellModeControl.cs index 16b7492e5..c1f6793b2 100644 --- a/app/Helpers/ClamshellModeControl.cs +++ b/app/Helpers/ClamshellModeControl.cs @@ -15,22 +15,29 @@ public ClamshellModeControl() public bool IsExternalDisplayConnected() { - var devices = ScreenInterrogatory.GetAllDevices().ToArray(); + try + { + var devicesList = ScreenInterrogatory.GetAllDevices(); + var devices = devicesList.ToArray(); - string internalName = AppConfig.GetString("internal_display"); + string internalName = AppConfig.GetString("internal_display"); - foreach (var device in devices) - { - if (device.outputTechnology != ScreenInterrogatory.DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL && - device.outputTechnology != ScreenInterrogatory.DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED - && device.monitorFriendlyDeviceName != internalName) + foreach (var device in devices) { - Logger.WriteLine("Found external screen: " + device.monitorFriendlyDeviceName + ":" + device.outputTechnology.ToString()); + if (device.outputTechnology != ScreenInterrogatory.DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL && + device.outputTechnology != ScreenInterrogatory.DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED + && device.monitorFriendlyDeviceName != internalName) + { + Logger.WriteLine("Found external screen: " + device.monitorFriendlyDeviceName + ":" + device.outputTechnology.ToString()); - //Already found one, we do not have to check whether there are more - return true; - } + //Already found one, we do not have to check whether there are more + return true; + } + } + } catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); } return false;