mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Working manual game icon selection
Also copes with patching existing shortcuts
This commit is contained in:
parent
65cca02e5d
commit
4d9216328d
@ -373,6 +373,7 @@ namespace DisplayMagician
|
|||||||
Icon myIcon = null;
|
Icon myIcon = null;
|
||||||
List<ShortcutBitmap> bmList = new List<ShortcutBitmap>();
|
List<ShortcutBitmap> bmList = new List<ShortcutBitmap>();
|
||||||
int bmCount = 0;
|
int bmCount = 0;
|
||||||
|
string fileNameOnly = Path.GetFileName(fileNameAndPath);
|
||||||
|
|
||||||
if (fileNameAndPath.EndsWith(".ico"))
|
if (fileNameAndPath.EndsWith(".ico"))
|
||||||
{
|
{
|
||||||
@ -384,12 +385,7 @@ namespace DisplayMagician
|
|||||||
|
|
||||||
myIcon = new Icon(fileNameAndPath, 256, 256);
|
myIcon = new Icon(fileNameAndPath, 256, 256);
|
||||||
//Icon myIcon = Icon.ExtractAssociatedIcon(fileNameAndPath);
|
//Icon myIcon = Icon.ExtractAssociatedIcon(fileNameAndPath);
|
||||||
ShortcutBitmap bm = new ShortcutBitmap();
|
ShortcutBitmap bm = CreateShortcutBitmap(myIcon.ToBitmap(), fileNameOnly, fileNameAndPath, bmCount++);
|
||||||
bm.UUID = Guid.NewGuid().ToString("D");
|
|
||||||
bm.Order = bmCount++;
|
|
||||||
bm.Source = fileNameAndPath;
|
|
||||||
bm.Image = myIcon.ToBitmap();
|
|
||||||
bm.Size = new Size(bm.Image.Width, bm.Image.Height);
|
|
||||||
// Add the shortcutbitmap to the list
|
// Add the shortcutbitmap to the list
|
||||||
bmList.Add(bm);
|
bmList.Add(bm);
|
||||||
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: Added new bitmap from the icon file {fileNameAndPath} using standard Icon access method.");
|
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: Added new bitmap from the icon file {fileNameAndPath} using standard Icon access method.");
|
||||||
@ -406,12 +402,7 @@ namespace DisplayMagician
|
|||||||
mySingleIcon.Load(fileNameAndPath);
|
mySingleIcon.Load(fileNameAndPath);
|
||||||
foreach (IconImage myIconImage in mySingleIcon)
|
foreach (IconImage myIconImage in mySingleIcon)
|
||||||
{
|
{
|
||||||
ShortcutBitmap bm = new ShortcutBitmap();
|
ShortcutBitmap bm = CreateShortcutBitmap(myIconImage.Image, fileNameOnly, fileNameAndPath, bmCount++);
|
||||||
bm.UUID = Guid.NewGuid().ToString("D");
|
|
||||||
bm.Order = bmCount++;
|
|
||||||
bm.Source = fileNameAndPath;
|
|
||||||
bm.Image = myIconImage.Image;
|
|
||||||
bm.Size = new Size(bm.Image.Width, bm.Image.Height);
|
|
||||||
// Add the shortcutbitmap to the list
|
// Add the shortcutbitmap to the list
|
||||||
bmList.Add(bm);
|
bmList.Add(bm);
|
||||||
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: Added new bitmap from the icon file {fileNameAndPath} using MultiIcon access method.");
|
logger.Trace($"ShortcutItem/GetMeABitmapFromFile: Added new bitmap from the icon file {fileNameAndPath} using MultiIcon access method.");
|
||||||
@ -453,12 +444,7 @@ namespace DisplayMagician
|
|||||||
Icon[] allIcons = ie.GetAllIcons();
|
Icon[] allIcons = ie.GetAllIcons();
|
||||||
foreach (Icon myExtractedIcon in allIcons)
|
foreach (Icon myExtractedIcon in allIcons)
|
||||||
{
|
{
|
||||||
ShortcutBitmap bm = new ShortcutBitmap();
|
ShortcutBitmap bm = CreateShortcutBitmap(myExtractedIcon.ToBitmap(), fileNameOnly, fileNameAndPath, bmCount++);
|
||||||
bm.UUID = Guid.NewGuid().ToString("D");
|
|
||||||
bm.Order = bmCount++;
|
|
||||||
bm.Source = fileNameAndPath;
|
|
||||||
bm.Image = myExtractedIcon.ToBitmap();
|
|
||||||
bm.Size = new Size(bm.Image.Width, bm.Image.Height);
|
|
||||||
// Add the shortcutbitmap to the list
|
// Add the shortcutbitmap to the list
|
||||||
bmList.Add(bm);
|
bmList.Add(bm);
|
||||||
|
|
||||||
@ -492,12 +478,7 @@ namespace DisplayMagician
|
|||||||
|
|
||||||
if (myIcon != null)
|
if (myIcon != null)
|
||||||
{
|
{
|
||||||
ShortcutBitmap bm = new ShortcutBitmap();
|
ShortcutBitmap bm = CreateShortcutBitmap(myIcon.ToBitmap(),fileNameOnly,fileNameAndPath,bmCount++);
|
||||||
bm.UUID = Guid.NewGuid().ToString("D");
|
|
||||||
bm.Order = bmCount++;
|
|
||||||
bm.Source = fileNameAndPath;
|
|
||||||
bm.Image = myIcon.ToBitmap();
|
|
||||||
bm.Size = new Size(bm.Image.Width, bm.Image.Height);
|
|
||||||
// Add the shortcutbitmap to the list
|
// Add the shortcutbitmap to the list
|
||||||
bmList.Add(bm);
|
bmList.Add(bm);
|
||||||
|
|
||||||
@ -559,6 +540,17 @@ namespace DisplayMagician
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ShortcutBitmap CreateShortcutBitmap(Bitmap bitmap, string name = "", string source = "", int order = 0)
|
||||||
|
{
|
||||||
|
ShortcutBitmap sc = new ShortcutBitmap();
|
||||||
|
sc.UUID = Guid.NewGuid().ToString("D");
|
||||||
|
sc.Name = name;
|
||||||
|
sc.Order = order;
|
||||||
|
sc.Source = source;
|
||||||
|
sc.Image = bitmap;
|
||||||
|
sc.Size = new Size(sc.Image.Width, sc.Image.Height);
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool ImagesAreEqual(Bitmap imageA, Bitmap imageB)
|
public static bool ImagesAreEqual(Bitmap imageA, Bitmap imageB)
|
||||||
{
|
{
|
||||||
|
@ -26,8 +26,8 @@ using System.Resources;
|
|||||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("2.1.0.125")]
|
[assembly: AssemblyVersion("2.1.0.132")]
|
||||||
[assembly: AssemblyFileVersion("2.1.0.125")]
|
[assembly: AssemblyFileVersion("2.1.0.132")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|
||||||
|
@ -903,8 +903,9 @@ namespace DisplayMagician
|
|||||||
_profileUuid = profile.UUID;
|
_profileUuid = profile.UUID;
|
||||||
|
|
||||||
// We create the Bitmaps for the game
|
// We create the Bitmaps for the game
|
||||||
//SetBitmapsForGame();
|
|
||||||
_originalBitmap = selectedImage.Image;
|
_originalBitmap = selectedImage.Image;
|
||||||
|
// Now we use the originalBitmap or userBitmap, and create the shortcutBitmap from it
|
||||||
|
_shortcutBitmap = ImageUtils.ToBitmapOverlay(_originalBitmap, _profileToUse.ProfileTightestBitmap, 256, 256);
|
||||||
|
|
||||||
ReplaceShortcutIconInCache();
|
ReplaceShortcutIconInCache();
|
||||||
RefreshValidity();
|
RefreshValidity();
|
||||||
@ -972,8 +973,9 @@ namespace DisplayMagician
|
|||||||
_profileUuid = profile.UUID;
|
_profileUuid = profile.UUID;
|
||||||
|
|
||||||
// We create the Bitmaps for the executable
|
// We create the Bitmaps for the executable
|
||||||
//SetBitmapsForExecutable();
|
|
||||||
_originalBitmap = selectedImage.Image;
|
_originalBitmap = selectedImage.Image;
|
||||||
|
// Now we use the originalBitmap or userBitmap, and create the shortcutBitmap from it
|
||||||
|
_shortcutBitmap = ImageUtils.ToBitmapOverlay(_originalBitmap, _profileToUse.ProfileTightestBitmap, 256, 256);
|
||||||
|
|
||||||
ReplaceShortcutIconInCache();
|
ReplaceShortcutIconInCache();
|
||||||
RefreshValidity();
|
RefreshValidity();
|
||||||
@ -1087,98 +1089,6 @@ namespace DisplayMagician
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBitmapsForGame()
|
|
||||||
{
|
|
||||||
// Get the user icon bitmap if its set.
|
|
||||||
if (_userChoseOwnIcon)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/ToBitmapOverlay: Using the user set icon as the game icon.");
|
|
||||||
_originalBitmap = _selectedImage.Image;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get the game icon bitmap if we can find it.
|
|
||||||
logger.Trace($"ShortcutItem/ToBitmapOverlay: Using the game executable icon as the game icon instead from {_originalIconPath}.");
|
|
||||||
// Find the game bitmap that matches the game name we just got
|
|
||||||
foreach (var aGame in GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries)
|
|
||||||
{
|
|
||||||
if (aGame.Name.Equals(_gameName))
|
|
||||||
{
|
|
||||||
_selectedImage = aGame.GameBitmap;
|
|
||||||
_originalBitmap = aGame.GameBitmap.Image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// If we can't find the game icon bitmap then we try the icons for the game libraries themselves
|
|
||||||
if (_originalBitmap == null)
|
|
||||||
{
|
|
||||||
if (_gameLibrary == SupportedGameLibraryType.Steam)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Using the Steam icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.Steam;
|
|
||||||
}
|
|
||||||
else if (_gameLibrary == SupportedGameLibraryType.Uplay)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Using the Uplay icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.Uplay;
|
|
||||||
}
|
|
||||||
else if (_gameLibrary == SupportedGameLibraryType.Origin)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Using the Origin icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.Origin;
|
|
||||||
}
|
|
||||||
else if (_gameLibrary == SupportedGameLibraryType.Epic)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Using the Epic icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.Epic;
|
|
||||||
}
|
|
||||||
else if (_gameLibrary == SupportedGameLibraryType.GOG)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Using the GOG icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.GOG;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/GetOriginalBitmapFromGame: Unknown Game Library, so using the DisplayMagician icon as the icon instead.");
|
|
||||||
_originalBitmap = Properties.Resources.DisplayMagician.ToBitmap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we use the originalBitmap or userBitmap, and create the shortcutBitmap from it
|
|
||||||
_shortcutBitmap = ImageUtils.ToBitmapOverlay(_originalBitmap, _profileToUse.ProfileTightestBitmap, 256, 256);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetBitmapsForExecutable()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_userChoseOwnIcon)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/ToBitmapOverlay: Using the user set icon as the game icon.");
|
|
||||||
_originalBitmap = _selectedImage.Image;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/SetBitmapsForExecutable: Using the executable icon as the app icon instead from {_executableNameAndPath}.");
|
|
||||||
_availableImages = ImageUtils.GetMeAllBitmapsFromFile(_executableNameAndPath);
|
|
||||||
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
|
||||||
_originalBitmap = _selectedImage.Image;
|
|
||||||
|
|
||||||
if (_originalBitmap == null)
|
|
||||||
{
|
|
||||||
logger.Trace($"ShortcutItem/SetBitmapsForExecutable: Unknown Game Library, so using the DisplayMagician icon as the icon instead.");
|
|
||||||
_originalBitmap = ImageUtils.ToBitmapOverlay(Properties.Resources.DisplayMagician.ToBitmap(), _profileToUse.ProfileIcon.ToBitmap(), 256, 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we use the originalBitmap or userBitmap, and create the shortcutBitmap from it
|
|
||||||
_shortcutBitmap = ImageUtils.ToBitmapOverlay(_originalBitmap, _profileToUse.ProfileTightestBitmap, 256, 256);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshValidity()
|
public void RefreshValidity()
|
||||||
{
|
{
|
||||||
// Do some validation checks to make sure the shortcut is sensible
|
// Do some validation checks to make sure the shortcut is sensible
|
||||||
|
@ -22,6 +22,7 @@ namespace DisplayMagician.UIForms
|
|||||||
|
|
||||||
private ProfileAdaptor _profileAdaptor;
|
private ProfileAdaptor _profileAdaptor;
|
||||||
private GameAdaptor _gameAdaptor;
|
private GameAdaptor _gameAdaptor;
|
||||||
|
private bool _editingExistingShortcut = false;
|
||||||
//private List<ProfileItem> _loadedProfiles = new List<ProfileItem>();
|
//private List<ProfileItem> _loadedProfiles = new List<ProfileItem>();
|
||||||
private ProfileItem _profileToUse = null;
|
private ProfileItem _profileToUse = null;
|
||||||
private string _gameLauncher = "";
|
private string _gameLauncher = "";
|
||||||
@ -62,7 +63,7 @@ namespace DisplayMagician.UIForms
|
|||||||
|
|
||||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public ShortcutForm(ShortcutItem shortcutToEdit)
|
public ShortcutForm(ShortcutItem shortcutToEdit, bool editingExistingShortcut = false)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ namespace DisplayMagician.UIForms
|
|||||||
_profileAdaptor = new ProfileAdaptor();
|
_profileAdaptor = new ProfileAdaptor();
|
||||||
_gameAdaptor = new GameAdaptor();
|
_gameAdaptor = new GameAdaptor();
|
||||||
|
|
||||||
|
_editingExistingShortcut = editingExistingShortcut;
|
||||||
_shortcutToEdit = shortcutToEdit;
|
_shortcutToEdit = shortcutToEdit;
|
||||||
|
|
||||||
// Style the Saved Profiles list
|
// Style the Saved Profiles list
|
||||||
@ -114,6 +116,11 @@ namespace DisplayMagician.UIForms
|
|||||||
get => _shortcutToEdit;
|
get => _shortcutToEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool EditingExistingShortcut
|
||||||
|
{
|
||||||
|
get => _editingExistingShortcut;
|
||||||
|
set => _editingExistingShortcut = value;
|
||||||
|
}
|
||||||
|
|
||||||
public SupportedGameLibraryType GameLibrary
|
public SupportedGameLibraryType GameLibrary
|
||||||
{
|
{
|
||||||
@ -197,13 +204,6 @@ namespace DisplayMagician.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static bool IsLowQuality(IconImage iconImage)
|
|
||||||
{
|
|
||||||
return iconImage.PixelFormat == System.Drawing.Imaging.PixelFormat.Format1bppIndexed ||
|
|
||||||
iconImage.PixelFormat == System.Drawing.Imaging.PixelFormat.Format4bppIndexed ||
|
|
||||||
iconImage.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private void btn_app_executable_Click(object sender, EventArgs e)
|
private void btn_app_executable_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
||||||
@ -1168,68 +1168,63 @@ namespace DisplayMagician.UIForms
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load all the Games into the Games ListView
|
// Load all the Games into the Games ListView
|
||||||
foreach (var game in DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.OrderBy(game => game.Name))
|
foreach (var game in DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.OrderBy(game => game.Name))
|
||||||
{
|
{
|
||||||
// Add the game to the game array
|
// Add the game to the game array
|
||||||
ImageListViewItem newItem = new ImageListViewItem(game, game.Name);
|
ImageListViewItem newItem = new ImageListViewItem(game, game.Name);
|
||||||
//ilv_saved_profiles.Items.Add(newItem);
|
//ilv_saved_profiles.Items.Add(newItem);
|
||||||
ilv_games.Items.Add(newItem, _gameAdaptor);
|
ilv_games.Items.Add(newItem, _gameAdaptor);
|
||||||
if (game.Name.Equals(_shortcutToEdit.GameName))
|
if (_editingExistingShortcut && game.Name.Equals(_shortcutToEdit.GameName))
|
||||||
{
|
{
|
||||||
shortcutGame = game;
|
shortcutGame = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_shortcutToEdit != null)
|
if (_shortcutToEdit.Category == ShortcutCategory.Game && _shortcutToEdit.GameAppId != null)
|
||||||
{
|
{
|
||||||
if (_shortcutToEdit.Category == ShortcutCategory.Game && _shortcutToEdit.GameAppId != null)
|
bool gameStillInstalled = false;
|
||||||
|
foreach (ImageListViewItem gameItem in ilv_games.Items)
|
||||||
{
|
{
|
||||||
bool gameStillInstalled = false;
|
if (gameItem.Text.Equals(_shortcutToEdit.GameName))
|
||||||
foreach (ImageListViewItem gameItem in ilv_games.Items)
|
|
||||||
{
|
{
|
||||||
if (gameItem.Text.Equals(_shortcutToEdit.GameName))
|
gameStillInstalled = true;
|
||||||
{
|
break;
|
||||||
gameStillInstalled = true;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!gameStillInstalled)
|
|
||||||
{
|
|
||||||
DialogResult result = MessageBox.Show(
|
|
||||||
$"This shortcut refers to the '{_shortcutToEdit.GameName}' game that was installed in your {_shortcutToEdit.GameLibrary.ToString("G")} library. This game is no longer installed, so the shortcut won't work. You either need to change the game used in the Shortcut to another installed game, or you need to install the game files on your computer again.",
|
|
||||||
@"Game no longer exists",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Exclamation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!gameStillInstalled)
|
||||||
|
|
||||||
if (ProfileRepository.ContainsProfile(_shortcutToEdit.ProfileUUID))
|
|
||||||
{
|
{
|
||||||
// We have loaded the profile used last time
|
DialogResult result = MessageBox.Show(
|
||||||
// so we need to show the selected profile in the UI
|
$"This shortcut refers to the '{_shortcutToEdit.GameName}' game that was installed in your {_shortcutToEdit.GameLibrary.ToString("G")} library. This game is no longer installed, so the shortcut won't work. You either need to change the game used in the Shortcut to another installed game, or you need to install the game files on your computer again.",
|
||||||
chosenProfile = ProfileRepository.GetProfile(_shortcutToEdit.ProfileUUID);
|
@"Game no longer exists",
|
||||||
foundChosenProfileInLoadedProfiles = true;
|
|
||||||
|
|
||||||
// If the profile is the same, but the user has renamed the profile
|
|
||||||
// since the shortcut was last created, then we need to tell the user
|
|
||||||
if (!chosenProfile.IsPossible)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show(
|
|
||||||
$"The '{chosenProfile.Name}' Display Profile used by this Shortcut still exists, but it isn't possible to use it right now. You can either change the Display Profile this Shortcut uses, or you can change your Displays to make the Display Profile valid again.",
|
|
||||||
@"Display Profile isn't possible now",
|
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Exclamation);
|
MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
if (ProfileRepository.ContainsProfile(_shortcutToEdit.ProfileUUID))
|
||||||
|
{
|
||||||
|
// We have loaded the profile used last time
|
||||||
|
// so we need to show the selected profile in the UI
|
||||||
|
chosenProfile = ProfileRepository.GetProfile(_shortcutToEdit.ProfileUUID);
|
||||||
|
foundChosenProfileInLoadedProfiles = true;
|
||||||
|
|
||||||
|
// If the profile is the same, but the user has renamed the profile
|
||||||
|
// since the shortcut was last created, then we need to tell the user
|
||||||
|
if (!chosenProfile.IsPossible)
|
||||||
|
{
|
||||||
|
|
||||||
|
MessageBox.Show(
|
||||||
|
$"The '{chosenProfile.Name}' Display Profile used by this Shortcut still exists, but it isn't possible to use it right now. You can either change the Display Profile this Shortcut uses, or you can change your Displays to make the Display Profile valid again.",
|
||||||
|
@"Display Profile isn't possible now",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundChosenProfileInLoadedProfiles && !String.IsNullOrWhiteSpace(_shortcutToEdit.ProfileUUID))
|
if (!foundChosenProfileInLoadedProfiles && !String.IsNullOrWhiteSpace(_shortcutToEdit.ProfileUUID))
|
||||||
@ -1310,13 +1305,12 @@ namespace DisplayMagician.UIForms
|
|||||||
cb_wait_alternative_game.Checked = false;
|
cb_wait_alternative_game.Checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set the launcher items if we have them
|
// Set the launcher items if we have them
|
||||||
if (_shortcutToEdit.GameLibrary.Equals(SupportedGameLibraryType.Unknown))
|
if (_shortcutToEdit.GameLibrary.Equals(SupportedGameLibraryType.Unknown))
|
||||||
{
|
{
|
||||||
if (DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.Count <= 0)
|
if (DisplayMagician.GameLibraries.GameLibrary.AllInstalledGamesInAllLibraries.Count <= 0)
|
||||||
{
|
{
|
||||||
// Fill in the game library information to highliught there isn't one detected.
|
// Fill in the game library information to highlight there isn't one detected.
|
||||||
_gameLauncher = "None detected";
|
_gameLauncher = "None detected";
|
||||||
txt_game_name.Text = "No supported game libraries detected";
|
txt_game_name.Text = "No supported game libraries detected";
|
||||||
txt_args_game.Text = "";
|
txt_args_game.Text = "";
|
||||||
@ -1346,6 +1340,7 @@ namespace DisplayMagician.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the autoname checkbox
|
||||||
cb_autosuggest.Checked = _shortcutToEdit.AutoName;
|
cb_autosuggest.Checked = _shortcutToEdit.AutoName;
|
||||||
|
|
||||||
// Set the executable items if we have them
|
// Set the executable items if we have them
|
||||||
@ -1364,11 +1359,9 @@ namespace DisplayMagician.UIForms
|
|||||||
if (_shortcutToEdit.ProcessNameToMonitorUsesExecutable)
|
if (_shortcutToEdit.ProcessNameToMonitorUsesExecutable)
|
||||||
{
|
{
|
||||||
rb_wait_executable.Checked = true;
|
rb_wait_executable.Checked = true;
|
||||||
//rb_wait_alternative_executable.Checked = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//rb_wait_executable.Checked = false;
|
|
||||||
rb_wait_alternative_executable.Checked = true;
|
rb_wait_alternative_executable.Checked = true;
|
||||||
}
|
}
|
||||||
txt_alternative_executable.Text = _shortcutToEdit.DifferentExecutableToMonitor;
|
txt_alternative_executable.Text = _shortcutToEdit.DifferentExecutableToMonitor;
|
||||||
@ -1377,109 +1370,171 @@ namespace DisplayMagician.UIForms
|
|||||||
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
|
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
|
||||||
|
|
||||||
// Set the selected image and available images (originalBitmap is set during shortcut update)
|
// Set the selected image and available images (originalBitmap is set during shortcut update)
|
||||||
if (_shortcutToEdit.OriginalLargeBitmap == null || ImageUtils.ImagesAreEqual(_shortcutToEdit.SelectedImage.Image, _shortcutToEdit.OriginalLargeBitmap))
|
|
||||||
|
|
||||||
|
if (_editingExistingShortcut)
|
||||||
{
|
{
|
||||||
// if there aren't any available images, then we need to find some!
|
ShortcutBitmap defaultBitmap = new ShortcutBitmap();
|
||||||
if (_shortcutToEdit.Category == ShortcutCategory.Game)
|
|
||||||
|
// Check if AvailableImages have been set, because if not, then we need to 'upgrade' the image structure
|
||||||
|
// To use this new way of working
|
||||||
|
if (_shortcutToEdit.AvailableImages.Count > 0)
|
||||||
{
|
{
|
||||||
// If this is a shortcut we're editing
|
_selectedImage = _shortcutToEdit.SelectedImage;
|
||||||
_availableImages = new List<ShortcutBitmap>();
|
_availableImages = _shortcutToEdit.AvailableImages;
|
||||||
// If the game is selected, then grab images from the game
|
if (_shortcutToEdit.Category == ShortcutCategory.Game)
|
||||||
if (shortcutGame != null)
|
|
||||||
{
|
|
||||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.ExePath));
|
|
||||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.IconPath));
|
|
||||||
}
|
|
||||||
// If the different exe to monitor is set, then grab the icons from there too!
|
|
||||||
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentGameExeToMonitor) && File.Exists(_shortcutToEdit.DifferentGameExeToMonitor))
|
|
||||||
{
|
|
||||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.DifferentGameExeToMonitor));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matchedImage = false;
|
|
||||||
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
|
||||||
{
|
|
||||||
// go through available images and match the one we had
|
|
||||||
foreach (ShortcutBitmap sc in _availableImages)
|
|
||||||
{
|
|
||||||
if (ImageUtils.ImagesAreEqual(sc.Image, _shortcutToEdit.OriginalLargeBitmap))
|
|
||||||
{
|
|
||||||
// We've found the original image!
|
|
||||||
_selectedImage = sc;
|
|
||||||
pb_game_icon.Image = _selectedImage.Image;
|
|
||||||
matchedImage = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matchedImage)
|
|
||||||
{
|
|
||||||
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
|
||||||
pb_game_icon.Image = _selectedImage.Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
|
||||||
{
|
{
|
||||||
|
pb_game_icon.Image = _shortcutToEdit.SelectedImage.Image;
|
||||||
btn_choose_game_icon.Enabled = true;
|
btn_choose_game_icon.Enabled = true;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (_shortcutToEdit.Category == ShortcutCategory.Application)
|
|
||||||
{
|
|
||||||
// If this is a shortcut we're editing
|
|
||||||
_availableImages = new List<ShortcutBitmap>();
|
|
||||||
// If the exe is selected, then grab images from the exe
|
|
||||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.ExecutableNameAndPath));
|
|
||||||
// If the different exe to monitor is set, then grab the icons from there too!
|
|
||||||
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentExecutableToMonitor) && File.Exists(_shortcutToEdit.DifferentExecutableToMonitor))
|
|
||||||
{
|
|
||||||
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.DifferentExecutableToMonitor));
|
|
||||||
}
|
}
|
||||||
|
else if (_shortcutToEdit.Category == ShortcutCategory.Application)
|
||||||
bool matchedImage = false;
|
|
||||||
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
|
||||||
{
|
{
|
||||||
// go through available images and match the one we had
|
pb_exe_icon.Image = _shortcutToEdit.SelectedImage.Image;
|
||||||
foreach (ShortcutBitmap sc in _availableImages)
|
btn_choose_exe_icon.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if there aren't any available images, then we need to find some!
|
||||||
|
if (_shortcutToEdit.Category == ShortcutCategory.Game)
|
||||||
|
{
|
||||||
|
// If this is a shortcut we're editing
|
||||||
|
_availableImages = new List<ShortcutBitmap>();
|
||||||
|
// If the game is selected, then grab images from the game
|
||||||
|
if (shortcutGame != null)
|
||||||
{
|
{
|
||||||
if (ImageUtils.ImagesAreEqual(sc.Image, _shortcutToEdit.OriginalLargeBitmap))
|
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.ExePath));
|
||||||
|
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(shortcutGame.IconPath));
|
||||||
|
}
|
||||||
|
// If the different exe to monitor is set, then grab the icons from there too!
|
||||||
|
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentGameExeToMonitor) && File.Exists(_shortcutToEdit.DifferentGameExeToMonitor))
|
||||||
|
{
|
||||||
|
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.DifferentGameExeToMonitor));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we still don't have any availableImages, then we need to add some emergency replacements!
|
||||||
|
if (_availableImages.Count == 0)
|
||||||
|
{
|
||||||
|
if (_shortcutToEdit.GameLibrary == SupportedGameLibraryType.Steam)
|
||||||
{
|
{
|
||||||
// We've found the original image!
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Using the Steam icon as the icon instead.");
|
||||||
_selectedImage = sc;
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Steam, "Steam Icon", "", 0);
|
||||||
pb_game_icon.Image = _selectedImage.Image;
|
_availableImages.Add(bm);
|
||||||
matchedImage = true;
|
}
|
||||||
|
else if (_shortcutToEdit.GameLibrary == SupportedGameLibraryType.Uplay)
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Using the Uplay icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Uplay, "Uplay Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
}
|
||||||
|
else if (_shortcutToEdit.GameLibrary == SupportedGameLibraryType.Origin)
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Using the Origin icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Origin, "Origin Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
}
|
||||||
|
else if (_shortcutToEdit.GameLibrary == SupportedGameLibraryType.Epic)
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Using the Epic icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.Epic, "Epic Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
}
|
||||||
|
else if (_shortcutToEdit.GameLibrary == SupportedGameLibraryType.GOG)
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Using the GOG icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.GOG, "GOG Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Unknown Game Library, so using the DisplayMagician icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.DisplayMagician.ToBitmap(), "DisplayMagician Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matchedImage = false;
|
||||||
|
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
||||||
|
{
|
||||||
|
// go through available images and match the one we had
|
||||||
|
foreach (ShortcutBitmap sc in _availableImages)
|
||||||
|
{
|
||||||
|
if (ImageUtils.ImagesAreEqual(sc.Image, _shortcutToEdit.OriginalLargeBitmap))
|
||||||
|
{
|
||||||
|
// We've found the original image!
|
||||||
|
_selectedImage = sc;
|
||||||
|
pb_game_icon.Image = _selectedImage.Image;
|
||||||
|
matchedImage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!matchedImage)
|
if (!matchedImage)
|
||||||
{
|
{
|
||||||
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
||||||
pb_game_icon.Image = _selectedImage.Image;
|
pb_game_icon.Image = _selectedImage.Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
||||||
|
{
|
||||||
|
btn_choose_game_icon.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (_shortcutToEdit.Category == ShortcutCategory.Application)
|
||||||
{
|
{
|
||||||
btn_choose_exe_icon.Enabled = true;
|
// If this is a shortcut we're editing
|
||||||
}
|
_availableImages = new List<ShortcutBitmap>();
|
||||||
}
|
// If the exe is selected, then grab images from the exe
|
||||||
|
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.ExecutableNameAndPath));
|
||||||
|
// If the different exe to monitor is set, then grab the icons from there too!
|
||||||
|
if (!String.IsNullOrWhiteSpace(_shortcutToEdit.DifferentExecutableToMonitor) && File.Exists(_shortcutToEdit.DifferentExecutableToMonitor))
|
||||||
|
{
|
||||||
|
_availableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(_shortcutToEdit.DifferentExecutableToMonitor));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_availableImages.Count == 0)
|
||||||
|
{
|
||||||
|
logger.Trace($"ShortcutForm/ShortcutForm_Load: Unknown Game Library, so using the DisplayMagician icon as the icon instead.");
|
||||||
|
ShortcutBitmap bm = ImageUtils.CreateShortcutBitmap(Properties.Resources.DisplayMagician.ToBitmap(), "DisplayMagician Icon", "", 0);
|
||||||
|
_availableImages.Add(bm);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matchedImage = false;
|
||||||
|
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
||||||
|
{
|
||||||
|
// go through available images and match the one we had
|
||||||
|
foreach (ShortcutBitmap sc in _availableImages)
|
||||||
|
{
|
||||||
|
if (ImageUtils.ImagesAreEqual(sc.Image, _shortcutToEdit.OriginalLargeBitmap))
|
||||||
|
{
|
||||||
|
// We've found the original image!
|
||||||
|
_selectedImage = sc;
|
||||||
|
pb_game_icon.Image = _selectedImage.Image;
|
||||||
|
matchedImage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matchedImage)
|
||||||
|
{
|
||||||
|
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
|
||||||
|
pb_game_icon.Image = _selectedImage.Image;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_shortcutToEdit.OriginalLargeBitmap != null)
|
||||||
|
{
|
||||||
|
btn_choose_exe_icon.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This is the most common scenario
|
// We're editing a new shortcut, so no game or anything selected
|
||||||
_selectedImage = _shortcutToEdit.SelectedImage;
|
|
||||||
_availableImages = _shortcutToEdit.AvailableImages;
|
|
||||||
if (_shortcutToEdit.Category == ShortcutCategory.Game)
|
|
||||||
{
|
|
||||||
pb_game_icon.Image = _shortcutToEdit.SelectedImage.Image;
|
|
||||||
btn_choose_game_icon.Enabled = true;
|
|
||||||
}
|
|
||||||
else if (_shortcutToEdit.Category == ShortcutCategory.Application)
|
|
||||||
{
|
|
||||||
pb_exe_icon.Image = _shortcutToEdit.SelectedImage.Image;
|
|
||||||
btn_choose_exe_icon.Enabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the start programs
|
// Set up the start programs
|
||||||
|
@ -264,7 +264,7 @@ namespace DisplayMagician.UIForms
|
|||||||
private void btn_new_Click(object sender, EventArgs e)
|
private void btn_new_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Cursor = Cursors.WaitCursor;
|
this.Cursor = Cursors.WaitCursor;
|
||||||
var shortcutForm = new ShortcutForm(new ShortcutItem());
|
var shortcutForm = new ShortcutForm(new ShortcutItem(),false);
|
||||||
//ShortcutRepository.IsValidRefresh();
|
//ShortcutRepository.IsValidRefresh();
|
||||||
shortcutForm.ShowDialog(this);
|
shortcutForm.ShowDialog(this);
|
||||||
if (shortcutForm.DialogResult == DialogResult.OK)
|
if (shortcutForm.DialogResult == DialogResult.OK)
|
||||||
@ -312,12 +312,8 @@ namespace DisplayMagician.UIForms
|
|||||||
_selectedShortcut = GetShortcutFromUUID(shortcutUUID);
|
_selectedShortcut = GetShortcutFromUUID(shortcutUUID);
|
||||||
|
|
||||||
this.Cursor = Cursors.WaitCursor;
|
this.Cursor = Cursors.WaitCursor;
|
||||||
|
|
||||||
// We need to stop ImageListView redrawing things before we're ready
|
var shortcutForm = new ShortcutForm(_selectedShortcut,true);
|
||||||
// This stops an exception when ILV is just too keen!
|
|
||||||
|
|
||||||
|
|
||||||
var shortcutForm = new ShortcutForm(_selectedShortcut);
|
|
||||||
//ilv_saved_shortcuts.SuspendLayout();
|
//ilv_saved_shortcuts.SuspendLayout();
|
||||||
shortcutForm.ShowDialog(this);
|
shortcutForm.ShowDialog(this);
|
||||||
if (shortcutForm.DialogResult == DialogResult.OK)
|
if (shortcutForm.DialogResult == DialogResult.OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user