diff --git a/DisplayMagician/DisplayMagician.csproj b/DisplayMagician/DisplayMagician.csproj index 16ba568..86404fa 100644 --- a/DisplayMagician/DisplayMagician.csproj +++ b/DisplayMagician/DisplayMagician.csproj @@ -78,6 +78,7 @@ + diff --git a/DisplayMagician/ShortcutItem.cs b/DisplayMagician/ShortcutItem.cs index 740bd48..f434c05 100644 --- a/DisplayMagician/ShortcutItem.cs +++ b/DisplayMagician/ShortcutItem.cs @@ -43,7 +43,7 @@ namespace DisplayMagician public struct StartProgram { public int Priority; - public bool Enabled; + public bool Disabled; public string Executable; public string Arguments; public bool ExecutableArgumentsRequired; diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index d08933a..4da386c 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -773,7 +773,7 @@ namespace DisplayMagician // Now run the pre-start applications List startProgramsToStop = new List(); - List startProgramsToStart = shortcutToUse.StartPrograms.Where(program => program.Enabled == true).OrderBy(program => program.Priority).ToList(); + List startProgramsToStart = shortcutToUse.StartPrograms.Where(program => program.Disabled == true).OrderBy(program => program.Priority).ToList(); if (startProgramsToStart.Count > 0) { logger.Info($"ShortcutRepository/RunShortcut: Starting {startProgramsToStart.Count} programs before the main game or executable"); diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs index 237cca5..719a23d 100644 --- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs +++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs @@ -629,10 +629,12 @@ namespace DisplayMagician.UIForms // pnl_start_programs // this.pnl_start_programs.AutoScroll = true; + this.pnl_start_programs.AutoScrollMargin = new System.Drawing.Size(5, 5); + this.pnl_start_programs.AutoScrollMinSize = new System.Drawing.Size(5, 5); this.pnl_start_programs.BackColor = System.Drawing.Color.White; - this.pnl_start_programs.Location = new System.Drawing.Point(58, 65); + this.pnl_start_programs.Location = new System.Drawing.Point(38, 126); this.pnl_start_programs.Name = "pnl_start_programs"; - this.pnl_start_programs.Size = new System.Drawing.Size(987, 507); + this.pnl_start_programs.Size = new System.Drawing.Size(1007, 446); this.pnl_start_programs.TabIndex = 2; // // tabp_game diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 313a2a5..26eaaeb 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -1165,20 +1165,27 @@ namespace DisplayMagician.UIForms if (_shortcutToEdit.StartPrograms is List && _shortcutToEdit.StartPrograms.Count > 0) { - int x = 0; - int y = 0; + int x = 5; + int y = 5; + + Padding startProgramMargin = new Padding(10) { }; // Order the inital list in order of priority foreach (StartProgram myStartProgram in _shortcutToEdit.StartPrograms.OrderBy(sp => sp.Priority)) { StartProgramControl startProgramControl = new StartProgramControl(myStartProgram); + startProgramControl.Dock = DockStyle.None; + startProgramControl.Margin = startProgramMargin; + startProgramControl.Width = pnl_start_programs.Width - 30; + //startProgramControl.Height = pnl_start_programs.Height; startProgramControl.Location = new Point(x, y); - startProgramControl.BringToFront(); - startProgramControl.Margin = DefaultMargin; - startProgramControl.Width = pnl_start_programs.Width; + // startProgramControl.BringToFront(); + //startProgramControl.Margin = DefaultMargin; + //startProgramControl.Width = pnl_start_programs.Width; pnl_start_programs.Controls.Add(startProgramControl); - y += startProgramControl.Height; + // Move the next line down + y += startProgramControl.Height + 5; } } @@ -1429,7 +1436,7 @@ namespace DisplayMagician.UIForms // Restart updating the saved_profiles listview ilv_saved_profiles.ResumeLayout(); - } + } UpdateHotkeyLabel(_shortcutToEdit.Hotkey); EnableSaveButtonIfValid(); @@ -2009,6 +2016,24 @@ namespace DisplayMagician.UIForms } } + public void RemoveStartProgram(StartProgramControl startProgramControlToRemove) + { + foreach (StartProgram startProgramToTest in _shortcutToEdit.StartPrograms) + { + if (startProgramControlToRemove.StartProgram.Equals(startProgramToTest)) + { + // If we find the start program then we need to remove it from the list + _shortcutToEdit.StartPrograms.Remove(startProgramToTest); + // And we reove the program control passed in as well + pnl_start_programs.Controls.Remove(startProgramControlToRemove); + break; + } + } + + // And we redraw the panel again + pnl_start_programs.Refresh(); + } + private void btn_hotkey_Click(object sender, EventArgs e) { Keys testHotkey; diff --git a/DisplayMagician/UIForms/StartProgramControl.Designer.cs b/DisplayMagician/UIForms/StartProgramControl.Designer.cs index 56f9ff7..225f9b4 100644 --- a/DisplayMagician/UIForms/StartProgramControl.Designer.cs +++ b/DisplayMagician/UIForms/StartProgramControl.Designer.cs @@ -36,7 +36,8 @@ namespace DisplayMagician.UIForms this.txt_start_program_args = new System.Windows.Forms.TextBox(); this.cb_start_program_pass_args = new System.Windows.Forms.CheckBox(); this.btn_delete = new System.Windows.Forms.Button(); - this.cb_start_program = new System.Windows.Forms.CheckBox(); + this.cb_disable_start_program = new System.Windows.Forms.CheckBox(); + this.lbl_start_program = new System.Windows.Forms.Label(); this.SuspendLayout(); // // cb_dont_start_if_running @@ -44,7 +45,7 @@ namespace DisplayMagician.UIForms this.cb_dont_start_if_running.AutoSize = true; this.cb_dont_start_if_running.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cb_dont_start_if_running.ForeColor = System.Drawing.Color.White; - this.cb_dont_start_if_running.Location = new System.Drawing.Point(135, 97); + this.cb_dont_start_if_running.Location = new System.Drawing.Point(78, 91); this.cb_dont_start_if_running.Name = "cb_dont_start_if_running"; this.cb_dont_start_if_running.Size = new System.Drawing.Size(289, 24); this.cb_dont_start_if_running.TabIndex = 26; @@ -57,9 +58,9 @@ namespace DisplayMagician.UIForms this.txt_start_program.BackColor = System.Drawing.Color.White; this.txt_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txt_start_program.ForeColor = System.Drawing.Color.Black; - this.txt_start_program.Location = new System.Drawing.Point(268, 20); + this.txt_start_program.Location = new System.Drawing.Point(221, 17); this.txt_start_program.Name = "txt_start_program"; - this.txt_start_program.Size = new System.Drawing.Size(535, 26); + this.txt_start_program.Size = new System.Drawing.Size(503, 26); this.txt_start_program.TabIndex = 25; // // cb_start_program_close @@ -67,7 +68,7 @@ namespace DisplayMagician.UIForms this.cb_start_program_close.AutoSize = true; this.cb_start_program_close.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cb_start_program_close.ForeColor = System.Drawing.Color.White; - this.cb_start_program_close.Location = new System.Drawing.Point(515, 97); + this.cb_start_program_close.Location = new System.Drawing.Point(422, 91); this.cb_start_program_close.Name = "cb_start_program_close"; this.cb_start_program_close.Size = new System.Drawing.Size(398, 24); this.cb_start_program_close.TabIndex = 24; @@ -77,10 +78,11 @@ namespace DisplayMagician.UIForms // // btn_start_program // + this.btn_start_program.Anchor = System.Windows.Forms.AnchorStyles.None; this.btn_start_program.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_start_program.ForeColor = System.Drawing.Color.White; - this.btn_start_program.Location = new System.Drawing.Point(819, 19); + this.btn_start_program.Location = new System.Drawing.Point(730, 17); this.btn_start_program.Name = "btn_start_program"; this.btn_start_program.Size = new System.Drawing.Size(85, 27); this.btn_start_program.TabIndex = 23; @@ -93,9 +95,9 @@ namespace DisplayMagician.UIForms this.txt_start_program_args.BackColor = System.Drawing.Color.White; this.txt_start_program_args.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txt_start_program_args.ForeColor = System.Drawing.Color.Black; - this.txt_start_program_args.Location = new System.Drawing.Point(365, 60); + this.txt_start_program_args.Location = new System.Drawing.Point(309, 56); this.txt_start_program_args.Name = "txt_start_program_args"; - this.txt_start_program_args.Size = new System.Drawing.Size(540, 26); + this.txt_start_program_args.Size = new System.Drawing.Size(506, 26); this.txt_start_program_args.TabIndex = 22; // // cb_start_program_pass_args @@ -103,7 +105,7 @@ namespace DisplayMagician.UIForms this.cb_start_program_pass_args.AutoSize = true; this.cb_start_program_pass_args.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cb_start_program_pass_args.ForeColor = System.Drawing.Color.White; - this.cb_start_program_pass_args.Location = new System.Drawing.Point(135, 62); + this.cb_start_program_pass_args.Location = new System.Drawing.Point(79, 58); this.cb_start_program_pass_args.Name = "cb_start_program_pass_args"; this.cb_start_program_pass_args.Size = new System.Drawing.Size(228, 24); this.cb_start_program_pass_args.TabIndex = 21; @@ -114,10 +116,11 @@ namespace DisplayMagician.UIForms // // btn_delete // + this.btn_delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btn_delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_delete.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_delete.ForeColor = System.Drawing.Color.White; - this.btn_delete.Location = new System.Drawing.Point(933, 3); + this.btn_delete.Location = new System.Drawing.Point(868, 3); this.btn_delete.Name = "btn_delete"; this.btn_delete.Size = new System.Drawing.Size(29, 27); this.btn_delete.TabIndex = 27; @@ -127,24 +130,35 @@ namespace DisplayMagician.UIForms // // cb_start_program // - this.cb_start_program.AutoSize = true; - this.cb_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cb_start_program.ForeColor = System.Drawing.Color.White; - this.cb_start_program.Location = new System.Drawing.Point(34, 21); - this.cb_start_program.Name = "cb_start_program"; - this.cb_start_program.Size = new System.Drawing.Size(222, 24); - this.cb_start_program.TabIndex = 28; - this.cb_start_program.Text = "Start the following program:"; - this.cb_start_program.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.cb_start_program.UseVisualStyleBackColor = true; - this.cb_start_program.CheckedChanged += new System.EventHandler(this.cb_start_program_CheckedChanged); + this.cb_disable_start_program.AutoSize = true; + this.cb_disable_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cb_disable_start_program.ForeColor = System.Drawing.Color.White; + this.cb_disable_start_program.Location = new System.Drawing.Point(78, 121); + this.cb_disable_start_program.Name = "cb_start_program"; + this.cb_disable_start_program.Size = new System.Drawing.Size(312, 24); + this.cb_disable_start_program.TabIndex = 28; + this.cb_disable_start_program.Text = "Temporarily disable starting this program"; + this.cb_disable_start_program.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.cb_disable_start_program.UseVisualStyleBackColor = true; + this.cb_disable_start_program.CheckedChanged += new System.EventHandler(this.cb_start_program_CheckedChanged); + // + // lbl_start_program + // + this.lbl_start_program.AutoSize = true; + this.lbl_start_program.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_start_program.Location = new System.Drawing.Point(75, 19); + this.lbl_start_program.Name = "lbl_start_program"; + this.lbl_start_program.Size = new System.Drawing.Size(140, 20); + this.lbl_start_program.TabIndex = 29; + this.lbl_start_program.Text = "Start this program:"; // // StartProgramControl // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.AutoSize = true; this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.cb_start_program); + this.Controls.Add(this.lbl_start_program); + this.Controls.Add(this.cb_disable_start_program); this.Controls.Add(this.btn_delete); this.Controls.Add(this.cb_dont_start_if_running); this.Controls.Add(this.txt_start_program); @@ -153,8 +167,9 @@ namespace DisplayMagician.UIForms this.Controls.Add(this.txt_start_program_args); this.Controls.Add(this.cb_start_program_pass_args); this.ForeColor = System.Drawing.Color.White; + this.Margin = new System.Windows.Forms.Padding(10); this.Name = "StartProgramControl"; - this.Size = new System.Drawing.Size(965, 136); + this.Size = new System.Drawing.Size(900, 150); this.ResumeLayout(false); this.PerformLayout(); @@ -169,6 +184,7 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.TextBox txt_start_program_args; private System.Windows.Forms.CheckBox cb_start_program_pass_args; private System.Windows.Forms.Button btn_delete; - private System.Windows.Forms.CheckBox cb_start_program; + private System.Windows.Forms.CheckBox cb_disable_start_program; + private System.Windows.Forms.Label lbl_start_program; } } diff --git a/DisplayMagician/UIForms/StartProgramControl.cs b/DisplayMagician/UIForms/StartProgramControl.cs index 2e3e94e..86184b8 100644 --- a/DisplayMagician/UIForms/StartProgramControl.cs +++ b/DisplayMagician/UIForms/StartProgramControl.cs @@ -48,7 +48,7 @@ namespace DisplayMagician.UIForms { // Now populate the controls with the start program data txt_start_program.Text = myStartProgram.Executable; - cb_start_program.Checked = myStartProgram.Enabled; + cb_disable_start_program.Checked = myStartProgram.Disabled; cb_start_program_pass_args.Checked = myStartProgram.ExecutableArgumentsRequired; txt_start_program_args.Text = myStartProgram.Arguments; cb_start_program_close.Checked = myStartProgram.CloseOnFinish; @@ -64,12 +64,13 @@ namespace DisplayMagician.UIForms private void cb_start_program_CheckedChanged(object sender, EventArgs e) { - // Disable the start program 1 fields - if (cb_start_program.Checked) + // Disable the start program fields + if (!cb_disable_start_program.Checked) { // Enable the Executable Arguments Text field txt_start_program.Visible = true; btn_start_program.Visible = true; + txt_start_program_args.Visible = true; cb_start_program_pass_args.Visible = true; cb_start_program_close.Visible = true; cb_dont_start_if_running.Visible = true; @@ -79,6 +80,7 @@ namespace DisplayMagician.UIForms // Disable the Executable Arguments Text field txt_start_program.Visible = false; btn_start_program.Visible = false; + txt_start_program_args.Visible = false; cb_start_program_pass_args.Visible = false; cb_start_program_close.Visible = false; cb_dont_start_if_running.Visible = false; @@ -123,18 +125,10 @@ namespace DisplayMagician.UIForms return textToReturn; } - private void lbl_start_program_Click(object sender, EventArgs e) - { - if (!cb_start_program.Checked) - cb_start_program.CheckState = CheckState.Checked; - else - cb_start_program.CheckState = CheckState.Unchecked; - } - - private void btn_delete_Click(object sender, EventArgs e) { - + ((ShortcutForm)this.Parent.Parent.Parent.Parent).RemoveStartProgram(this); + //this.Parent.Controls.Remove(this); } } diff --git a/DisplayMagician/UIForms/StartProgramControl.resx b/DisplayMagician/UIForms/StartProgramControl.resx index 1af7de1..61bc649 100644 --- a/DisplayMagician/UIForms/StartProgramControl.resx +++ b/DisplayMagician/UIForms/StartProgramControl.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + \ No newline at end of file