mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Attempting to create Shortcut ID
Partial attempt at a Shortcut ID. Need to refactor slightly to move more logic to the Shortcut itself rather than in the form!
This commit is contained in:
parent
4d8e69d6ba
commit
b31d233678
@ -28,6 +28,7 @@ namespace HeliosPlus
|
||||
{
|
||||
Application,
|
||||
Game,
|
||||
NoGame,
|
||||
}
|
||||
|
||||
public class Shortcut
|
||||
@ -51,7 +52,9 @@ namespace HeliosPlus
|
||||
|
||||
public static Version Version = new Version(1, 0);
|
||||
|
||||
public string Name { get; set; } = "Current Display Profile";
|
||||
public uint Id { get; set; } = 0;
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[JsonIgnore]
|
||||
public Profile ProfileToUse { get; set; } = null;
|
||||
@ -73,11 +76,11 @@ namespace HeliosPlus
|
||||
|
||||
public ShortcutCategory Category { get; set; } = ShortcutCategory.Game;
|
||||
|
||||
public string ProcessNameToMonitor { get; set; } = "";
|
||||
public string DifferentExecutableToMonitor { get; set; } = "";
|
||||
|
||||
public string ExecutableNameAndPath { get; set; } = "";
|
||||
|
||||
public uint ExecutableTimeout { get; set; } = 0;
|
||||
public uint ExecutableTimeout { get; set; } = 30;
|
||||
|
||||
public string ExecutableArguments { get; set; } = "";
|
||||
|
||||
@ -91,7 +94,7 @@ namespace HeliosPlus
|
||||
|
||||
public SupportedGameLibrary GameLibrary { get; set; } = SupportedGameLibrary.Unknown;
|
||||
|
||||
public uint GameTimeout { get; set; } = 0;
|
||||
public uint GameTimeout { get; set; } = 30;
|
||||
|
||||
public string GameArguments { get; set; } = "";
|
||||
|
||||
|
136
HeliosPlus/UIForms/ShortcutForm.Designer.cs
generated
136
HeliosPlus/UIForms/ShortcutForm.Designer.cs
generated
@ -37,8 +37,6 @@ namespace HeliosPlus.UIForms
|
||||
this.btn_cancel = new System.Windows.Forms.Button();
|
||||
this.il_games = new System.Windows.Forms.ImageList(this.components);
|
||||
this.dialog_open = new System.Windows.Forms.OpenFileDialog();
|
||||
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.tabc_shortcut = new System.Windows.Forms.TabControl();
|
||||
this.tabp_display = new System.Windows.Forms.TabPage();
|
||||
this.lbl_profile_shown_subtitle = new System.Windows.Forms.Label();
|
||||
@ -48,11 +46,12 @@ namespace HeliosPlus.UIForms
|
||||
this.tabp_before = new System.Windows.Forms.TabPage();
|
||||
this.tabp_game = new System.Windows.Forms.TabPage();
|
||||
this.p_standalone = new System.Windows.Forms.Panel();
|
||||
this.btn_exe_to_start = new System.Windows.Forms.Button();
|
||||
this.txt_args_executable = new System.Windows.Forms.TextBox();
|
||||
this.cb_args_executable = new System.Windows.Forms.CheckBox();
|
||||
this.btn_app_process = new System.Windows.Forms.Button();
|
||||
this.txt_process_name = new System.Windows.Forms.TextBox();
|
||||
this.rb_wait_process = new System.Windows.Forms.RadioButton();
|
||||
this.btn_app_different_executable = new System.Windows.Forms.Button();
|
||||
this.txt_alternative_executable = new System.Windows.Forms.TextBox();
|
||||
this.rb_wait_alternative_executable = new System.Windows.Forms.RadioButton();
|
||||
this.rb_wait_executable = new System.Windows.Forms.RadioButton();
|
||||
this.txt_executable = new System.Windows.Forms.TextBox();
|
||||
this.lbl_app_executable = new System.Windows.Forms.Label();
|
||||
@ -81,6 +80,7 @@ namespace HeliosPlus.UIForms
|
||||
this.txt_shortcut_save_name = new System.Windows.Forms.TextBox();
|
||||
this.lbl_title = new System.Windows.Forms.Label();
|
||||
this.lbl_shortcut_name = new System.Windows.Forms.Label();
|
||||
this.cb_autosuggest = new System.Windows.Forms.CheckBox();
|
||||
this.tabc_shortcut.SuspendLayout();
|
||||
this.tabp_display.SuspendLayout();
|
||||
this.tabp_game.SuspendLayout();
|
||||
@ -136,18 +136,6 @@ namespace HeliosPlus.UIForms
|
||||
this.dialog_open.RestoreDirectory = true;
|
||||
this.dialog_open.SupportMultiDottedExtensions = true;
|
||||
//
|
||||
// dialog_save
|
||||
//
|
||||
this.dialog_save.DefaultExt = "lnk";
|
||||
this.dialog_save.DereferenceLinks = false;
|
||||
this.dialog_save.Filter = global::HeliosPlus.Resources.Language.Shortcuts_Filter;
|
||||
this.dialog_save.RestoreDirectory = true;
|
||||
//
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
this.openFileDialog1.Title = "Title";
|
||||
//
|
||||
// tabc_shortcut
|
||||
//
|
||||
this.tabc_shortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@ -272,11 +260,12 @@ namespace HeliosPlus.UIForms
|
||||
//
|
||||
// p_standalone
|
||||
//
|
||||
this.p_standalone.Controls.Add(this.btn_exe_to_start);
|
||||
this.p_standalone.Controls.Add(this.txt_args_executable);
|
||||
this.p_standalone.Controls.Add(this.cb_args_executable);
|
||||
this.p_standalone.Controls.Add(this.btn_app_process);
|
||||
this.p_standalone.Controls.Add(this.txt_process_name);
|
||||
this.p_standalone.Controls.Add(this.rb_wait_process);
|
||||
this.p_standalone.Controls.Add(this.btn_app_different_executable);
|
||||
this.p_standalone.Controls.Add(this.txt_alternative_executable);
|
||||
this.p_standalone.Controls.Add(this.rb_wait_alternative_executable);
|
||||
this.p_standalone.Controls.Add(this.rb_wait_executable);
|
||||
this.p_standalone.Controls.Add(this.txt_executable);
|
||||
this.p_standalone.Controls.Add(this.lbl_app_executable);
|
||||
@ -288,6 +277,18 @@ namespace HeliosPlus.UIForms
|
||||
this.p_standalone.Size = new System.Drawing.Size(1006, 160);
|
||||
this.p_standalone.TabIndex = 10;
|
||||
//
|
||||
// btn_exe_to_start
|
||||
//
|
||||
this.btn_exe_to_start.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_exe_to_start.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_exe_to_start.Location = new System.Drawing.Point(593, 10);
|
||||
this.btn_exe_to_start.Name = "btn_exe_to_start";
|
||||
this.btn_exe_to_start.Size = new System.Drawing.Size(85, 27);
|
||||
this.btn_exe_to_start.TabIndex = 12;
|
||||
this.btn_exe_to_start.Text = "Choose";
|
||||
this.btn_exe_to_start.UseVisualStyleBackColor = true;
|
||||
this.btn_exe_to_start.Click += new System.EventHandler(this.btn_exe_to_start_Click);
|
||||
//
|
||||
// txt_args_executable
|
||||
//
|
||||
this.txt_args_executable.Enabled = false;
|
||||
@ -307,39 +308,42 @@ namespace HeliosPlus.UIForms
|
||||
this.cb_args_executable.Text = "Pass arguments to Executable:";
|
||||
this.cb_args_executable.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.cb_args_executable.UseVisualStyleBackColor = true;
|
||||
this.cb_args_executable.CheckedChanged += new System.EventHandler(this.cb_args_executable_CheckedChanged);
|
||||
this.cb_args_executable.Paint += new System.Windows.Forms.PaintEventHandler(this.checkbox_Paint);
|
||||
//
|
||||
// btn_app_process
|
||||
// btn_app_different_executable
|
||||
//
|
||||
this.btn_app_process.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_app_process.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_app_process.Location = new System.Drawing.Point(739, 115);
|
||||
this.btn_app_process.Name = "btn_app_process";
|
||||
this.btn_app_process.Size = new System.Drawing.Size(85, 27);
|
||||
this.btn_app_process.TabIndex = 9;
|
||||
this.btn_app_process.Text = "Choose";
|
||||
this.btn_app_process.UseVisualStyleBackColor = true;
|
||||
this.btn_app_process.Click += new System.EventHandler(this.btn_app_process_Click);
|
||||
this.btn_app_different_executable.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_app_different_executable.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_app_different_executable.Location = new System.Drawing.Point(877, 115);
|
||||
this.btn_app_different_executable.Name = "btn_app_different_executable";
|
||||
this.btn_app_different_executable.Size = new System.Drawing.Size(85, 27);
|
||||
this.btn_app_different_executable.TabIndex = 9;
|
||||
this.btn_app_different_executable.Text = "Choose";
|
||||
this.btn_app_different_executable.UseVisualStyleBackColor = true;
|
||||
this.btn_app_different_executable.Click += new System.EventHandler(this.btn_app_different_executable_Click);
|
||||
//
|
||||
// txt_process_name
|
||||
// txt_alternative_executable
|
||||
//
|
||||
this.txt_process_name.Enabled = false;
|
||||
this.txt_process_name.Location = new System.Drawing.Point(446, 116);
|
||||
this.txt_process_name.Name = "txt_process_name";
|
||||
this.txt_process_name.Size = new System.Drawing.Size(287, 26);
|
||||
this.txt_process_name.TabIndex = 4;
|
||||
this.txt_alternative_executable.Enabled = false;
|
||||
this.txt_alternative_executable.Location = new System.Drawing.Point(493, 116);
|
||||
this.txt_alternative_executable.Name = "txt_alternative_executable";
|
||||
this.txt_alternative_executable.Size = new System.Drawing.Size(378, 26);
|
||||
this.txt_alternative_executable.TabIndex = 4;
|
||||
this.txt_alternative_executable.TextChanged += new System.EventHandler(this.txt_different_executable_TextChanged);
|
||||
//
|
||||
// rb_wait_process
|
||||
// rb_wait_alternative_executable
|
||||
//
|
||||
this.rb_wait_process.AutoSize = true;
|
||||
this.rb_wait_process.ForeColor = System.Drawing.Color.White;
|
||||
this.rb_wait_process.Location = new System.Drawing.Point(23, 117);
|
||||
this.rb_wait_process.Name = "rb_wait_process";
|
||||
this.rb_wait_process.Size = new System.Drawing.Size(428, 24);
|
||||
this.rb_wait_process.TabIndex = 8;
|
||||
this.rb_wait_process.Text = "Change Display Profile back when this process is closed: ";
|
||||
this.rb_wait_process.UseVisualStyleBackColor = true;
|
||||
this.rb_wait_process.Paint += new System.Windows.Forms.PaintEventHandler(this.radiobutton_Paint);
|
||||
this.rb_wait_alternative_executable.AutoSize = true;
|
||||
this.rb_wait_alternative_executable.ForeColor = System.Drawing.Color.White;
|
||||
this.rb_wait_alternative_executable.Location = new System.Drawing.Point(23, 118);
|
||||
this.rb_wait_alternative_executable.Name = "rb_wait_alternative_executable";
|
||||
this.rb_wait_alternative_executable.Size = new System.Drawing.Size(468, 24);
|
||||
this.rb_wait_alternative_executable.TabIndex = 8;
|
||||
this.rb_wait_alternative_executable.Text = "Wait until an alternative executable is closed before continuing:";
|
||||
this.rb_wait_alternative_executable.UseVisualStyleBackColor = true;
|
||||
this.rb_wait_alternative_executable.CheckedChanged += new System.EventHandler(this.rb_wait_process_CheckedChanged);
|
||||
this.rb_wait_alternative_executable.Paint += new System.Windows.Forms.PaintEventHandler(this.radiobutton_Paint);
|
||||
//
|
||||
// rb_wait_executable
|
||||
//
|
||||
@ -348,11 +352,12 @@ namespace HeliosPlus.UIForms
|
||||
this.rb_wait_executable.ForeColor = System.Drawing.Color.White;
|
||||
this.rb_wait_executable.Location = new System.Drawing.Point(23, 87);
|
||||
this.rb_wait_executable.Name = "rb_wait_executable";
|
||||
this.rb_wait_executable.Size = new System.Drawing.Size(486, 24);
|
||||
this.rb_wait_executable.Size = new System.Drawing.Size(439, 24);
|
||||
this.rb_wait_executable.TabIndex = 7;
|
||||
this.rb_wait_executable.TabStop = true;
|
||||
this.rb_wait_executable.Text = "Change Display Profile back when the executable above is closed";
|
||||
this.rb_wait_executable.Text = "Wait until the executable above is closed before continuing";
|
||||
this.rb_wait_executable.UseVisualStyleBackColor = true;
|
||||
this.rb_wait_executable.CheckedChanged += new System.EventHandler(this.rb_wait_executable_CheckedChanged);
|
||||
this.rb_wait_executable.Paint += new System.Windows.Forms.PaintEventHandler(this.radiobutton_Paint);
|
||||
//
|
||||
// txt_executable
|
||||
@ -361,6 +366,7 @@ namespace HeliosPlus.UIForms
|
||||
this.txt_executable.Name = "txt_executable";
|
||||
this.txt_executable.Size = new System.Drawing.Size(416, 26);
|
||||
this.txt_executable.TabIndex = 1;
|
||||
this.txt_executable.TextChanged += new System.EventHandler(this.txt_executable_TextChanged);
|
||||
//
|
||||
// lbl_app_executable
|
||||
//
|
||||
@ -532,6 +538,7 @@ namespace HeliosPlus.UIForms
|
||||
this.cb_args_game.Text = "Pass arguments to Game:";
|
||||
this.cb_args_game.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.cb_args_game.UseVisualStyleBackColor = true;
|
||||
this.cb_args_game.CheckedChanged += new System.EventHandler(this.cb_args_game_CheckedChanged);
|
||||
this.cb_args_game.Paint += new System.Windows.Forms.PaintEventHandler(this.checkbox_Paint);
|
||||
//
|
||||
// lbl_game_timeout
|
||||
@ -640,11 +647,12 @@ namespace HeliosPlus.UIForms
|
||||
// txt_shortcut_save_name
|
||||
//
|
||||
this.txt_shortcut_save_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txt_shortcut_save_name.Location = new System.Drawing.Point(441, 707);
|
||||
this.txt_shortcut_save_name.Location = new System.Drawing.Point(326, 707);
|
||||
this.txt_shortcut_save_name.MaxLength = 200;
|
||||
this.txt_shortcut_save_name.Name = "txt_shortcut_save_name";
|
||||
this.txt_shortcut_save_name.Size = new System.Drawing.Size(409, 35);
|
||||
this.txt_shortcut_save_name.Size = new System.Drawing.Size(511, 35);
|
||||
this.txt_shortcut_save_name.TabIndex = 29;
|
||||
this.txt_shortcut_save_name.Click += new System.EventHandler(this.txt_shortcut_save_name_Click);
|
||||
this.txt_shortcut_save_name.TextChanged += new System.EventHandler(this.txt_shortcut_save_name_TextChanged);
|
||||
//
|
||||
// lbl_title
|
||||
@ -663,12 +671,26 @@ namespace HeliosPlus.UIForms
|
||||
this.lbl_shortcut_name.AutoSize = true;
|
||||
this.lbl_shortcut_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lbl_shortcut_name.ForeColor = System.Drawing.Color.Transparent;
|
||||
this.lbl_shortcut_name.Location = new System.Drawing.Point(264, 710);
|
||||
this.lbl_shortcut_name.Location = new System.Drawing.Point(142, 710);
|
||||
this.lbl_shortcut_name.Name = "lbl_shortcut_name";
|
||||
this.lbl_shortcut_name.Size = new System.Drawing.Size(178, 29);
|
||||
this.lbl_shortcut_name.TabIndex = 31;
|
||||
this.lbl_shortcut_name.Text = "Shortcut Name:";
|
||||
//
|
||||
// cb_autosuggest
|
||||
//
|
||||
this.cb_autosuggest.AutoSize = true;
|
||||
this.cb_autosuggest.Checked = true;
|
||||
this.cb_autosuggest.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cb_autosuggest.ForeColor = System.Drawing.Color.White;
|
||||
this.cb_autosuggest.Location = new System.Drawing.Point(856, 716);
|
||||
this.cb_autosuggest.Name = "cb_autosuggest";
|
||||
this.cb_autosuggest.Size = new System.Drawing.Size(117, 17);
|
||||
this.cb_autosuggest.TabIndex = 32;
|
||||
this.cb_autosuggest.Text = "Auto-suggest name";
|
||||
this.cb_autosuggest.UseVisualStyleBackColor = true;
|
||||
this.cb_autosuggest.CheckedChanged += new System.EventHandler(this.cb_autosuggest_CheckedChanged);
|
||||
//
|
||||
// ShortcutForm
|
||||
//
|
||||
this.AcceptButton = this.btn_save;
|
||||
@ -677,6 +699,7 @@ namespace HeliosPlus.UIForms
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.CancelButton = this.btn_cancel;
|
||||
this.ClientSize = new System.Drawing.Size(1114, 806);
|
||||
this.Controls.Add(this.cb_autosuggest);
|
||||
this.Controls.Add(this.txt_shortcut_save_name);
|
||||
this.Controls.Add(this.lbl_shortcut_name);
|
||||
this.Controls.Add(this.lbl_title);
|
||||
@ -691,6 +714,7 @@ namespace HeliosPlus.UIForms
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "HeliosPlus - Configure a Game Shortcut";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShortcutForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.ShortcutForm_Load);
|
||||
this.tabc_shortcut.ResumeLayout(false);
|
||||
this.tabp_display.ResumeLayout(false);
|
||||
@ -714,8 +738,6 @@ namespace HeliosPlus.UIForms
|
||||
private System.Windows.Forms.Button btn_save;
|
||||
private System.Windows.Forms.Button btn_cancel;
|
||||
private System.Windows.Forms.OpenFileDialog dialog_open;
|
||||
private System.Windows.Forms.SaveFileDialog dialog_save;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.ImageList il_games;
|
||||
private System.Windows.Forms.TabControl tabc_shortcut;
|
||||
private System.Windows.Forms.TabPage tabp_display;
|
||||
@ -746,9 +768,9 @@ namespace HeliosPlus.UIForms
|
||||
private System.Windows.Forms.Panel p_standalone;
|
||||
private System.Windows.Forms.TextBox txt_args_executable;
|
||||
private System.Windows.Forms.CheckBox cb_args_executable;
|
||||
private System.Windows.Forms.Button btn_app_process;
|
||||
private System.Windows.Forms.TextBox txt_process_name;
|
||||
private System.Windows.Forms.RadioButton rb_wait_process;
|
||||
private System.Windows.Forms.Button btn_app_different_executable;
|
||||
private System.Windows.Forms.TextBox txt_alternative_executable;
|
||||
private System.Windows.Forms.RadioButton rb_wait_alternative_executable;
|
||||
private System.Windows.Forms.RadioButton rb_wait_executable;
|
||||
private System.Windows.Forms.TextBox txt_executable;
|
||||
private System.Windows.Forms.Label lbl_app_executable;
|
||||
@ -759,5 +781,7 @@ namespace HeliosPlus.UIForms
|
||||
private System.Windows.Forms.RadioButton rb_switch_temp;
|
||||
private System.Windows.Forms.Label lbl_title;
|
||||
private System.Windows.Forms.Label lbl_shortcut_name;
|
||||
private System.Windows.Forms.Button btn_exe_to_start;
|
||||
private System.Windows.Forms.CheckBox cb_autosuggest;
|
||||
}
|
||||
}
|
@ -21,14 +21,14 @@ namespace HeliosPlus.UIForms
|
||||
|
||||
List<SteamGame> _allSteamGames;
|
||||
private ProfileAdaptor _profileAdaptor;
|
||||
private static bool _inDialog = false;
|
||||
private List<Profile> _loadedProfiles = new List<Profile>();
|
||||
private Profile _profileToUse= null;
|
||||
private Shortcut _shortcutToEdit = null;
|
||||
private string _saveOrRenameMode = "save";
|
||||
private bool _isNewShortcut = true;
|
||||
private bool _isNewShortcut = false;
|
||||
private bool _isUnsaved = false;
|
||||
private bool _saveNameAutomatic = true;
|
||||
private uint _gameId = 0;
|
||||
private uint _id = 0;
|
||||
|
||||
public ShortcutForm()
|
||||
{
|
||||
@ -38,13 +38,22 @@ namespace HeliosPlus.UIForms
|
||||
// into the Profiles ImageListView
|
||||
_profileAdaptor = new ProfileAdaptor();
|
||||
|
||||
// Create a new SHortcut if we are creating a new one
|
||||
// And set up the page (otherwise this is all set when we load an
|
||||
// existing Shortcut)
|
||||
if (_shortcutToEdit == null)
|
||||
{
|
||||
_shortcutToEdit = new Shortcut();
|
||||
_isNewShortcut = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortcutForm(Shortcut shortcutToEdit) : this()
|
||||
{
|
||||
_shortcutToEdit = shortcutToEdit;
|
||||
|
||||
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
|
||||
_isNewShortcut = false;
|
||||
}
|
||||
|
||||
public string ProcessNameToMonitor
|
||||
@ -54,7 +63,7 @@ namespace HeliosPlus.UIForms
|
||||
if (rb_switch_temp.Checked && rb_standalone.Checked) {
|
||||
if (rb_wait_executable.Checked)
|
||||
{
|
||||
return txt_process_name.Text;
|
||||
return txt_alternative_executable.Text;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
@ -62,7 +71,7 @@ namespace HeliosPlus.UIForms
|
||||
set
|
||||
{
|
||||
// We we're setting this entry, then we want to set it to a particular entry
|
||||
txt_process_name.Text = value;
|
||||
txt_alternative_executable.Text = value;
|
||||
rb_wait_executable.Checked = true;
|
||||
}
|
||||
}
|
||||
@ -249,7 +258,7 @@ namespace HeliosPlus.UIForms
|
||||
}
|
||||
|
||||
// Please use a plain name that can be
|
||||
if (Shortcut.NameAlreadyExists(txt_shortcut_save_name.Text))
|
||||
if (_isNewShortcut && Shortcut.NameAlreadyExists(txt_shortcut_save_name.Text))
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"A shortcut has already been created with this name. Please enter a different name for this shortcut.",
|
||||
@ -270,9 +279,6 @@ namespace HeliosPlus.UIForms
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the permanence requirements
|
||||
if (rb_switch_permanent.Checked)
|
||||
{
|
||||
// Check the Shortcut Category to see if it's application
|
||||
if (rb_standalone.Checked)
|
||||
{
|
||||
@ -290,33 +296,35 @@ namespace HeliosPlus.UIForms
|
||||
if (!File.Exists(txt_executable.Text))
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"The executable you have chosen does not exist! Please reselect the executable, or check you have persmissions to view it.",
|
||||
@"The executable you have chosen does not exist! Please reselect the executable, or check you have permissions to view it.",
|
||||
@"Executable doesn't exist",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(txt_process_name.Text))
|
||||
if (rb_wait_alternative_executable.Checked && String.IsNullOrWhiteSpace(txt_alternative_executable.Text))
|
||||
{
|
||||
string message = "";
|
||||
|
||||
// figure out the message we want to give the user
|
||||
if (_shortcutToEdit.ProcessNameToMonitorUsesExecutable)
|
||||
message = @"Cannot work out the process to monitor from the executable. Please reselect the executable (and we'll try again), and if that doesn't work then manually enter the process name into the 'Process to monitor' field.";
|
||||
else
|
||||
message = @"Please manually enter the process name into the 'Process to monitor' field.";
|
||||
|
||||
// show the error message
|
||||
MessageBox.Show(
|
||||
message,
|
||||
@"Empty process monitor",
|
||||
$"If you want to wait for an alternative executable then you need to choose it! Click the 'Choose' button next to the different executable field.",
|
||||
@"Need to choose the different executable",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rb_wait_alternative_executable.Checked && !File.Exists(txt_alternative_executable.Text))
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"The alternative executable you have chosen does not exist! Please reselect the alternative executable, or check you have permissions to view it.",
|
||||
@"Alternative executable doesn't exist",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
else if (rb_switch_temp.Checked)
|
||||
|
||||
}
|
||||
else if (rb_launcher.Checked)
|
||||
{
|
||||
|
||||
if (cb_args_game.Checked && String.IsNullOrWhiteSpace(txt_args_game.Text))
|
||||
@ -338,7 +346,24 @@ namespace HeliosPlus.UIForms
|
||||
MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
bool gameStillInstalled = false;
|
||||
foreach (ListViewItem gameItem in lv_games.Items)
|
||||
{
|
||||
if (gameItem.Text.Equals(txt_game_name.Text))
|
||||
gameStillInstalled = true;
|
||||
}
|
||||
if (!gameStillInstalled)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(
|
||||
$"This shortcut refers to the '{txt_game_name.Text}' game that was installed in your {txt_game_launcher.Text} library. This game is no longer installed, so the shortcut won't work. Do you still want to save the shortcut?",
|
||||
@"Game no longer exists",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Exclamation);
|
||||
if (result == DialogResult.No)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Fill the Shortcut object with the bits we care about saving
|
||||
@ -384,14 +409,14 @@ namespace HeliosPlus.UIForms
|
||||
_shortcutToEdit.Permanence = ShortcutPermanence.Permanent;
|
||||
|
||||
// Update the process name to monitor
|
||||
if (!String.IsNullOrWhiteSpace(txt_process_name.Text)) {
|
||||
_shortcutToEdit.ProcessNameToMonitor = txt_process_name.Text;
|
||||
if (!String.IsNullOrWhiteSpace(txt_alternative_executable.Text)) {
|
||||
_shortcutToEdit.DifferentExecutableToMonitor = txt_alternative_executable.Text;
|
||||
}
|
||||
|
||||
if (rb_wait_process.Checked && !String.IsNullOrWhiteSpace(txt_process_name.Text))
|
||||
if (rb_wait_alternative_executable.Checked && !String.IsNullOrWhiteSpace(txt_alternative_executable.Text))
|
||||
{
|
||||
_shortcutToEdit.ProcessNameToMonitorUsesExecutable = true;
|
||||
_shortcutToEdit.ProcessNameToMonitor = txt_process_name.Text;
|
||||
_shortcutToEdit.DifferentExecutableToMonitor = txt_alternative_executable.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -438,31 +463,15 @@ namespace HeliosPlus.UIForms
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
private void txt_different_executable_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
}
|
||||
|
||||
private void txt_executable_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
if (File.Exists(txt_executable.Text))
|
||||
{
|
||||
|
||||
// Try and discern the process name for this
|
||||
// if the user hasn't entered anything already
|
||||
if (txt_process_name.Text == String.Empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
txt_process_name.Text = Path.GetFileNameWithoutExtension(txt_executable.Text)?.ToLower() ?? txt_process_name.Text;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
suggestShortcutName();
|
||||
enableSaveButtonIfValid();
|
||||
}
|
||||
|
||||
@ -472,7 +481,7 @@ namespace HeliosPlus.UIForms
|
||||
_profileToUse is Profile &&
|
||||
(rb_no_game.Checked ||
|
||||
rb_launcher.Checked && _gameId > 0 ||
|
||||
rb_standalone.Checked && txt_args_executable.Text.Length > 0))
|
||||
rb_standalone.Checked && txt_executable.Text.Length > 0))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -484,6 +493,30 @@ namespace HeliosPlus.UIForms
|
||||
btn_save.Enabled = true;
|
||||
else
|
||||
btn_save.Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
private void suggestShortcutName()
|
||||
{
|
||||
if (_saveNameAutomatic && _profileToUse is Profile)
|
||||
{
|
||||
if (rb_no_game.Checked)
|
||||
{
|
||||
if (rb_switch_permanent.Checked)
|
||||
txt_shortcut_save_name.Text = $"{_profileToUse.Name}";
|
||||
else if (rb_switch_temp.Checked)
|
||||
txt_shortcut_save_name.Text = $"{_profileToUse.Name} (Temporary)";
|
||||
}
|
||||
else if (rb_launcher.Checked && txt_game_name.Text.Length > 0)
|
||||
{
|
||||
txt_shortcut_save_name.Text = $"{txt_game_name.Text} ({_profileToUse.Name})";
|
||||
}
|
||||
else if (rb_standalone.Checked && txt_executable.Text.Length > 0)
|
||||
{
|
||||
string baseName = Path.GetFileNameWithoutExtension(txt_executable.Text);
|
||||
txt_shortcut_save_name.Text = $"{baseName} ({_profileToUse.Name})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rb_standalone_CheckedChanged(object sender, EventArgs e)
|
||||
@ -499,6 +532,7 @@ namespace HeliosPlus.UIForms
|
||||
// Disable the Game Panel
|
||||
p_game.Enabled = false;
|
||||
|
||||
suggestShortcutName();
|
||||
enableSaveButtonIfValid();
|
||||
}
|
||||
|
||||
@ -517,6 +551,7 @@ namespace HeliosPlus.UIForms
|
||||
// Disable the Standalone Panel
|
||||
p_standalone.Enabled = false;
|
||||
|
||||
suggestShortcutName();
|
||||
enableSaveButtonIfValid();
|
||||
|
||||
}
|
||||
@ -535,6 +570,7 @@ namespace HeliosPlus.UIForms
|
||||
// Disable the Game Panel
|
||||
p_game.Enabled = false;
|
||||
|
||||
suggestShortcutName();
|
||||
enableSaveButtonIfValid();
|
||||
|
||||
}
|
||||
@ -574,20 +610,6 @@ namespace HeliosPlus.UIForms
|
||||
private async void ShortcutForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
// Create a new SHortcut if we are creating a new one
|
||||
// And set up the page.
|
||||
if (_shortcutToEdit == null)
|
||||
{
|
||||
_shortcutToEdit = new Shortcut();
|
||||
_isNewShortcut = true;
|
||||
_saveOrRenameMode = "save";
|
||||
}
|
||||
else
|
||||
{
|
||||
_isNewShortcut = false;
|
||||
_saveOrRenameMode = "rename";
|
||||
}
|
||||
|
||||
// Load all the profiles to prepare things
|
||||
_loadedProfiles = (List<Profile>)Profile.LoadAllProfiles();
|
||||
|
||||
@ -610,8 +632,6 @@ namespace HeliosPlus.UIForms
|
||||
if (!foundCurrentProfileInLoadedProfiles && _loadedProfiles.Count > 0)
|
||||
ChangeSelectedProfile(_loadedProfiles[0]);
|
||||
|
||||
// Refresh the Shortcut UI
|
||||
RefreshShortcutUI();
|
||||
|
||||
// Start finding the games and loading the Games ListView
|
||||
List<SteamGame> allSteamGames = SteamGame.GetAllInstalledGames();
|
||||
@ -663,15 +683,96 @@ namespace HeliosPlus.UIForms
|
||||
ImageIndex = il_games.Images.Count - 1
|
||||
});
|
||||
}
|
||||
|
||||
// Now start populating the other fields
|
||||
|
||||
if (_shortcutToEdit.Id == 0)
|
||||
{
|
||||
// This is a new Shortcut so we need to figure out what the next
|
||||
// ID will need to be set to.
|
||||
try
|
||||
{
|
||||
_id = (from shortcut in Shortcut.AllSavedShortcuts select shortcut.Id).Max<uint>() + 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_id = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
_id = _shortcutToEdit.Id;
|
||||
// Set if we launch App/Game/NoGame
|
||||
switch (_shortcutToEdit.Category)
|
||||
{
|
||||
case ShortcutCategory.NoGame:
|
||||
rb_no_game.Checked = true;
|
||||
break;
|
||||
case ShortcutCategory.Game:
|
||||
rb_launcher.Checked = true;
|
||||
break;
|
||||
case ShortcutCategory.Application:
|
||||
rb_standalone.Checked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the launcher items if we have them
|
||||
txt_game_launcher.Text = _shortcutToEdit.GameLibrary.ToString();
|
||||
txt_game_name.Text = _shortcutToEdit.GameName;
|
||||
_gameId = _shortcutToEdit.GameAppId;
|
||||
nud_timeout_game.Value = _shortcutToEdit.GameTimeout;
|
||||
txt_args_game.Text = _shortcutToEdit.GameArguments;
|
||||
if (_shortcutToEdit.GameArgumentsRequired)
|
||||
{
|
||||
cb_args_game.Checked = true;
|
||||
}
|
||||
|
||||
//select the loaded Game item if it is there
|
||||
foreach (ListViewItem gameItem in lv_games.Items)
|
||||
{
|
||||
if (gameItem.Text.Equals(_shortcutToEdit.GameName))
|
||||
{
|
||||
gameItem.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the executable items if we have them
|
||||
txt_executable.Text = _shortcutToEdit.ExecutableNameAndPath;
|
||||
nud_timeout_executable.Value = _shortcutToEdit.ExecutableTimeout;
|
||||
txt_args_executable.Text = _shortcutToEdit.ExecutableArguments;
|
||||
if (_shortcutToEdit.ExecutableArgumentsRequired)
|
||||
{
|
||||
cb_args_executable.Checked = true;
|
||||
}
|
||||
if (_shortcutToEdit.ProcessNameToMonitorUsesExecutable)
|
||||
{
|
||||
rb_wait_executable.Checked = true;
|
||||
rb_wait_alternative_executable.Checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rb_wait_executable.Checked = false;
|
||||
rb_wait_alternative_executable.Checked = true;
|
||||
}
|
||||
txt_alternative_executable.Text = _shortcutToEdit.DifferentExecutableToMonitor;
|
||||
|
||||
|
||||
// Set the shortcut name
|
||||
txt_shortcut_save_name.Text = _shortcutToEdit.Name;
|
||||
|
||||
// Refresh the Shortcut UI
|
||||
RefreshShortcutUI();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void rb_wait_process_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (rb_wait_process.Checked)
|
||||
if (rb_wait_alternative_executable.Checked)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
rb_wait_executable.Checked = false;
|
||||
txt_process_name.Enabled = true;
|
||||
txt_alternative_executable.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,20 +781,20 @@ namespace HeliosPlus.UIForms
|
||||
if (rb_wait_executable.Checked)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
rb_wait_process.Checked = false;
|
||||
txt_process_name.Enabled = false;
|
||||
rb_wait_alternative_executable.Checked = false;
|
||||
txt_alternative_executable.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void btn_app_process_Click(object sender, EventArgs e)
|
||||
private void btn_app_different_executable_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
if (File.Exists(dialog_open.FileName) && Path.GetExtension(dialog_open.FileName) == @".exe")
|
||||
{
|
||||
txt_process_name.Text = dialog_open.FileName;
|
||||
txt_alternative_executable.Text = dialog_open.FileName;
|
||||
dialog_open.FileName = string.Empty;
|
||||
}
|
||||
else
|
||||
@ -735,6 +836,7 @@ namespace HeliosPlus.UIForms
|
||||
}
|
||||
}
|
||||
|
||||
suggestShortcutName();
|
||||
enableSaveButtonIfValid();
|
||||
|
||||
}
|
||||
@ -792,8 +894,6 @@ namespace HeliosPlus.UIForms
|
||||
private void RefreshShortcutUI()
|
||||
{
|
||||
|
||||
if (!_inDialog)
|
||||
{
|
||||
|
||||
if (_loadedProfiles.Count > 0)
|
||||
{
|
||||
@ -833,39 +933,13 @@ namespace HeliosPlus.UIForms
|
||||
ilv_saved_profiles.ResumeLayout();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
// Otherwise turn off the dialog mode we were just in
|
||||
_inDialog = false;
|
||||
|
||||
enableSaveButtonIfValid();
|
||||
}
|
||||
|
||||
private void btn_back_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_isUnsaved)
|
||||
{
|
||||
// If the user doesn't want to close this window without saving, then don't close the window.
|
||||
DialogResult result = MessageBox.Show(
|
||||
@"You have unsaved changes! Do you want to close this window without saving your changes?",
|
||||
@"You have unsaved changes.",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Exclamation);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void radiobutton_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
@ -932,6 +1006,8 @@ namespace HeliosPlus.UIForms
|
||||
{
|
||||
_isUnsaved = true;
|
||||
rb_switch_permanent.Checked = false;
|
||||
|
||||
suggestShortcutName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,6 +1017,7 @@ namespace HeliosPlus.UIForms
|
||||
{
|
||||
_isUnsaved = true;
|
||||
rb_switch_temp.Checked = false;
|
||||
suggestShortcutName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -954,5 +1031,56 @@ namespace HeliosPlus.UIForms
|
||||
{
|
||||
_isUnsaved = true;
|
||||
}
|
||||
|
||||
private void ShortcutForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
|
||||
if (_isUnsaved)
|
||||
{
|
||||
// If the user doesn't want to close this window without saving, then don't close the window.
|
||||
DialogResult result = MessageBox.Show(
|
||||
@"You have unsaved changes! Do you want to close this window without saving your changes?",
|
||||
@"You have unsaved changes.",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Exclamation);
|
||||
e.Cancel = (result == DialogResult.No);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btn_exe_to_start_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
_isUnsaved = true;
|
||||
if (File.Exists(dialog_open.FileName) && Path.GetExtension(dialog_open.FileName) == @".exe")
|
||||
{
|
||||
txt_executable.Text = dialog_open.FileName;
|
||||
dialog_open.FileName = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
Language.Selected_file_is_not_a_valid_executable_file,
|
||||
Language.Executable,
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void txt_shortcut_save_name_Click(object sender, EventArgs e)
|
||||
{
|
||||
_saveNameAutomatic = false;
|
||||
cb_autosuggest.Checked = false;
|
||||
}
|
||||
|
||||
private void cb_autosuggest_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cb_autosuggest.Checked)
|
||||
_saveNameAutomatic = true;
|
||||
else
|
||||
_saveNameAutomatic = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -118,17 +118,11 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="il_games.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>513, 24</value>
|
||||
<value>151, 20</value>
|
||||
</metadata>
|
||||
<metadata name="dialog_open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dialog_save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>258, 24</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>373, 24</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>67</value>
|
||||
</metadata>
|
||||
|
Loading…
Reference in New Issue
Block a user