Added cancel button to shortcut library form

Added Cancel button to shortcut library form to allow people to cancel the monitoring from either a Windows Toast or from the shortcut library form itself. All works now!
This commit is contained in:
Terry MacDonald 2021-12-03 11:19:02 +13:00
parent e3d85f9e96
commit 4c6891ad2a
3 changed files with 39 additions and 2 deletions

View File

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

View File

@ -51,6 +51,7 @@
this.btn_help = new System.Windows.Forms.Button(); this.btn_help = new System.Windows.Forms.Button();
this.btn_donate = new System.Windows.Forms.Button(); this.btn_donate = new System.Windows.Forms.Button();
this.btn_copy = new System.Windows.Forms.Button(); this.btn_copy = new System.Windows.Forms.Button();
this.btn_cancel = new System.Windows.Forms.Button();
this.cms_shortcuts.SuspendLayout(); this.cms_shortcuts.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -323,6 +324,25 @@
this.btn_copy.UseVisualStyleBackColor = false; this.btn_copy.UseVisualStyleBackColor = false;
this.btn_copy.Click += new System.EventHandler(this.btn_copy_Click); this.btn_copy.Click += new System.EventHandler(this.btn_copy_Click);
// //
// btn_cancel
//
this.btn_cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btn_cancel.BackColor = System.Drawing.Color.Black;
this.btn_cancel.Enabled = false;
this.btn_cancel.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_cancel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_cancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_cancel.ForeColor = System.Drawing.Color.White;
this.btn_cancel.Location = new System.Drawing.Point(503, 488);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(120, 40);
this.btn_cancel.TabIndex = 37;
this.btn_cancel.Text = "&Cancel";
this.btn_cancel.UseVisualStyleBackColor = false;
this.btn_cancel.Visible = false;
this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
//
// ShortcutLibraryForm // ShortcutLibraryForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -330,6 +350,7 @@
this.BackColor = System.Drawing.Color.Black; this.BackColor = System.Drawing.Color.Black;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(1134, 716); this.ClientSize = new System.Drawing.Size(1134, 716);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_copy); this.Controls.Add(this.btn_copy);
this.Controls.Add(this.btn_donate); this.Controls.Add(this.btn_donate);
this.Controls.Add(this.btn_help); this.Controls.Add(this.btn_help);
@ -383,5 +404,6 @@
private System.Windows.Forms.Button btn_donate; private System.Windows.Forms.Button btn_donate;
private System.Windows.Forms.Button btn_copy; private System.Windows.Forms.Button btn_copy;
private System.Windows.Forms.ToolStripMenuItem tsmi_copy; private System.Windows.Forms.ToolStripMenuItem tsmi_copy;
private System.Windows.Forms.Button btn_cancel;
} }
} }

View File

@ -453,6 +453,11 @@ namespace DisplayMagician.UIForms
lbl_mask.BringToFront(); lbl_mask.BringToFront();
lbl_mask.Visible = true; lbl_mask.Visible = true;
// Show the cancel button
btn_cancel.Visible = true;
btn_cancel.Enabled = true;
btn_cancel.BringToFront();
ilv_saved_shortcuts.SuspendLayout(); ilv_saved_shortcuts.SuspendLayout();
ilv_saved_shortcuts.Refresh(); ilv_saved_shortcuts.Refresh();
@ -478,6 +483,11 @@ namespace DisplayMagician.UIForms
lbl_mask.Visible = false; lbl_mask.Visible = false;
lbl_mask.SendToBack(); lbl_mask.SendToBack();
// Hide the cancel button
btn_cancel.Visible = false;
btn_cancel.Enabled = false;
// Also refresh the right-click menu (if we have a main form loaded) // Also refresh the right-click menu (if we have a main form loaded)
if (Program.AppMainForm is Form) if (Program.AppMainForm is Form)
{ {
@ -588,5 +598,10 @@ namespace DisplayMagician.UIForms
} }
} }
private void btn_cancel_Click(object sender, EventArgs e)
{
// Inform the ShortcutRepository that it needs to cancel the running shortcut.
ShortcutRepository.CancelWait = true;
}
} }
} }