Fixed ShortcutAdaptor errors and Saved prompt

Did a fix for the SHortcutAdaptor doing exceptions
for showing the form before loading all the graphics
but can't really do much about it without adding
background loading to the main form. This is a lot of
work considering we'll be moving from WinForms
to WPF UI in the future.

Also fixed the 'Do you want to save' prompt detection
logic so that it correctly waits until all the loading has
finished before monitoring for users making changes.
Should stop the form incorrectly suggesting you
should save unless they've really made a change.
This commit is contained in:
terrymacdonald 2020-07-15 20:11:38 +12:00
parent 0e985238f9
commit 85963b3417
16 changed files with 166 additions and 112 deletions

View File

@ -100,8 +100,9 @@ namespace HeliosPlus.Shared
{
NvAPIWrapper.NVIDIA.Initialize();
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutItem/Instansiation exception: {ex.Message}: {ex.InnerException}");
// ignored
}
@ -364,8 +365,9 @@ namespace HeliosPlus.Shared
GridTopology.SetGridTopologies(surroundTopologies, SetDisplayTopologyFlag.MaximizePerformance);
}
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileItem/ApplyTopos exception: {ex.Message}: {ex.InnerException}");
// ignored
}
}

View File

@ -165,8 +165,9 @@ namespace HeliosPlus.Shared
{
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/RemoveProfile exception: {ex.Message}: {ex.InnerException}");
// TODO check and report
}
}
@ -199,8 +200,9 @@ namespace HeliosPlus.Shared
{
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/RemoveProfile exception 2: {ex.Message}: {ex.InnerException}");
// TODO check and report
}
}
@ -233,8 +235,9 @@ namespace HeliosPlus.Shared
{
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/RemoveProfile exception 3: {ex.Message}: {ex.InnerException}");
// TODO check and report
}
}
@ -419,6 +422,7 @@ namespace HeliosPlus.Shared
catch (Exception ex)
{
// ignored
Console.WriteLine($"ProfileRepository/LoadProfiles exception: {ex.Message}: {ex.InnerException}");
Console.WriteLine($"Unable to load Profiles from JSON file {_profileStorageJsonFileName}: " + ex.Message);
}
@ -473,6 +477,7 @@ namespace HeliosPlus.Shared
}
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/SaveProfiles exception: {ex.Message}: {ex.InnerException}");
Console.WriteLine($"Unable to create Profile folder {_profileStorageJsonPath}: " + ex.Message);
}
@ -497,6 +502,7 @@ namespace HeliosPlus.Shared
}
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/SaveProfiles exception 2: {ex.Message}: {ex.InnerException}");
Console.WriteLine($"Unable to save Profile JSON file {_profileStorageJsonFileName}: " + ex.Message);
}
@ -517,6 +523,7 @@ namespace HeliosPlus.Shared
}
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/SaveProfileIconToCache exception: {ex.Message}: {ex.InnerException}");
// If we fail to create an icon based on the Profile, then we use the standard HeliosPlus profile one.
// Which is created on program startup.
File.Copy(AppHeliosPlusIconFilename, profile.SavedProfileIconCacheFilename);
@ -560,6 +567,7 @@ namespace HeliosPlus.Shared
}
catch (Exception ex)
{
Console.WriteLine($"ProfileRepository/ApplyProfile exception: {ex.Message}: {ex.InnerException}");
UpdateCurrentProfile();
Console.WriteLine($"Profile: Problem applying the '{profile.Name}' Display Profile: {ex.Message}");
MessageBox.Show($"Problem applying the '{profile.Name}' Display Profile! \n(ex.Message)", $"Problem applying '{profile.Name}' Profile", MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@ -102,18 +102,20 @@ namespace HeliosPlus.GameLibraries
return false;
}
}
catch (SecurityException e)
catch (SecurityException ex)
{
if (e.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsRunning securityexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (IOException e)
catch (IOException ex)
{
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsRunning ioexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
}
@ -135,18 +137,20 @@ namespace HeliosPlus.GameLibraries
return false;
}
}
catch (SecurityException e)
catch (SecurityException ex)
{
if (e.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating securityexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (IOException e)
catch (IOException ex)
{
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating ioexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
}
@ -318,8 +322,9 @@ namespace HeliosPlus.GameLibraries
}
steamAppInfo.Add(app.AppID, steamGameAppInfo);
}
catch (ArgumentException e)
catch (ArgumentException ex)
{
Console.WriteLine($"SteamGame/GetAllInstalledGames exception: {ex.Message}: {ex.InnerException}");
//we just want to ignore it if we try to add it twice....
}
@ -439,30 +444,34 @@ namespace HeliosPlus.GameLibraries
}
}
}
catch (SecurityException e)
catch (SecurityException ex)
{
if (e.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/GetAllInstalledGames securityexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (UnauthorizedAccessException e)
catch (UnauthorizedAccessException ex)
{
if (e.Source != null)
Console.WriteLine("UnauthorizedAccessException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/GetAllInstalledGames unauthorizedaccessexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("UnauthorizedAccessException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (ObjectDisposedException e)
catch (ObjectDisposedException ex)
{
if (e.Source != null)
Console.WriteLine("ObjectDisposedException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/GetAllInstalledGames objectdisposedexceptions: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("ObjectDisposedException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (IOException e)
catch (IOException ex)
{
Console.WriteLine($"SteamGame/GetAllInstalledGames ioexception: {ex.Message}: {ex.InnerException}");
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", e.Source, e.Message);
if (ex.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}

View File

@ -102,18 +102,20 @@ namespace HeliosPlus.GameLibraries
return false;
}
}
catch (SecurityException e)
catch (SecurityException ex)
{
if (e.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating securityexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (IOException e)
catch (IOException ex)
{
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating ioexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
}
@ -135,18 +137,20 @@ namespace HeliosPlus.GameLibraries
return false;
}
}
catch (SecurityException e)
catch (SecurityException ex)
{
if (e.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating securityexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("SecurityException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
catch (IOException e)
catch (IOException ex)
{
// Extract some information from this exception, and then
// throw it to the parent method.
if (e.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", e.Source, e.Message);
Console.WriteLine($"SteamGame/IsUpdating ioexception: {ex.Message}: {ex.InnerException}");
if (ex.Source != null)
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
throw;
}
}
@ -319,8 +323,9 @@ namespace HeliosPlus.GameLibraries
}
uplayAppInfo.Add(app.AppID, uplayGameAppInfo);
}
catch (ArgumentException e)
catch (ArgumentException ex)
{
Console.WriteLine($"UplayGame/GetAllInstalledGames argumentexception: {ex.Message}: {ex.InnerException}");
//we just want to ignore it if we try to add it twice....
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Description;
@ -49,8 +50,9 @@ namespace HeliosPlus.InterProcess
{
processChannel = new IPCClient(process);
}
catch
catch (Exception ex)
{
Console.WriteLine($"IPCClient/QueryAll exception: {ex.Message}: {ex.InnerException}");
// ignored
}
@ -78,8 +80,9 @@ namespace HeliosPlus.InterProcess
return processChannel;
}
}
catch
catch (Exception ex)
{
Console.WriteLine($"IPCClient/QueryByStatus exception: {ex.Message}: {ex.InnerException}");
// ignored
}
}

View File

@ -51,14 +51,16 @@ namespace HeliosPlus.InterProcess
return true;
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine($"IPCService/StartService exception: {ex.Message}: {ex.InnerException}");
try
{
_serviceHost?.Close();
}
catch
catch (Exception ex2)
{
Console.WriteLine($"IPCService/StartService exception 2: {ex2.Message}: {ex2.InnerException}");
// ignored
}

View File

@ -202,6 +202,7 @@ namespace HeliosPlus {
}
catch (CommandParsingException ex)
{
Console.WriteLine($"Program/Main commandParsingException: {ex.Message}: {ex.InnerException}");
// You'll always want to catch this exception, otherwise it will generate a messy and confusing error for the end user.
// the message will usually be something like:
// "Unrecognized command or argument '<invalid-command>'"
@ -209,6 +210,7 @@ namespace HeliosPlus {
}
catch (Exception ex)
{
Console.WriteLine($"Program/Main exception: {ex.Message}: {ex.InnerException}");
Console.WriteLine("Unable to execute application: {0}", ex.Message);
}
return 0;
@ -239,8 +241,9 @@ namespace HeliosPlus {
{
Directory.CreateDirectory(AppIconPath);
}
catch
catch (Exception ex)
{
Console.WriteLine($"Program/StartUpNormally exception: {ex.Message}: {ex.InnerException}");
// TODO
}
}
@ -287,8 +290,9 @@ namespace HeliosPlus {
heliosIcon.Save(fs);
}
}
catch
catch (Exception ex)
{
Console.WriteLine($"Program/StartUpNormally exception 2: {ex.Message}: {ex.InnerException}");
// TODO
}
@ -298,6 +302,7 @@ namespace HeliosPlus {
}
catch (Exception ex)
{
Console.WriteLine($"Program/StartUpNormally exception 3: {ex.Message}: {ex.InnerException}");
MessageBox.Show(
ex.Message,
Language.Fatal_Error,
@ -374,8 +379,9 @@ namespace HeliosPlus {
};
Application.DoEvents();
}
catch
catch (Exception ex)
{
Console.WriteLine($"Program/SwitchToExecutable exception: {ex.Message}: {ex.InnerException}");
// ignored
}
@ -385,8 +391,9 @@ namespace HeliosPlus {
{
p.WaitForExit();
}
catch
catch (Exception ex)
{
Console.WriteLine($"Program/SwitchToExecutable exception 2: {ex.Message}: {ex.InnerException}");
// ignored
}
}
@ -514,8 +521,9 @@ namespace HeliosPlus {
};
Application.DoEvents();
}
catch
catch (Exception ex)
{
Console.WriteLine($"Program/SwitchToSteamGame exception: {ex.Message}: {ex.InnerException}");
// ignored
}

View File

@ -327,7 +327,11 @@ namespace HeliosPlus
}
}
}
catch { return null; }
catch (Exception ex)
{
Console.WriteLine($"ShortcutItem/ExtractVisataIcon exception: {ex.Message}: {ex.InnerException}");
return null;
}
return bmpPngExtracted;
}
@ -582,16 +586,20 @@ namespace HeliosPlus
}
finally
{
Console.WriteLine($"ShortcutItem/CreateShortcut exception (saving)");
Marshal.FinalReleaseComObject(shortcut);
}
}
finally
{
Console.WriteLine($"ShortcutItem/CreateShortcut exception (Creating shortcut)");
Marshal.FinalReleaseComObject(wshShell);
}
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutItem/CreateShortcut exception (deleting old shortcut)");
// Clean up a failed attempt
if (File.Exists(shortcutFileName))
{

View File

@ -134,8 +134,10 @@ namespace HeliosPlus
{
File.Delete(shortcutToRemove.SavedShortcutIconCacheFilename);
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutRepository/RemoveShortcut exception: {ex.Message}: {ex.InnerException}");
// TODO check and report
}
}
@ -182,8 +184,10 @@ namespace HeliosPlus
{
File.Delete(shortcutToRemove.SavedShortcutIconCacheFilename);
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutRepository/RemoveShortcut exception 2: {ex.Message}: {ex.InnerException}");
// TODO check and report
}
}
@ -354,6 +358,8 @@ namespace HeliosPlus
}
catch (Exception ex)
{
Console.WriteLine($"ShortcutRepository/SaveShortcuts exception: {ex.Message}: {ex.InnerException}");
Console.WriteLine($"Unable to create Shortcut folder {_shortcutStorageJsonPath}: " + ex.Message);
}
@ -378,6 +384,8 @@ namespace HeliosPlus
}
catch (Exception ex)
{
Console.WriteLine($"ShortcutRepository/SaveShortcuts exception 2: {ex.Message}: {ex.InnerException}");
Console.WriteLine($"Unable to save Shortcut JSON file {_shortcutStorageJsonFileName}: " + ex.Message);
}
@ -434,6 +442,8 @@ namespace HeliosPlus
}
catch (Exception ex)
{
Console.WriteLine($"ShortcutRepository/SaveShortcutIconToCache exception: {ex.Message}: {ex.InnerException}");
// If we fail to create an icon based on the original executable or game
// Then we use the standard HeliosPlus profile one.
shortcutIcon = shortcut.ProfileToUse.ProfileIcon.ToIcon();

View File

@ -188,8 +188,9 @@ namespace HeliosPlus.UIForms
{
Opacity = f;
}
catch
catch (Exception ex)
{
Console.WriteLine($"ApplyingChangesForm/SplashForm_FormClosing exception: {ex.Message}: {ex.InnerException}");
// ignored
}
}, this), new SafeInvoker(() =>
@ -213,8 +214,9 @@ namespace HeliosPlus.UIForms
{
Opacity = f;
}
catch
catch (Exception ex)
{
Console.WriteLine($"ApplyingChangesForm/SplashForm_Shown exception: {ex.Message}: {ex.InnerException}");
// ignored
}
}, this), new SafeInvoker(DoTimeout, this));

