mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixed shortcut editing and icon updates
The shortcut editing window was broken and was not copying the information across properly to the new shortcuts when the shortcut was edited. I have now moved to actually replacing the shortcut when the form updates it. So basically the ShortcutForm loads the shortcut info from the ShortcutItem, then when you save the form, it returns a new ShortcutItem. The shortcut library then removes the old shortcut (which removes the icons, and updates the file), then it saves the new shortcut we just created (which saves the icons and updates the save file). This was the easiest way to make the shortcut modification process work.
This commit is contained in:
@ -308,6 +308,55 @@ namespace HeliosPlus
|
||||
return true;
|
||||
}
|
||||
|
||||
/* public static bool ReplaceShortcut(ShortcutItem oldShortcut, ShortcutItem newShortcut)
|
||||
{
|
||||
if (!(oldShortcut is ShortcutItem) || !(newShortcut is ShortcutItem))
|
||||
return false;
|
||||
|
||||
// Remove the old Shortcut Icons from the Cache
|
||||
List<ShortcutItem> shortcutsToRemove = _allShortcuts.FindAll(item => item.UUID.Equals(oldShortcut.UUID, StringComparison.InvariantCultureIgnoreCase));
|
||||
foreach (ShortcutItem shortcutToRemove in shortcutsToRemove)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(shortcutToRemove.SavedShortcutIconCacheFilename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"ShortcutRepository/ReplaceShortcut exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
|
||||
|
||||
// TODO check and report
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the shortcut from the list.
|
||||
int numRemoved = _allShortcuts.RemoveAll(item => item.UUID.Equals(shortcut.UUID, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
SaveShortcuts();
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
return false;
|
||||
else
|
||||
throw new ShortcutRepositoryException();
|
||||
|
||||
|
||||
foreach (ShortcutItem testShortcut in ShortcutRepository.AllShortcuts)
|
||||
{
|
||||
if (testShortcut.ProfileUUID.Equals(newProfile.UUID, StringComparison.InvariantCultureIgnoreCase) && testShortcut.AutoName)
|
||||
{
|
||||
testShortcut.ProfileToUse = newProfile;
|
||||
testShortcut.AutoSuggestShortcutName();
|
||||
}
|
||||
}
|
||||
|
||||
SaveShortcuts();
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
|
||||
private static bool LoadShortcuts()
|
||||
{
|
||||
@ -356,7 +405,7 @@ namespace HeliosPlus
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool SaveShortcuts()
|
||||
public static bool SaveShortcuts()
|
||||
{
|
||||
|
||||
if (!Directory.Exists(AppShortcutStoragePath))
|
||||
|
Reference in New Issue
Block a user