Skip to content

Commit

Permalink
Exception wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed May 2, 2024
1 parent 8241700 commit ba0bac1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion app/Display/ScreenNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 18 additions & 11 deletions app/Helpers/ClamshellModeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ba0bac1

Please sign in to comment.