View File

@ -18,15 +18,14 @@ namespace HeliosPlus.UIForms
private string _saveOrRenameMode = "save";
//private static bool _inDialog = false;
private static ProfileItem _profileToLoad = null;
private ProfileAdaptor _profileAdaptor;
private ProfileRepository _profileRepository;
private ProfileAdaptor _profileAdaptor = new ProfileAdaptor();
private ProfileRepository _profileRepository = new ProfileRepository();
public DisplayProfileForm()
{
InitializeComponent();
this.AcceptButton = this.btn_save_or_rename;
_profileAdaptor = new ProfileAdaptor();
_profileRepository = new ProfileRepository();
//_profileRepository = new ProfileRepository();
}
public DisplayProfileForm(ProfileItem profileToLoad) : this()

View File

@ -64,7 +64,9 @@ namespace HeliosPlus.UIForms
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
return profileToUse.ProfileBitmap.GetThumbnailImage(size.Width, size.Height, myCallback, IntPtr.Zero);
}
catch {
catch (Exception ex)
{
Console.WriteLine($"ProfileAdaptor/GetThumbnail exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;
@ -90,11 +92,18 @@ namespace HeliosPlus.UIForms
try
{
string profileName = (string)key;
return profileName;
}
catch
ProfileItem profileToUse = (ProfileItem)key;
if (profileToUse == null)
{
profileToUse = ProfileRepository.CurrentProfile;
}
return profileToUse.Name;
}
catch (Exception ex)
{
Console.WriteLine($"ProfileAdaptor/GertUniqueIdentifier exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;
@ -116,8 +125,9 @@ namespace HeliosPlus.UIForms
string profileName = (string)key;
return profileName;
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileAdaptor/GetSourceImage exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;
@ -138,17 +148,7 @@ namespace HeliosPlus.UIForms
try
{
string profileName = (string)key;
ProfileItem profileToUse = null;
foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles)
{
if (profileToTest.Name == profileName)
{
profileToUse = profileToTest;
}
}
ProfileItem profileToUse = (ProfileItem)key;
if (profileToUse == null)
{
@ -183,8 +183,9 @@ namespace HeliosPlus.UIForms
return details.ToArray();
}
catch
catch (Exception ex)
{
Console.WriteLine($"ProfileAdaptor/Utility.Tuple exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;

View File

@ -53,7 +53,10 @@ namespace HeliosPlus.UIForms
//return shortcut.ShortcutBitmap.GetThumbnailImage(size.Width, size.Height, myCallback, IntPtr.Zero);
return shortcut.ShortcutBitmap;
}
catch {
catch (Exception ex)
{
Console.WriteLine($"ShortcutAdapter/GetThumbnail exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;
@ -79,11 +82,12 @@ namespace HeliosPlus.UIForms
try
{
ShortcutItem shortcutName = (ShortcutItem) key;
return shortcutName.Name;
ShortcutItem shortcut = (ShortcutItem) key;
return shortcut.Name;
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutAdapter/GetUniqueIdentifier exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a Shortcut
// Then we return null
return null;
@ -102,18 +106,13 @@ namespace HeliosPlus.UIForms
try
{
//Shortcut shortcut = (Shortcut)key;
//return shortcut.SavedShortcutIconCacheFilename;
string shortcutName = (string)key;
/* Shortcut shortcut = (from item in Shortcut.AllSavedShortcuts where item.Name == shortcutName select item).First();
if (shortcut is Shortcut)
return shortcut.SavedShortcutIconCacheFilename;
else
return null;*/
return shortcutName;
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutAdaptor/GetSourceImage exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;
@ -134,7 +133,6 @@ namespace HeliosPlus.UIForms
try
{
ShortcutItem shortcut = (ShortcutItem) key;
// Get file info
@ -165,8 +163,9 @@ namespace HeliosPlus.UIForms
return details.ToArray();
}
catch
catch (Exception ex)
{
Console.WriteLine($"ShortcutAdapter/Utility.Tuple exception: {ex.Message}: {ex.InnerException}");
// If we have a problem with converting the submitted key to a profile
// Then we return null
return null;

View File

@ -587,7 +587,6 @@ namespace HeliosPlus.UIForms
this.lv_games.SmallImageList = this.il_games;
this.lv_games.TabIndex = 22;
this.lv_games.UseCompatibleStateImageBehavior = false;
this.lv_games.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lv_games_ItemSelectionChanged);
this.lv_games.DoubleClick += new System.EventHandler(this.btn_choose_game_Click);
//
// rb_launcher

View File

@ -676,8 +676,9 @@ namespace HeliosPlus.UIForms
il_games.Images.Add(extractedBitmap);
}
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine($"ShortcutForm exception: {ex.Message}: {ex.InnerException}");
il_games.Images.Add(Image.FromFile("Resources/Steam.ico"));
}
} else
@ -686,6 +687,7 @@ namespace HeliosPlus.UIForms
il_games.Images.Add(Image.FromFile("Resources/Steam.ico"));
}
if (!Visible)
{
return;
@ -700,7 +702,6 @@ namespace HeliosPlus.UIForms
}
// Now start populating the other fields
_uuid = _shortcutToEdit.UUID;
// Set if we launch App/Game/NoGame
switch (_shortcutToEdit.Category)
@ -738,7 +739,6 @@ namespace HeliosPlus.UIForms
}
}
// Set the executable items if we have them
txt_executable.Text = _shortcutToEdit.ExecutableNameAndPath;
nud_timeout_executable.Value = _shortcutToEdit.ExecutableTimeout;
@ -759,7 +759,6 @@ namespace HeliosPlus.UIForms
}
txt_alternative_executable.Text = _shortcutToEdit.DifferentExecutableToMonitor;
// Set the shortcut name
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
@ -857,6 +856,8 @@ namespace HeliosPlus.UIForms
if (loadedProfile.Name == e.Item.Text)
{
ChangeSelectedProfile(loadedProfile);
if (_loadedShortcut)
_isUnsaved = true;
}
}
@ -1039,16 +1040,10 @@ namespace HeliosPlus.UIForms
enableSaveButtonIfValid();
}
private void lv_games_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (_loadedShortcut)
_isUnsaved = true;
}
private void ShortcutForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (_isUnsaved)
if (_isUnsaved && _loadedShortcut)
{
// If the user doesn't want to close this window without saving, then don't close the window.
DialogResult result = MessageBox.Show(
@ -1085,12 +1080,16 @@ namespace HeliosPlus.UIForms
private void txt_shortcut_save_name_Click(object sender, EventArgs e)
{
if (_loadedShortcut)
_isUnsaved = true;
_saveNameAutomatic = false;
cb_autosuggest.Checked = false;
}
private void cb_autosuggest_CheckedChanged(object sender, EventArgs e)
{
if (_loadedShortcut)
_isUnsaved = true;
if (cb_autosuggest.Checked)
_saveNameAutomatic = true;
else

View File

@ -20,18 +20,18 @@ namespace HeliosPlus.UIForms
public partial class ShortcutLibraryForm : Form
{
private ShortcutAdaptor _shortcutAdaptor;
private ShortcutAdaptor _shortcutAdaptor = new ShortcutAdaptor();
private ImageListViewItem _selectedShortcutILVItem = null;
private ShortcutItem _selectedShortcut = null;
private ShortcutRepository _shortcutRepository;
private ProfileRepository _profileRepository;
private ShortcutRepository _shortcutRepository = new ShortcutRepository();
private ProfileRepository _profileRepository = new ProfileRepository();
public ShortcutLibraryForm()
{
InitializeComponent();
_shortcutAdaptor = new ShortcutAdaptor();
_shortcutRepository = new ShortcutRepository();
_profileRepository = new ProfileRepository();
//_shortcutAdaptor = new ShortcutAdaptor();
//_shortcutRepository = new ShortcutRepository();
//_profileRepository = new ProfileRepository();
}
private void btn_new_Click(object sender, EventArgs e)