mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Increased logging and improved uplay library processing
This commit is contained in:
parent
bf2f95a992
commit
e893fbac69
@ -1,75 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using Microsoft.QueryStringDotNET;
|
||||
using System.Windows.Forms;
|
||||
using DisplayMagician.UIForms;
|
||||
using DisplayMagicianShared;
|
||||
|
||||
namespace DisplayMagician
|
||||
{
|
||||
// The GUID must be unique to your app. Create a new GUID if copying this code.
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
[ComSourceInterfaces(typeof(INotificationActivationCallback))]
|
||||
[Guid(Program.AppActivationId), ComVisible(true)]
|
||||
|
||||
public class DesktopNotificationActivator : NotificationActivator
|
||||
{
|
||||
public override void OnActivated(string arguments, NotificationUserInput userInput, string appUserModelId)
|
||||
{
|
||||
// Invoke the code we're running on the UI Thread to avoid
|
||||
// cross thread exceptions
|
||||
Program.AppMainForm.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
// This code is running on the main UI thread!
|
||||
// Parse the query string (using NuGet package QueryString.NET)
|
||||
QueryString args = QueryString.Parse(arguments);
|
||||
|
||||
foreach (QueryStringParameter myArg in args)
|
||||
{
|
||||
if (myArg.Name.Equals("action",StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// See what action is being requested
|
||||
switch (args["action"])
|
||||
{
|
||||
// Open the Main window
|
||||
case "open":
|
||||
|
||||
// Open the Main DisplayMagician Window
|
||||
Program.AppMainForm.openApplicationWindow();
|
||||
break;
|
||||
|
||||
// Exit the application
|
||||
case "exit":
|
||||
|
||||
// Exit the application (overriding the close restriction)
|
||||
Program.AppMainForm.exitApplication();
|
||||
break;
|
||||
|
||||
// Stop waiting so that the monitoring stops, and the UI becomes free
|
||||
case "stopWaiting":
|
||||
|
||||
Program.AppCancellationTokenSource.Cancel();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void OpenWindowIfNeeded()
|
||||
{
|
||||
// Make sure we have a window open (in case user clicked toast while app closed)
|
||||
if (Program.AppMainForm == null)
|
||||
{
|
||||
Program.AppMainForm = new MainForm();
|
||||
}
|
||||
|
||||
// Activate the window, bringing it to focus
|
||||
Program.AppMainForm.openApplicationWindow();
|
||||
}
|
||||
}
|
||||
}
|
@ -96,7 +96,6 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DesktopNotificationActivator.cs" />
|
||||
<Compile Include="GameLibraries\GOGGame.cs" />
|
||||
<Compile Include="GameLibraries\GOGLibrary.cs" />
|
||||
<Compile Include="GameLibraries\Game.cs" />
|
||||
|
@ -175,6 +175,7 @@ namespace DisplayMagician.GameLibraries
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"EpicLibrary/IsRunning: Exception while trying to get the Epic Library processes with names: {_epicProcessList.ToString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,8 @@ namespace DisplayMagician.GameLibraries
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex) {
|
||||
logger.Warn(ex, $"GogLibrary/IsRunning: Exception while trying to get the GOG Library processes with names: {_gogProcessList.ToString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ namespace DisplayMagician.GameLibraries
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"OriginLibrary/IsRunning: Exception while trying to get the Origin Library processes with names: {_originProcessList.ToString()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -193,6 +193,7 @@ namespace DisplayMagician.GameLibraries
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"SteamLibrary/IsRunning: Exception while trying to get the steam library processes matching process names: {_steamProcessList.ToString()}.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ namespace DisplayMagician.GameLibraries
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"UplayLibrary/IsRunning: Exception while trying to get the Uplay Library processes with names: {_uplayProcessList.ToString()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -589,245 +590,253 @@ namespace DisplayMagician.GameLibraries
|
||||
|
||||
// Now we'll try to sort out the rest of the game data!
|
||||
// We first look for the online executable information
|
||||
if (root.start_game.online.executables.Count > 0)
|
||||
if (root.GetType().GetProperty("start_game") != null)
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay game {gameName} has some online executables to process! ");
|
||||
|
||||
// First up we look at the online games, cause they're just better!
|
||||
foreach (var executable in root.start_game.online.executables)
|
||||
if (root.start_game.GetType().GetProperty("online") != null && root.start_game.online.executables.Count > 0)
|
||||
{
|
||||
string exePath = "";
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay game {gameName} has some online executables to process! ");
|
||||
|
||||
// Check if its a full path or a relative path
|
||||
if (!String.IsNullOrEmpty(executable.path.relative))
|
||||
// First up we look at the online games, cause they're just better!
|
||||
foreach (var executable in root.start_game.online.executables)
|
||||
{
|
||||
if (executable.working_directory.register.StartsWith("HKEY_LOCAL_MACHINE"))
|
||||
{
|
||||
// This copes with relative files using a HKEY_LOCAL_MACHINE registry
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
if (this.GetInstallDirFromRegKey(regKeyText, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses local machine registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}
|
||||
/*else if (executable.working_directory.register.StartsWith("HKEY_CURRENT_USER"))
|
||||
{
|
||||
// This copes with relative files using a HKEY_CURRENT_USER registry
|
||||
string exePath = "";
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
|
||||
if (this.GetInstallDirFromRegKey(executable.working_directory.register, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses current user registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}*/
|
||||
else if (!String.IsNullOrEmpty(executable.working_directory.append))
|
||||
// Check if its a full path or a relative path
|
||||
if (!String.IsNullOrEmpty(executable.path.relative))
|
||||
{
|
||||
// This copes with relative files using an appended path
|
||||
gameExePath = Path.Combine(executable.working_directory.append, executable.path.relative);
|
||||
gameIconPath = Path.Combine(executable.working_directory.append, executable.icon_image);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses appended file path: {executable.working_directory.append} ");
|
||||
gameId = productInfo.uplay_id.ToString();
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
if (executable.working_directory.register.StartsWith("HKEY_LOCAL_MACHINE"))
|
||||
{
|
||||
// This copes with relative files using a HKEY_LOCAL_MACHINE registry
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
if (this.GetInstallDirFromRegKey(regKeyText, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses local machine registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}
|
||||
/*else if (executable.working_directory.register.StartsWith("HKEY_CURRENT_USER"))
|
||||
{
|
||||
// This copes with relative files using a HKEY_CURRENT_USER registry
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
|
||||
if (this.GetInstallDirFromRegKey(executable.working_directory.register, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses current user registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}*/
|
||||
else if (!String.IsNullOrEmpty(executable.working_directory.append))
|
||||
{
|
||||
// This copes with relative files using an appended path
|
||||
gameExePath = Path.Combine(executable.working_directory.append, executable.path.relative);
|
||||
gameIconPath = Path.Combine(executable.working_directory.append, executable.icon_image);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses appended file path: {executable.working_directory.append} ");
|
||||
gameId = productInfo.uplay_id.ToString();
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Problem!
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found relative GameExePath {executable.path.relative} for Uplay game {gameName} but no registry key or appended file path! Skipping this game.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Problem!
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found relative GameExePath {executable.path.relative} for Uplay game {gameName} but no registry key or appended file path! Skipping this game.");
|
||||
// This should cope with full pathed files, but we have no examples to test! So log it
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found non-relative GameExePath {executable.path} for Uplay game {gameName} but we've not seen it before so no idea how to handle it! Skipping this game.");
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: executable.path for troubleshooting: {executable.path}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This should cope with full pathed files, but we have no examples to test! So log it
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found non-relative GameExePath {executable.path} for Uplay game {gameName} but we've not seen it before so no idea how to handle it! Skipping this game.");
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: executable.path for troubleshooting: {executable.path}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// We should check the exe file exists, and if it doesn't then we need to do the next exe
|
||||
if (!File.Exists(gameExePath))
|
||||
{
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Couldn't find the GameExePath {gameExePath} for Uplay game {gameName} so skipping this exe, and trying the next one.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now try to get the Uplay game icon
|
||||
if (!String.IsNullOrEmpty(root.icon_image))
|
||||
{
|
||||
gameIconPath = Path.Combine(_uplayPath, "data", "games", root.icon_image);
|
||||
|
||||
// If the icon file isn't actually there, then use the game exe instead.
|
||||
if (!File.Exists(gameIconPath))
|
||||
// We should check the exe file exists, and if it doesn't then we need to do the next exe
|
||||
if (!File.Exists(gameExePath))
|
||||
{
|
||||
gameIconPath = gameExePath;
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Couldn't find the GameExePath {gameExePath} for Uplay game {gameName} so skipping this exe, and trying the next one.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found GameExePath {exePath} and Icon Path {gameIconPath} for Uplay game {gameName}.");
|
||||
|
||||
// We do a final check to make sure that we do have a GameName, and if not we use the shortcut
|
||||
if (String.IsNullOrEmpty(gameName) && !String.IsNullOrEmpty(executable.shortcut_name))
|
||||
{
|
||||
gameName = executable.shortcut_name;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Game Name was still empty, so we're using the shortcut name as a last resort: {executable.shortcut_name} ");
|
||||
// Now try to get the Uplay game icon
|
||||
if (!String.IsNullOrEmpty(root.icon_image))
|
||||
{
|
||||
gameIconPath = Path.Combine(_uplayPath, "data", "games", root.icon_image);
|
||||
|
||||
// If the icon file isn't actually there, then use the game exe instead.
|
||||
if (!File.Exists(gameIconPath))
|
||||
{
|
||||
gameIconPath = gameExePath;
|
||||
}
|
||||
}
|
||||
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found GameExePath {exePath} and Icon Path {gameIconPath} for Uplay game {gameName}.");
|
||||
|
||||
// We do a final check to make sure that we do have a GameName, and if not we use the shortcut
|
||||
if (String.IsNullOrEmpty(gameName) && !String.IsNullOrEmpty(executable.shortcut_name))
|
||||
{
|
||||
gameName = executable.shortcut_name;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Game Name was still empty, so we're using the shortcut name as a last resort: {executable.shortcut_name} ");
|
||||
}
|
||||
|
||||
// Now we need to save the game name, cause if we're here then we're good enough to save
|
||||
// Then we have the gameID, the thumbimage, the icon, the name, the exe path
|
||||
// And we add the Game to the list of games we have!
|
||||
_allGames.Add(new UplayGame(gameId, gameName, gameExePath, gameIconPath));
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Adding Uplay Game with game id {productInfo.uplay_id}, name {gameName}, game exe {gameExePath} and icon path {gameIconPath}");
|
||||
break;
|
||||
}
|
||||
|
||||
// Now we need to save the game name, cause if we're here then we're good enough to save
|
||||
// Then we have the gameID, the thumbimage, the icon, the name, the exe path
|
||||
// And we add the Game to the list of games we have!
|
||||
_allGames.Add(new UplayGame(gameId, gameName, gameExePath, gameIconPath));
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Adding Uplay Game with game id {productInfo.uplay_id}, name {gameName}, game exe {gameExePath} and icon path {gameIconPath}");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// This is the offline exes
|
||||
else if (root.start_game.offline.executables.Count > 0)
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay game {gameName} has some offline executables to process! ");
|
||||
|
||||
// we look at the offline games, cause there weren't any online ones
|
||||
foreach (var executable in root.start_game.offline.executables)
|
||||
// This is the offline exes
|
||||
else if (root.start_game.GetType().GetProperty("offline") != null && root.start_game.offline.executables.Count > 0)
|
||||
{
|
||||
string exePath = "";
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay game {gameName} has some offline executables to process! ");
|
||||
|
||||
// Check if its a full path or a relative path
|
||||
if (!String.IsNullOrEmpty(executable.path.relative))
|
||||
// we look at the offline games, cause there weren't any online ones
|
||||
foreach (var executable in root.start_game.offline.executables)
|
||||
{
|
||||
if (executable.working_directory.register.StartsWith("HKEY_LOCAL_MACHINE"))
|
||||
string exePath = "";
|
||||
|
||||
// Check if its a full path or a relative path
|
||||
if (!String.IsNullOrEmpty(executable.path.relative))
|
||||
{
|
||||
// This copes with relative files using a HKEY_LOCAL_MACHINE registry
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
|
||||
if (this.GetInstallDirFromRegKey(regKeyText, out exePath))
|
||||
if (executable.working_directory.register.StartsWith("HKEY_LOCAL_MACHINE"))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses local machine registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
// This copes with relative files using a HKEY_LOCAL_MACHINE registry
|
||||
|
||||
}
|
||||
/*else if (executable.working_directory.register.StartsWith("HKEY_CURRENT_USER"))
|
||||
{
|
||||
// This copes with relative files using a HKEY_CURRENT_USER registry
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
if (this.GetInstallDirFromRegKey(regKeyText, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses local machine registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
|
||||
if (this.GetInstallDirFromRegKey(executable.working_directory.register, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses current user registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
/*else if (executable.working_directory.register.StartsWith("HKEY_CURRENT_USER"))
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
// This copes with relative files using a HKEY_CURRENT_USER registry
|
||||
|
||||
string regKeyText = executable.working_directory.register;
|
||||
regKeyText = regKeyText.Replace(@"\InstallDir", "");
|
||||
regKeyText = regKeyText.Replace(@"Ubisoft", @"WOW6432Node\Ubisoft");
|
||||
logger.Trace($"UplayLibrary/GetInstallDirFromRegKey: Accessing HKLM reg key {regKeyText}");
|
||||
|
||||
if (this.GetInstallDirFromRegKey(executable.working_directory.register, out exePath))
|
||||
{
|
||||
gameExePath = Path.Combine(exePath, executable.path.relative);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses current user registry key: {executable.working_directory.register} ");
|
||||
}
|
||||
// Get the GameID from the reg key
|
||||
string pattern = @"Installs\\(\d+)\\InstallDir";
|
||||
MatchCollection mc = Regex.Matches(executable.working_directory.register, pattern);
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
gameId = mc[0].Groups[1].Value;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}*/
|
||||
else if (!String.IsNullOrEmpty(executable.working_directory.append))
|
||||
{
|
||||
// This copes with relative files using an appended path
|
||||
gameExePath = Path.Combine(executable.working_directory.append, executable.path.relative);
|
||||
gameIconPath = Path.Combine(executable.working_directory.append, executable.icon_image);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses appended file path: {executable.working_directory.append} ");
|
||||
gameId = productInfo.uplay_id.ToString();
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Problem!
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found relative GameExePath {executable.path.relative} for Uplay game {gameName} but no registry key or appended file path! Skipping this game.");
|
||||
continue;
|
||||
}
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}*/
|
||||
else if (!String.IsNullOrEmpty(executable.working_directory.append))
|
||||
{
|
||||
// This copes with relative files using an appended path
|
||||
gameExePath = Path.Combine(executable.working_directory.append, executable.path.relative);
|
||||
gameIconPath = Path.Combine(executable.working_directory.append, executable.icon_image);
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Relative executable uses appended file path: {executable.working_directory.append} ");
|
||||
gameId = productInfo.uplay_id.ToString();
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Got uplay Game ID: {gameId} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Problem!
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found relative GameExePath {executable.path.relative} for Uplay game {gameName} but no registry key or appended file path! Skipping this game.");
|
||||
// This should cope with full pathed files, but we have no examples to test! So log it
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found non-relative GameExePath {executable.path} for Uplay game {gameName} but we've not seen it before so no idea how to handle it! Skipping this game.");
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: executable.path for troubleshooting: {executable.path}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This should cope with full pathed files, but we have no examples to test! So log it
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Found non-relative GameExePath {executable.path} for Uplay game {gameName} but we've not seen it before so no idea how to handle it! Skipping this game.");
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: executable.path for troubleshooting: {executable.path}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// We should check the exe file exists, and if it doesn't then we need to do the next exe
|
||||
if (!File.Exists(gameExePath))
|
||||
{
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Couldn't find the GameExePath {gameExePath} for Uplay game {gameName} so skipping this exe, and trying the next one.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now try to get the Uplay game icon
|
||||
if (!String.IsNullOrEmpty(root.icon_image))
|
||||
{
|
||||
gameIconPath = Path.Combine(_uplayPath, "data", "games", root.icon_image);
|
||||
|
||||
// If the icon file isn't actually there, then use the game exe instead.
|
||||
if (!File.Exists(gameIconPath))
|
||||
// We should check the exe file exists, and if it doesn't then we need to do the next exe
|
||||
if (!File.Exists(gameExePath))
|
||||
{
|
||||
gameIconPath = gameExePath;
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Couldn't find the GameExePath {gameExePath} for Uplay game {gameName} so skipping this exe, and trying the next one.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now try to get the Uplay game icon
|
||||
if (!String.IsNullOrEmpty(root.icon_image))
|
||||
{
|
||||
gameIconPath = Path.Combine(_uplayPath, "data", "games", root.icon_image);
|
||||
|
||||
// If the icon file isn't actually there, then use the game exe instead.
|
||||
if (!File.Exists(gameIconPath))
|
||||
{
|
||||
gameIconPath = gameExePath;
|
||||
}
|
||||
}
|
||||
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found GameExePath {exePath} and Icon Path {gameIconPath} for Uplay game {gameName}.");
|
||||
|
||||
// We do a final check to make sure that we do have a GameName, and if not we use the shortcut
|
||||
if (String.IsNullOrEmpty(gameName) && !String.IsNullOrEmpty(executable.shortcut_name))
|
||||
{
|
||||
gameName = executable.shortcut_name;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Game Name was still empty, so we're using the shortcut name as a last resort: {executable.shortcut_name} ");
|
||||
}
|
||||
|
||||
// Now we need to save the game name, cause if we're here then we're good enough to save
|
||||
// Then we have the gameID, the thumbimage, the icon, the name, the exe path
|
||||
// And we add the Game to the list of games we have!
|
||||
_allGames.Add(new UplayGame(gameId, gameName, gameExePath, gameIconPath));
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Adding Uplay Game with game id {productInfo.uplay_id}, name {gameName}, game exe {gameExePath} and icon path {gameIconPath}");
|
||||
break;
|
||||
}
|
||||
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Found GameExePath {exePath} and Icon Path {gameIconPath} for Uplay game {gameName}.");
|
||||
|
||||
// We do a final check to make sure that we do have a GameName, and if not we use the shortcut
|
||||
if (String.IsNullOrEmpty(gameName) && !String.IsNullOrEmpty(executable.shortcut_name))
|
||||
{
|
||||
gameName = executable.shortcut_name;
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Game Name was still empty, so we're using the shortcut name as a last resort: {executable.shortcut_name} ");
|
||||
}
|
||||
|
||||
// Now we need to save the game name, cause if we're here then we're good enough to save
|
||||
// Then we have the gameID, the thumbimage, the icon, the name, the exe path
|
||||
// And we add the Game to the list of games we have!
|
||||
_allGames.Add(new UplayGame(gameId, gameName, gameExePath, gameIconPath));
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Adding Uplay Game with game id {productInfo.uplay_id}, name {gameName}, game exe {gameExePath} and icon path {gameIconPath}");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay Entry {gameName} doesn't have any online or offline executable associated with it! We have to skip adding this game.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: Uplay Entry {gameName} doesn't have any executables associated with it! We have to skip adding this game.");
|
||||
@ -840,12 +849,12 @@ namespace DisplayMagician.GameLibraries
|
||||
// If we get an error processing the game YAML, lets try and skip this game and try the next one. It might work!
|
||||
if (item.GameInfo.StartsWith("root:"))
|
||||
{
|
||||
logger.Warn($"UplayLibrary/LoadInstalledGames: Problem deserialising the YAML embedded in the Uplay configuration file {uplayConfigFilePath}. Cannot process this Uplay game! (Uplay ID:{item.UplayId}): {item.GameInfo}");
|
||||
logger.Warn(ex, $"UplayLibrary/LoadInstalledGames: Problem deserialising the YAML embedded in the Uplay configuration file {uplayConfigFilePath}. Cannot process this Uplay game! (Uplay ID:{item.UplayId}): {item.GameInfo}");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Trace($"UplayLibrary/LoadInstalledGames: This Uplay entry (Uplay ID:{item.UplayId}) in the Uplay configuration file {uplayConfigFilePath} is not a YAML config so skipping: {item.GameInfo}");
|
||||
logger.Trace(ex, $"UplayLibrary/LoadInstalledGames: This Uplay entry (Uplay ID:{item.UplayId}) in the Uplay configuration file {uplayConfigFilePath} is not a YAML config so skipping: {item.GameInfo}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -855,7 +864,7 @@ namespace DisplayMagician.GameLibraries
|
||||
catch (Exception ex)
|
||||
{
|
||||
// We can't do anything if we hit here.
|
||||
logger.Error($"UplayLibrary/LoadInstalledGames: Problem deserialising the protobuf Uplay configuration file {uplayConfigFilePath}. Cannot process any Uplay games!");
|
||||
logger.Error(ex, $"UplayLibrary/LoadInstalledGames: Problem deserialising the protobuf Uplay configuration file {uplayConfigFilePath}. Cannot process any Uplay games!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -175,17 +175,17 @@ namespace DisplayMagician.Processes
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
logger.Trace($"ProcessUtils/ProcessExited: {process.Id} is not running, and the process ID has expired. This means the process has finished!");
|
||||
logger.Trace(ex, $"ProcessUtils/ProcessExited: {process.Id} is not running, and the process ID has expired. This means the process has finished!");
|
||||
return true;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
logger.Warn($"ProcessUtils/ProcessExited: {process.Id} was not started by this process object. This likely means the process has finished!");
|
||||
logger.Warn(ex, $"ProcessUtils/ProcessExited: {process.Id} was not started by this process object. This likely means the process has finished!");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Trace($"ProcessUtils/ProcessExited: Exception when checking if {process.Id} is still running, so assuming the process has finished!");
|
||||
logger.Trace(ex, $"ProcessUtils/ProcessExited: Exception when checking if {process.Id} is still running, so assuming the process has finished!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,8 @@ namespace DisplayMagician {
|
||||
var logfile = new NLog.Targets.FileTarget("logfile")
|
||||
{
|
||||
FileName = AppLogFilename,
|
||||
DeleteOldFileOnStartup = true
|
||||
DeleteOldFileOnStartup = true,
|
||||
Layout = "${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}"
|
||||
};
|
||||
|
||||
// Create a logging rule to use the log file target
|
||||
@ -1196,7 +1197,7 @@ namespace DisplayMagician {
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
logger.Trace($"Program/RunShortcutTask: User cancelled the running the shortcut {shortcutToUse.Name}.");
|
||||
logger.Trace(ex, $"Program/RunShortcutTask: User cancelled the running the shortcut {shortcutToUse.Name}.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1248,7 +1249,7 @@ namespace DisplayMagician {
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
logger.Trace($"Program/ApplyProfileTask: User cancelled the ApplyProfile {profile.Name}.");
|
||||
logger.Trace(ex, $"Program/ApplyProfileTask: User cancelled the ApplyProfile {profile.Name}.");
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
@ -1468,7 +1469,7 @@ namespace DisplayMagician {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn($"Program/CheckForUpdates: Exception while trying to get all the network interfaces to make sure we have internet connectivity. Attempting to auto update anyway.");
|
||||
logger.Warn(ex, $"Program/CheckForUpdates: Exception while trying to get all the network interfaces to make sure we have internet connectivity. Attempting to auto update anyway.");
|
||||
}
|
||||
|
||||
|
||||
@ -1729,6 +1730,7 @@ namespace DisplayMagician {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, $"Program/IsInstalledVersion: DisplayMagician InstallDir isn't in registry! This DisplayMagician isn't installed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.4.0.31")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.31")]
|
||||
[assembly: AssemblyVersion("2.4.0.41")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.41")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
@ -1183,7 +1183,7 @@ namespace DisplayMagician
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"ShortcutRepository/RunShortcut: Exception while trying to find the user supplied executable to monitor: {shortcutToUse.DifferentExecutableToMonitor}.");
|
||||
logger.Error(ex, $"ShortcutRepository/RunShortcut: Exception while trying to find the user supplied executable to monitor: {shortcutToUse.DifferentExecutableToMonitor}.");
|
||||
foundSomethingToMonitor = false;
|
||||
}
|
||||
}
|
||||
@ -2097,7 +2097,6 @@ namespace DisplayMagician
|
||||
{
|
||||
// At the moment we only allow one stop program
|
||||
StopProgram stopProg = shortcutToUse.StopPrograms[0];
|
||||
uint processID = 0;
|
||||
try
|
||||
{
|
||||
// Only start if not disabled
|
||||
|
@ -226,11 +226,13 @@ namespace DisplayMagician
|
||||
}
|
||||
catch (PlatformNotSupportedException ex)
|
||||
{
|
||||
Console.WriteLine($"SingleInstance/NamedPipeServerCreateServer: Cannot create a named pipe server. This NamedPipeServerStream function does not support this platform.");
|
||||
//Console.WriteLine($"SingleInstance/NamedPipeServerCreateServer: Cannot create a named pipe server. This NamedPipeServerStream function does not support this platform.");
|
||||
logger.Warn(ex, $"SingleInstance/NamedPipeServerCreateServer: Cannot create a named pipe server. This NamedPipeServerStream function does not support this platform.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"SingleInstance/NamedPipeServerCreateServer: Exception - Source: {ex.Source} {ex.TargetSite} - {ex.Message} - {ex.StackTrace}");
|
||||
logger.Warn(ex, $"SingleInstance/NamedPipeServerCreateServer: Exception - Source: {ex.Source} {ex.TargetSite} - {ex.Message} - {ex.StackTrace}");
|
||||
}
|
||||
// Begin async wait for connections
|
||||
_namedPipeServerStream.BeginWaitForConnection(NamedPipeServerConnectionCallback, _namedPipeServerStream);
|
||||
|
@ -81,6 +81,12 @@ namespace DisplayMagician.UIForms
|
||||
logger.Error($"DisplayProfileForm/Apply_Click: Error applying the Profile {_selectedProfile.Name}. Unable to change the display layout.");
|
||||
}
|
||||
|
||||
// Recenter the Window
|
||||
RecenterWindow();
|
||||
}
|
||||
|
||||
private void RecenterWindow()
|
||||
{
|
||||
// Center the MainAppForm
|
||||
Program.AppMainForm.Top = (Screen.PrimaryScreen.Bounds.Height - Program.AppMainForm.Height) / 2;
|
||||
Program.AppMainForm.Left = (Screen.PrimaryScreen.Bounds.Width - Program.AppMainForm.Width) / 2;
|
||||
@ -545,14 +551,16 @@ namespace DisplayMagician.UIForms
|
||||
ChangeSelectedProfile(ProfileRepository.GetActiveProfile());
|
||||
// Refresh the Profile UI
|
||||
RefreshDisplayProfileUI();
|
||||
// Recenter the Window
|
||||
RecenterWindow();
|
||||
}
|
||||
|
||||
private void txt_profile_save_name_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode.Equals(Keys.Enter))
|
||||
{
|
||||
MessageBox.Show("Click works!", "Click works", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
//MessageBox.Show("Click works!", "Click works", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
btn_save.PerformClick();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ namespace DisplayMagician.UIForms
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
SharedLogger.logger.Warn(ex, $"ProfileSettingsForm/btn_clear_Click: Exception while deleting wallpaper bitmap file {Profile.WallpaperBitmapFilename}");
|
||||
}
|
||||
|
||||
// Empty the file name in the Profile
|
||||
|
@ -594,6 +594,8 @@ namespace DisplayMagician.UIForms
|
||||
File.Delete(zipFilePath);
|
||||
}
|
||||
|
||||
NLog.LogManager.SuspendLogging();
|
||||
|
||||
ZipArchive archive = ZipFile.Open(zipFilePath, ZipArchiveMode.Create);
|
||||
|
||||
// Get the list of files we want to look for to zip (they may or may not exist)
|
||||
@ -630,6 +632,7 @@ namespace DisplayMagician.UIForms
|
||||
Path.Combine(Program.AppDataPath,"Settings_2.3.json.old"),
|
||||
Path.Combine(Program.AppDataPath,"Settings_2.4.json.old")
|
||||
};
|
||||
|
||||
foreach (string filename in listOfFiles)
|
||||
{
|
||||
try
|
||||
@ -661,6 +664,9 @@ namespace DisplayMagician.UIForms
|
||||
}
|
||||
|
||||
archive.Dispose();
|
||||
|
||||
NLog.LogManager.ResumeLogging();
|
||||
|
||||
SharedLogger.logger.Trace($"SettingsForm/btn_create_support_package_Click: Finished creating support zip file at {zipFilePath}.");
|
||||
MessageBox.Show($"Created DisplayMagician Support ZIP file {zipFilePath}. You can now attach this file to your GitHub issue.");
|
||||
}
|
||||
|
@ -3142,7 +3142,7 @@ namespace DisplayMagician.UIForms
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
logger.Warn(ex, $"ShortcutForm/ilv_games_ItemClick: Exception while attempting to suggest shortcut name.");
|
||||
}
|
||||
|
||||
try
|
||||
@ -3151,7 +3151,7 @@ namespace DisplayMagician.UIForms
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
logger.Warn(ex, $"ShortcutForm/ilv_games_ItemClick: Exception while figuring out if the save button shoud be enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1473,6 +1473,9 @@ namespace DisplayMagicianShared
|
||||
screen.ClonedCopies = 0;
|
||||
try
|
||||
{
|
||||
// IMPORTANT: This lookup WILL DEFINITELY CAUSE AN EXCEPTION right after windows changes back from
|
||||
// NVIDIA Surround to a non-surround profile. This is expected, as it is caused bythe way Windows is SOOOO slow to update
|
||||
// the taskbar locations in memory (it takes up to 15 seconds!). Nothing I can do, except put this protection in place :( .
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tbr => tbr.Value.RegKeyValue.Contains($"UID{targetId}")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
}
|
||||
|
@ -1356,7 +1356,7 @@ namespace DisplayMagicianShared
|
||||
|
||||
// Figure out the Video Cards and see what mode we want
|
||||
// Get a list of all the PCI Vendor IDs
|
||||
List<string> videoCardVendors = WinLibrary.GetLibrary().GetCurrentPCIVideoCardVendors();
|
||||
List<string> videoCardVendors = WinLibrary.GetLibrary().GetAllPCIVideoCardVendors();
|
||||
if (NVIDIALibrary.GetLibrary().IsInstalled && NVIDIALibrary.GetLibrary().PCIVendorIDs.All(value => videoCardVendors.Contains(value)))
|
||||
{
|
||||
// We detected a NVIDIA video card in the computer
|
||||
|
@ -771,15 +771,7 @@ namespace DisplayMagicianShared.Windows
|
||||
retryNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the length of the display sources equals the taskbar locations we're tracking
|
||||
// Note: taskBarStuckRectangles includes the 'Settings' main screen which is one extra screen that windows stores for the primary screen. We need to remove this from the count as it is extra.
|
||||
if (displaySources.Count != taskBarStuckRectangles.Keys.Count - 1)
|
||||
{
|
||||
SharedLogger.logger.Error($"TaskBarLayout/GetAllCurrentTaskBarPositions: We have an error because Display Sources array length doesn't match the taskBarStuckRectangles array length. This means we have a mismatch somewhere.");
|
||||
retryNeeded = true;
|
||||
}
|
||||
|
||||
|
||||
retryNeeded = false;
|
||||
return taskBarStuckRectangles;
|
||||
}
|
||||
|
@ -254,35 +254,35 @@ namespace DisplayMagicianShared.Windows
|
||||
{
|
||||
|
||||
Dictionary<ulong, ulong> adapterOldToNewMap = new Dictionary<ulong, ulong>();
|
||||
Dictionary<ulong, string> currentAdapterMap = GetCurrentAdapterIDs();
|
||||
Dictionary<ulong, string> currentAdapterMap = GetAllAdapterIDs();
|
||||
try
|
||||
{
|
||||
SharedLogger.logger.Trace("WinLibrary/PatchAdapterIDs: Going through the list of adapters we stored in the config to figure out the old adapterIDs");
|
||||
SharedLogger.logger.Trace("WinLibrary/PatchWindowsDisplayConfig: Going through the list of adapters we stored in the config to figure out the old adapterIDs");
|
||||
foreach (KeyValuePair<ulong, string> savedAdapter in savedDisplayConfig.DisplayAdapters)
|
||||
{
|
||||
bool adapterMatched = false;
|
||||
foreach (KeyValuePair<ulong, string> currentAdapter in currentAdapterMap)
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Checking if saved adapter {savedAdapter.Key} (AdapterName is {savedAdapter.Value}) is equal to current adapter id {currentAdapter.Key} (AdapterName is {currentAdapter.Value})");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Checking if saved adapter {savedAdapter.Key} (AdapterName is {savedAdapter.Value}) is equal to current adapter id {currentAdapter.Key} (AdapterName is {currentAdapter.Value})");
|
||||
|
||||
if (currentAdapter.Value.Equals(savedAdapter.Value))
|
||||
{
|
||||
// we have found the new LUID Value for the same adapter
|
||||
// So we want to store it
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: We found that saved adapter {savedAdapter.Key} has now been assigned adapter id {currentAdapter.Key} (AdapterName is {savedAdapter.Value})");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: We found that saved adapter {savedAdapter.Key} has now been assigned adapter id {currentAdapter.Key} (AdapterName is {savedAdapter.Value})");
|
||||
adapterOldToNewMap.Add(savedAdapter.Key, currentAdapter.Key);
|
||||
adapterMatched = true;
|
||||
}
|
||||
}
|
||||
if (!adapterMatched)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/PatchAdapterIDs: Saved adapter {savedAdapter.Key} (AdapterName is {savedAdapter.Value}) doesn't have a current match! The adapters have changed since the configuration was last saved.");
|
||||
SharedLogger.logger.Error($"WinLibrary/PatchWindowsDisplayConfig: Saved adapter {savedAdapter.Key} (AdapterName is {savedAdapter.Value}) doesn't have a current match! The adapters have changed since the configuration was last saved.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the list of adapters we stored in the config to figure out the old adapterIDs");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the list of adapters we stored in the config to figure out the old adapterIDs");
|
||||
}
|
||||
|
||||
ulong newAdapterValue = 0;
|
||||
@ -291,7 +291,7 @@ namespace DisplayMagicianShared.Windows
|
||||
try
|
||||
{
|
||||
// Update the DisplayAdapters with the current adapter id
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Going through the display adatpers to update the adapter id");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Going through the display adatpers to update the adapter id");
|
||||
ulong[] currentKeys = savedDisplayConfig.DisplayAdapters.Keys.ToArray();
|
||||
var currentLength = savedDisplayConfig.DisplayAdapters.Count;
|
||||
for (int i = 0; i < currentLength; i++)
|
||||
@ -311,19 +311,19 @@ namespace DisplayMagicianShared.Windows
|
||||
// Remove the old dictionary key
|
||||
savedDisplayConfig.DisplayAdapters.Remove(oldAdapterValue);
|
||||
}
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Updated DisplayAdapter from adapter {oldAdapterValue} to adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Updated DisplayAdapter from adapter {oldAdapterValue} to adapter {newAdapterValue} instead.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the display adapters update the adapter ids");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the display adapters update the adapter ids");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Update the paths with the current adapter id
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Going through the display config paths to update the adapter id");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Going through the display config paths to update the adapter id");
|
||||
for (int i = 0; i < savedDisplayConfig.DisplayConfigPaths.Length; i++)
|
||||
{
|
||||
// Change the Path SourceInfo and TargetInfo AdapterIDs
|
||||
@ -334,14 +334,14 @@ namespace DisplayMagicianShared.Windows
|
||||
savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
newAdapterValue = adapterOldToNewMap[savedDisplayConfig.DisplayConfigPaths[i].TargetInfo.AdapterId.Value];
|
||||
savedDisplayConfig.DisplayConfigPaths[i].TargetInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Updated DisplayConfig Path #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Updated DisplayConfig Path #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there isn't a matching adapter, then we just pick the first current one and hope that works!
|
||||
// (it is highly likely to... its only if the user has multiple graphics cards with some weird config it may break)
|
||||
newAdapterValue = currentAdapterMap.First().Key;
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchAdapterIDs: Uh Oh. Adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchWindowsDisplayConfig: Uh Oh. Adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
savedDisplayConfig.DisplayConfigPaths[i].TargetInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
}
|
||||
@ -349,13 +349,13 @@ namespace DisplayMagicianShared.Windows
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the display config paths to update the adapter id");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the display config paths to update the adapter id");
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Going through the display config modes to update the adapter id");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Going through the display config modes to update the adapter id");
|
||||
// Update the modes with the current adapter id
|
||||
for (int i = 0; i < savedDisplayConfig.DisplayConfigModes.Length; i++)
|
||||
{
|
||||
@ -365,27 +365,27 @@ namespace DisplayMagicianShared.Windows
|
||||
// We get here if there is a matching adapter
|
||||
newAdapterValue = adapterOldToNewMap[savedDisplayConfig.DisplayConfigModes[i].AdapterId.Value];
|
||||
savedDisplayConfig.DisplayConfigModes[i].AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Updated DisplayConfig Mode #{i} from adapter {savedDisplayConfig.DisplayConfigModes[i].AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Updated DisplayConfig Mode #{i} from adapter {savedDisplayConfig.DisplayConfigModes[i].AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there isn't a matching adapter, then we just pick the first current one and hope that works!
|
||||
// (it is highly likely to... its only if the user has multiple graphics cards with some weird config it may break)
|
||||
newAdapterValue = currentAdapterMap.First().Key;
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchAdapterIDs: Uh Oh. Adapter {savedDisplayConfig.DisplayConfigModes[i].AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchWindowsDisplayConfig: Uh Oh. Adapter {savedDisplayConfig.DisplayConfigModes[i].AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
savedDisplayConfig.DisplayConfigModes[i].AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the display config modes to update the adapter id");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the display config modes to update the adapter id");
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Going through the display config HDR info to update the adapter id");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Going through the display config HDR info to update the adapter id");
|
||||
if (savedDisplayConfig.DisplayHDRStates.Count > 0)
|
||||
{
|
||||
// Update the HDRInfo with the current adapter id
|
||||
@ -395,7 +395,7 @@ namespace DisplayMagicianShared.Windows
|
||||
// Change the Mode AdapterID
|
||||
if (adapterOldToNewMap.ContainsKey(savedDisplayConfig.DisplayHDRStates[i].AdapterId.Value))
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: adapterOldToNewMap contains adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} so using the new adapter ID of {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: adapterOldToNewMap contains adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} so using the new adapter ID of {newAdapterValue} instead.");
|
||||
// We get here if there is a matching adapter
|
||||
newAdapterValue = adapterOldToNewMap[savedDisplayConfig.DisplayHDRStates[i].AdapterId.Value];
|
||||
hdrInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
@ -403,14 +403,14 @@ namespace DisplayMagicianShared.Windows
|
||||
hdrInfo.AdvancedColorInfo.Header.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
newAdapterValue = adapterOldToNewMap[savedDisplayConfig.DisplayHDRStates[i].SDRWhiteLevel.Header.AdapterId.Value];
|
||||
hdrInfo.SDRWhiteLevel.Header.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Updated Display HDR state #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Updated Display HDR state #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there isn't a matching adapter, then we just pick the first current one and hope that works!
|
||||
// (it is highly likely to... its only if the user has multiple graphics cards with some weird config it may break)
|
||||
newAdapterValue = currentAdapterMap.First().Key;
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchAdapterIDs: Uh Oh. Adapter {savedDisplayConfig.DisplayHDRStates[i].AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchWindowsDisplayConfig: Uh Oh. Adapter {savedDisplayConfig.DisplayHDRStates[i].AdapterId.Value} didn't have a current match! It's possible the adapter was swapped or disabled. Attempting to use adapter {newAdapterValue} instead.");
|
||||
hdrInfo.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
hdrInfo.AdvancedColorInfo.Header.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
hdrInfo.SDRWhiteLevel.Header.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
@ -420,18 +420,18 @@ namespace DisplayMagicianShared.Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchAdapterIDs: There are no Display HDR states to update. Skipping.");
|
||||
SharedLogger.logger.Warn($"WinLibrary/PatchWindowsDisplayConfig: There are no Display HDR states to update. Skipping.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the display config HDR info to update the adapter id");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the display config HDR info to update the adapter id");
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Going through the display sources list info to update the adapter id");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Going through the display sources list info to update the adapter id");
|
||||
// Update the DisplaySources with the current adapter id
|
||||
for (int i = 0; i < savedDisplayConfig.DisplaySources.Count; i++)
|
||||
{
|
||||
@ -447,7 +447,7 @@ namespace DisplayMagicianShared.Windows
|
||||
// We get here if there is a matching adapter
|
||||
newAdapterValue = adapterOldToNewMap[ds.AdapterId.Value];
|
||||
ds.AdapterId = AdapterValueToLUID(newAdapterValue);
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchAdapterIDs: Updated DisplaySource #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/PatchWindowsDisplayConfig: Updated DisplaySource #{i} from adapter {savedDisplayConfig.DisplayConfigPaths[i].SourceInfo.AdapterId.Value} to adapter {newAdapterValue} instead.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -464,7 +464,7 @@ namespace DisplayMagicianShared.Windows
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchAdapterIDs: Exception while going through the display sources list info to update the adapter id");
|
||||
SharedLogger.logger.Error(ex, "WinLibrary/PatchWindowsDisplayConfig: Exception while going through the display sources list info to update the adapter id");
|
||||
}
|
||||
|
||||
}
|
||||
@ -668,7 +668,7 @@ namespace DisplayMagicianShared.Windows
|
||||
paths[i].TargetInfo.ModeInfoIdx = CCDImport.DISPLAYCONFIG_PATH_MODE_IDX_INVALID;
|
||||
}
|
||||
|
||||
// Get adapter ID for later
|
||||
/*// Get adapter ID for later
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetWindowsDisplayConfig: Attempting to get adapter name for adapter {paths[i].TargetInfo.AdapterId.Value}.");
|
||||
if (!windowsDisplayConfig.DisplayAdapters.ContainsKey(paths[i].TargetInfo.AdapterId.Value))
|
||||
{
|
||||
@ -695,7 +695,7 @@ namespace DisplayMagicianShared.Windows
|
||||
// We already have the adapter name
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetWindowsDisplayConfig: We already have the adapter name {windowsDisplayConfig.DisplayAdapters[paths[i].TargetInfo.AdapterId.Value]} for adapter {paths[i].TargetInfo.AdapterId.Value} so skipping storing it.");
|
||||
//gotAdapterName = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Get advanced color info
|
||||
@ -774,6 +774,9 @@ namespace DisplayMagicianShared.Windows
|
||||
}
|
||||
}
|
||||
|
||||
// Get all the DisplayAdapters currently in the system
|
||||
// This will be used for windows to translate the adapter details beween reboots
|
||||
windowsDisplayConfig.DisplayAdapters = GetAllAdapterIDs();
|
||||
|
||||
// Go through the list of physicalTargetIdsAvailable
|
||||
// ignore the ones that were found
|
||||
@ -2132,7 +2135,7 @@ namespace DisplayMagicianShared.Windows
|
||||
return displayIdentifiers;
|
||||
}
|
||||
|
||||
public List<string> GetCurrentPCIVideoCardVendors()
|
||||
public List<string> GetAllPCIVideoCardVendors()
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentPCIVideoCardVendors: Getting the current PCI vendor ids for the videocards reported to Windows");
|
||||
List<string> videoCardVendorIds = new List<string>();
|
||||
@ -2283,56 +2286,56 @@ namespace DisplayMagicianShared.Windows
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<ulong, string> GetCurrentAdapterIDs()
|
||||
public Dictionary<ulong, string> GetAllAdapterIDs()
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Getting the current adapter ids for the videocards Windows knows about");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Getting the current adapter ids for the videocards Windows knows about");
|
||||
Dictionary<ulong, string> currentAdapterMap = new Dictionary<ulong, string>();
|
||||
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Testing whether the display configuration is valid (allowing tweaks).");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Testing whether the display configuration is valid (allowing tweaks).");
|
||||
// Get the size of the largest All Paths and Modes arrays
|
||||
int pathCount = 0;
|
||||
int modeCount = 0;
|
||||
WIN32STATUS err = CCDImport.GetDisplayConfigBufferSizes(QDC.QDC_ALL_PATHS, out pathCount, out modeCount);
|
||||
if (err != WIN32STATUS.ERROR_SUCCESS)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/GetCurrentAdapterIDs: ERROR - GetDisplayConfigBufferSizes returned WIN32STATUS {err} when trying to get the maximum path and mode sizes");
|
||||
throw new WinLibraryException($"GetCurrentAdapterIDs returned WIN32STATUS {err} when trying to get the maximum path and mode sizes");
|
||||
SharedLogger.logger.Error($"WinLibrary/GetAllAdapterIDs: ERROR - GetDisplayConfigBufferSizes returned WIN32STATUS {err} when trying to get the maximum path and mode sizes");
|
||||
throw new WinLibraryException($"GetAllAdapterIDs returned WIN32STATUS {err} when trying to get the maximum path and mode sizes");
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Getting the current Display Config path and mode arrays");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Getting the current Display Config path and mode arrays");
|
||||
var paths = new DISPLAYCONFIG_PATH_INFO[pathCount];
|
||||
var modes = new DISPLAYCONFIG_MODE_INFO[modeCount];
|
||||
err = CCDImport.QueryDisplayConfig(QDC.QDC_ALL_PATHS, ref pathCount, paths, ref modeCount, modes, IntPtr.Zero);
|
||||
if (err == WIN32STATUS.ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
SharedLogger.logger.Warn($"WinLibrary/GetCurrentAdapterIDs: The displays were modified between GetDisplayConfigBufferSizes and QueryDisplayConfig so we need to get the buffer sizes again.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Getting the size of the largest Active Paths and Modes arrays");
|
||||
SharedLogger.logger.Warn($"WinLibrary/GetAllAdapterIDs: The displays were modified between GetDisplayConfigBufferSizes and QueryDisplayConfig so we need to get the buffer sizes again.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Getting the size of the largest Active Paths and Modes arrays");
|
||||
// Screen changed in between GetDisplayConfigBufferSizes and QueryDisplayConfig, so we need to get buffer sizes again
|
||||
// as per https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-querydisplayconfig
|
||||
err = CCDImport.GetDisplayConfigBufferSizes(QDC.QDC_ALL_PATHS, out pathCount, out modeCount);
|
||||
if (err != WIN32STATUS.ERROR_SUCCESS)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/GetCurrentAdapterIDs: ERROR - GetDisplayConfigBufferSizes returned WIN32STATUS {err} when trying to get the maximum path and mode sizes again");
|
||||
SharedLogger.logger.Error($"WinLibrary/GetAllAdapterIDs: ERROR - GetDisplayConfigBufferSizes returned WIN32STATUS {err} when trying to get the maximum path and mode sizes again");
|
||||
throw new WinLibraryException($"GetDisplayConfigBufferSizes returned WIN32STATUS {err} when trying to get the maximum path and mode sizes again");
|
||||
}
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Getting the current Display Config path and mode arrays");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Getting the current Display Config path and mode arrays");
|
||||
paths = new DISPLAYCONFIG_PATH_INFO[pathCount];
|
||||
modes = new DISPLAYCONFIG_MODE_INFO[modeCount];
|
||||
err = CCDImport.QueryDisplayConfig(QDC.QDC_ALL_PATHS, ref pathCount, paths, ref modeCount, modes, IntPtr.Zero);
|
||||
if (err == WIN32STATUS.ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/GetCurrentAdapterIDs: ERROR - The displays were still modified between GetDisplayConfigBufferSizes and QueryDisplayConfig, even though we tried twice. Something is wrong.");
|
||||
SharedLogger.logger.Error($"WinLibrary/GetAllAdapterIDs: ERROR - The displays were still modified between GetDisplayConfigBufferSizes and QueryDisplayConfig, even though we tried twice. Something is wrong.");
|
||||
throw new WinLibraryException($"The displays were still modified between GetDisplayConfigBufferSizes and QueryDisplayConfig, even though we tried twice. Something is wrong.");
|
||||
}
|
||||
else if (err != WIN32STATUS.ERROR_SUCCESS)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/GetCurrentAdapterIDs: ERROR - QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays again");
|
||||
SharedLogger.logger.Error($"WinLibrary/GetAllAdapterIDs: ERROR - QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays again");
|
||||
throw new WinLibraryException($"QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays again.");
|
||||
}
|
||||
}
|
||||
else if (err != WIN32STATUS.ERROR_SUCCESS)
|
||||
{
|
||||
SharedLogger.logger.Error($"WinLibrary/GetCurrentAdapterIDs: ERROR - QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays");
|
||||
SharedLogger.logger.Error($"WinLibrary/GetAllAdapterIDs: ERROR - QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays");
|
||||
throw new WinLibraryException($"QueryDisplayConfig returned WIN32STATUS {err} when trying to query all available displays.");
|
||||
}
|
||||
|
||||
@ -2341,7 +2344,7 @@ namespace DisplayMagicianShared.Windows
|
||||
if (path.TargetInfo.TargetAvailable == false)
|
||||
{
|
||||
// We want to skip this one cause it's not valid
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Skipping path due to TargetAvailable not existing in display #{path.TargetInfo.Id}");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Skipping path due to TargetAvailable not existing in display #{path.TargetInfo.Id}");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2354,12 +2357,12 @@ namespace DisplayMagicianShared.Windows
|
||||
err = CCDImport.DisplayConfigGetDeviceInfo(ref adapterInfo);
|
||||
if (err == WIN32STATUS.ERROR_SUCCESS)
|
||||
{
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetCurrentAdapterIDs: Successfully got the display name info from {path.TargetInfo.Id}.");
|
||||
SharedLogger.logger.Trace($"WinLibrary/GetAllAdapterIDs: Successfully got the display name info from {path.TargetInfo.Id}.");
|
||||
currentAdapterMap[path.TargetInfo.AdapterId.Value] = adapterInfo.AdapterDevicePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"WinLibrary/GetCurrentAdapterIDs: WARNING - DisplayConfigGetDeviceInfo returned WIN32STATUS {err} when trying to get the target info for display #{path.TargetInfo.Id}");
|
||||
SharedLogger.logger.Warn($"WinLibrary/GetAllAdapterIDs: WARNING - DisplayConfigGetDeviceInfo returned WIN32STATUS {err} when trying to get the target info for display #{path.TargetInfo.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user