diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 769d55a..e559d7a 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -662,6 +662,7 @@ namespace photo_sorter this.Controls.Add(this.menuStrip1); this.Controls.Add(this.split_container_main); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(1024, 480); this.Name = "form_main"; diff --git a/Form1.cs b/Form1.cs index 6b0697a..2cf638d 100644 --- a/Form1.cs +++ b/Form1.cs @@ -273,52 +273,51 @@ namespace photo_sorter } } - protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + protected override bool ProcessCmdKey(ref Message msg, Keys key_data) { if (tsi_enableGlobalHotkeys.Checked) { - if (keyData == Keys.Enter) + switch (key_data) { - sort_image(); - return true; - } - if (keyData == Keys.PageUp) - { - if (global.filecount > 1) - prev_image(); - return true; - } - if (keyData == Keys.PageDown) - { - if (global.filecount > 1) - next_image(); - return true; - } - if (keyData == Keys.Home) - { - if (global.filecount > 1) - { - status_msg("Loading first image..."); - global.position = 0; - update_image(); - } - return true; - } - if (keyData == Keys.End) - { - if (global.filecount > 1) - { - status_msg("Loading final image..."); - global.position = global.filecount - 1; - update_image(); - } - return true; + case Keys.PageUp: + if (global.filecount > 1) + prev_image(); + return true; + case Keys.PageDown: + if (global.filecount > 1) + next_image(); + return true; + case Keys.Shift | Keys.Home: + if (global.filecount > 1) + { + status_msg("Loading first image..."); + global.position = 0; + update_image(); + } + return true; + case Keys.Shift | Keys.End: + if (global.filecount > 1) + { + status_msg("Loading final image..."); + global.position = global.filecount - 1; + update_image(); + } + return true; + case Keys.Enter: + sort_image(); + return true; + case Keys.Delete: + delete_image(); + return true; + case Keys.Shift | Keys.Enter: + delete_image(); + return true; } } - return base.ProcessCmdKey(ref msg, keyData); + return base.ProcessCmdKey(ref msg, key_data); } - public void next_image() + public void next_image() { status_msg("Loading next image..."); if (global.position < global.filecount - 1)