Fixed issues creating new Shortcuts

This commit is contained in:
Terry MacDonald 2022-04-13 21:28:18 +12:00
parent 11792ec1a3
commit 5d97bf5d38
3 changed files with 42 additions and 17 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.3.0.36")]
[assembly: AssemblyFileVersion("2.3.0.36")]
[assembly: AssemblyVersion("2.3.0.46")]
[assembly: AssemblyFileVersion("2.3.0.46")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -153,8 +153,8 @@ namespace DisplayMagician
private bool _autoName = true;
private ShortcutValidity _isValid;
private List<ShortcutError> _shortcutErrors = new List<ShortcutError>();
private List<StartProgram> _startPrograms;
private List<StopProgram> _stopPrograms;
private List<StartProgram> _startPrograms = new List<StartProgram> ();
private List<StopProgram> _stopPrograms = new List<StopProgram>();
private Bitmap _shortcutBitmap, _originalBitmap;
[JsonIgnore]
#pragma warning disable CS3008 // Identifier is not CLS-compliant

View File

@ -883,14 +883,17 @@ namespace DisplayMagician.UIForms
}
// Look for any start programs without an exe
List<StartProgram> startProgramsToStartWithoutExe = _shortcutToEdit.StartPrograms.Where(program => program.Executable == null).ToList();
if (startProgramsToStartWithoutExe.Count > 0)
if (_shortcutToEdit.StartPrograms.Count > 0)
{
foreach (StartProgram myStartProgram in startProgramsToStartWithoutExe)
List<StartProgram> startProgramsToStartWithoutExe = _shortcutToEdit.StartPrograms.Where(program => program.Executable == null).ToList();
if (startProgramsToStartWithoutExe.Count > 0)
{
logger.Error($"ShortcutForm/CanEnableSaveButton: The start program at position #{myStartProgram.Priority} doesn't have an executable listed");
foreach (StartProgram myStartProgram in startProgramsToStartWithoutExe)
{
logger.Error($"ShortcutForm/CanEnableSaveButton: The start program at position #{myStartProgram.Priority} doesn't have an executable listed");
}
return false;
}
return false;
}
// Check the stop program has an exe in there
@ -923,9 +926,9 @@ namespace DisplayMagician.UIForms
else if (rb_switch_display_temp.Checked)
txt_shortcut_save_name.Text = $"{_profileToUse.Name} (Temporary)";
}
else if (rb_launcher.Checked && ilv_games.SelectedItems.Count > 0)
else if (rb_launcher.Checked && ilv_games.SelectedItems.Count > 0 && _selectedGame != null)
{
txt_shortcut_save_name.Text = $"{txt_game_name.Text} ({_profileToUse.Name})";
txt_shortcut_save_name.Text = $"{_selectedGame.Name} ({_profileToUse.Name})";
}
else if (rb_standalone.Checked && txt_executable.Text.Length > 0)
{
@ -956,6 +959,7 @@ namespace DisplayMagician.UIForms
//_loadedProfiles = new List<ProfileItem>();
_profileToUse = null;
_gameLauncher = "";
//_gameToUse;
// _executableToUse;
_displayPermanence = ShortcutPermanence.Temporary;
@ -983,6 +987,7 @@ namespace DisplayMagician.UIForms
selectedCaptureDevice = null;
_hotkey = Keys.None;
// Prepare the Game process priority combo box
cbx_game_priority.DataSource = new ComboItem[] {
new ComboItem{ Value = ProcessPriority.High, Text = "High" },
@ -1297,6 +1302,8 @@ namespace DisplayMagician.UIForms
}
_profileToUse = chosenProfile;
// *** 2. Choose Audio Tab ***
// Populate all the Audio devices in the audio devices list.
// Set the Audio device to the shortcut audio device only if
@ -1955,6 +1962,7 @@ namespace DisplayMagician.UIForms
}
}
_profileToUse = chosenProfile;
}
@ -2078,6 +2086,7 @@ namespace DisplayMagician.UIForms
_shortcutToEdit.AvailableImages = _selectedGame.AvailableGameBitmaps;
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
_shortcutToEdit.SelectedImage = _selectedImage;
txt_game_name.Text = _selectedGame.Name;
pb_game_icon.Image = _selectedImage.Image;
btn_choose_game_icon.Enabled = true;
}
@ -3120,14 +3129,30 @@ namespace DisplayMagician.UIForms
_shortcutToEdit.AvailableImages = game.AvailableGameBitmaps;
_selectedImage = ImageUtils.GetMeLargestAvailableBitmap(_availableImages);
_shortcutToEdit.SelectedImage = _selectedImage;
txt_game_name.Text = game.Name;
pb_game_icon.Image = _selectedImage.Image;
btn_choose_game_icon.Enabled = true;
break;
}
}
SuggestShortcutName();
EnableSaveButtonIfValid();
try
{
SuggestShortcutName();
}
catch(Exception ex)
{
}
try
{
EnableSaveButtonIfValid();
}
catch (Exception ex)
{
}
}