Additional stop program settings.

This commit is contained in:
Terry MacDonald 2021-11-02 22:54:34 +13:00
parent fb482030e2
commit 6febe82c2f
2 changed files with 65 additions and 3 deletions

View File

@ -61,6 +61,18 @@ namespace DisplayMagician
public bool DontStartIfAlreadyRunning;
}
public struct StopProgram
{
public int Priority;
public bool Disabled;
public ProcessPriority ProcessPriority;
public string Executable;
public string Arguments;
public bool ExecutableArgumentsRequired;
public bool CloseOnFinish;
public bool DontStartIfAlreadyRunning;
}
public struct Executable
{
public string DifferentExecutableToMonitor;
@ -139,6 +151,7 @@ namespace DisplayMagician
private ShortcutValidity _isValid;
private List<ShortcutError> _shortcutErrors = new List<ShortcutError>();
private List<StartProgram> _startPrograms;
private List<StopProgram> _stopPrograms;
private Bitmap _shortcutBitmap, _originalBitmap;
[JsonIgnore]
#pragma warning disable CS3008 // Identifier is not CLS-compliant
@ -641,6 +654,20 @@ namespace DisplayMagician
}
}
public List<StopProgram> StopPrograms
{
get
{
return _stopPrograms;
}
set
{
_stopPrograms = value;
}
}
public string OriginalIconPath {
get
{
@ -788,6 +815,7 @@ namespace DisplayMagician
bool setCaptureVolume = false,
decimal captureVolume = -1,
List<StartProgram> startPrograms = null,
List<StopProgram> stopPrograms = null,
bool autoName = true,
Keys hotkey = Keys.None,
string uuid = ""
@ -843,7 +871,8 @@ namespace DisplayMagician
string captureDevice = "",
bool setCaptureVolume = false,
decimal captureVolume = -1,
List<StartProgram> startPrograms = null,
List<StartProgram> startPrograms = null,
List<StopProgram> stopPrograms = null,
bool autoName = true,
string uuid = "",
Keys hotkey = Keys.None
@ -877,6 +906,7 @@ namespace DisplayMagician
_capturePermanence = capturePermanence;
_autoName = autoName;
_startPrograms = startPrograms;
_stopPrograms = stopPrograms;
_originalIconPath = originalIconPath;
_userChoseOwnIcon = userChoseOwnIcon;
_availableImages = availableImages;
@ -912,7 +942,8 @@ namespace DisplayMagician
string captureDevice = "",
bool setCaptureVolume = false,
decimal captureVolume = -1,
List<StartProgram> startPrograms = null,
List<StartProgram> startPrograms = null,
List<StopProgram> stopPrograms = null,
bool autoName = true,
Keys hotkey = Keys.None,
string uuid = ""
@ -943,6 +974,7 @@ namespace DisplayMagician
_capturePermanence = capturePermanence;
_autoName = autoName;
_startPrograms = startPrograms;
_stopPrograms = stopPrograms;
_originalIconPath = originalIconPath;
_userChoseOwnIcon = userChoseOwnIcon;
_availableImages = availableImages;
@ -995,6 +1027,7 @@ namespace DisplayMagician
shortcut.IsValid = IsValid;
shortcut.Errors.AddRange(Errors);
shortcut.StartPrograms = StartPrograms;
shortcut.StopPrograms = StopPrograms;
shortcut.ChangeAudioDevice = ChangeAudioDevice;
shortcut.AudioDevice = AudioDevice;
shortcut.SetAudioVolume = SetAudioVolume;

View File

@ -36,6 +36,7 @@ namespace DisplayMagician.UIForms
private ShortcutPermanence _audioPermanence = ShortcutPermanence.Temporary;
private ShortcutPermanence _capturePermanence = ShortcutPermanence.Temporary;
List<StartProgram> _startPrograms = new List<StartProgram>();
List<StopProgram> _stopPrograms = new List<StopProgram>();
private string _audioDevice = "";
private bool _changeAudioDevice = false;
private bool _setAudioVolume = false;
@ -496,7 +497,23 @@ namespace DisplayMagician.UIForms
// Replace the old start programs with the ones we've created now
_startPrograms = newStartPrograms;
// Store the single stop program if it's set (but wth lots of defaults)
if (!String.IsNullOrWhiteSpace(txt_run_cmd_afterwards.Text) && File.Exists(txt_run_cmd_afterwards.Text))
{
_stopPrograms = new List<StopProgram>();
StopProgram stopProgram = new StopProgram();
stopProgram.Executable = txt_run_cmd_afterwards.Text;
stopProgram.Priority = 0;
stopProgram.DontStartIfAlreadyRunning = false;
stopProgram.Arguments = "";
stopProgram.Disabled = false;
stopProgram.ExecutableArgumentsRequired = false;
stopProgram.ProcessPriority = ProcessPriority.Normal;
_stopPrograms.Add(stopProgram);
}
// Now we create the Shortcut Object ready to save
// If we're launching a game
if (rb_launcher.Checked)
@ -580,6 +597,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_uuid,
_hotkey
@ -606,6 +624,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_uuid,
_hotkey
@ -657,6 +676,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_hotkey
);
@ -682,6 +702,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_hotkey
);
@ -709,6 +730,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_hotkey
);
@ -731,6 +753,7 @@ namespace DisplayMagician.UIForms
_setCaptureVolume,
_captureVolume,
_startPrograms,
_stopPrograms,
_autoName,
_hotkey
);
@ -1429,6 +1452,12 @@ namespace DisplayMagician.UIForms
}
}
// Setup the single stop program we're beginning with
if (_shortcutToEdit.StopPrograms is List<StopProgram> && _shortcutToEdit.StopPrograms.Count > 0)
{
txt_run_cmd_afterwards.Text = _shortcutToEdit.StopPrograms[0].Executable;
}
// Refresh the Shortcut UI
RefreshShortcutUI();
ChangeSelectedProfile(chosenProfile);