diff --git a/ShareX/Forms/HotkeySettingsForm.Designer.cs b/ShareX/Forms/HotkeySettingsForm.Designer.cs index 03856dda9..205575c2e 100644 --- a/ShareX/Forms/HotkeySettingsForm.Designer.cs +++ b/ShareX/Forms/HotkeySettingsForm.Designer.cs @@ -35,6 +35,8 @@ private void InitializeComponent() this.btnEdit = new System.Windows.Forms.Button(); this.btnRemove = new System.Windows.Forms.Button(); this.btnAdd = new System.Windows.Forms.Button(); + this.btnMoveUp = new System.Windows.Forms.Button(); + this.btnMoveDown = new System.Windows.Forms.Button(); this.SuspendLayout(); // // btnDuplicate @@ -78,11 +80,27 @@ private void InitializeComponent() this.btnAdd.UseVisualStyleBackColor = true; this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); // + // btnMoveUp + // + resources.ApplyResources(this.btnMoveUp, "btnMoveUp"); + this.btnMoveUp.Name = "btnMoveUp"; + this.btnMoveUp.UseVisualStyleBackColor = true; + this.btnMoveUp.Click += new System.EventHandler(this.btnMoveUp_Click); + // + // btnMoveDown + // + resources.ApplyResources(this.btnMoveDown, "btnMoveDown"); + this.btnMoveDown.Name = "btnMoveDown"; + this.btnMoveDown.UseVisualStyleBackColor = true; + this.btnMoveDown.Click += new System.EventHandler(this.btnMoveDown_Click); + // // HotkeySettingsForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Window; + this.Controls.Add(this.btnMoveDown); + this.Controls.Add(this.btnMoveUp); this.Controls.Add(this.btnDuplicate); this.Controls.Add(this.btnReset); this.Controls.Add(this.flpHotkeys); @@ -103,6 +121,7 @@ private void InitializeComponent() private System.Windows.Forms.Button btnEdit; private System.Windows.Forms.Button btnRemove; private System.Windows.Forms.Button btnAdd; - + private System.Windows.Forms.Button btnMoveUp; + private System.Windows.Forms.Button btnMoveDown; } } \ No newline at end of file diff --git a/ShareX/Forms/HotkeySettingsForm.cs b/ShareX/Forms/HotkeySettingsForm.cs index c52fe1e5d..334bc42a1 100644 --- a/ShareX/Forms/HotkeySettingsForm.cs +++ b/ShareX/Forms/HotkeySettingsForm.cs @@ -24,12 +24,12 @@ You should have received a copy of the GNU General Public License #endregion License Information (GPL v3) using ShareX.HelpersLib; +using ShareX.Properties; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; -using ShareX.Properties; namespace ShareX { @@ -79,6 +79,7 @@ private void AddControls() private void UpdateButtons() { btnEdit.Enabled = btnRemove.Enabled = btnDuplicate.Enabled = Selected != null; + btnMoveUp.Enabled = btnMoveDown.Enabled = Selected != null && flpHotkeys.Controls.Count > 1; } private HotkeySelectionControl FindSelectionControl(HotkeySettings hotkeySetting) @@ -210,12 +211,58 @@ private void btnDuplicate_Click(object sender, EventArgs e) } } + private void btnMoveUp_Click(object sender, EventArgs e) + { + if (Selected != null && flpHotkeys.Controls.Count > 1) + { + int index = flpHotkeys.Controls.GetChildIndex(Selected); + + int newIndex; + + if (index == 0) + { + newIndex = flpHotkeys.Controls.Count - 1; + } + else + { + newIndex = index - 1; + } + + flpHotkeys.Controls.SetChildIndex(Selected, newIndex); + manager.Hotkeys.Move(index, newIndex); + } + } + + private void btnMoveDown_Click(object sender, EventArgs e) + { + if (Selected != null && flpHotkeys.Controls.Count > 1) + { + int index = flpHotkeys.Controls.GetChildIndex(Selected); + + int newIndex; + + if (index == flpHotkeys.Controls.Count - 1) + { + newIndex = 0; + } + else + { + newIndex = index + 1; + } + + flpHotkeys.Controls.SetChildIndex(Selected, newIndex); + manager.Hotkeys.Move(index, newIndex); + } + } + private void btnReset_Click(object sender, EventArgs e) { if (MessageBox.Show(Resources.HotkeySettingsForm_Reset_all_hotkeys_to_defaults_Confirmation, "ShareX", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { manager.ResetHotkeys(); AddControls(); + Selected = null; + UpdateButtons(); } } } diff --git a/ShareX/Forms/HotkeySettingsForm.resx b/ShareX/Forms/HotkeySettingsForm.resx index 49f884fb0..642ea1721 100644 --- a/ShareX/Forms/HotkeySettingsForm.resx +++ b/ShareX/Forms/HotkeySettingsForm.resx @@ -148,19 +148,16 @@ $this - 0 - - - Top, Right + 2 NoControl - 352, 8 + 392, 8 - 177, 23 + 208, 23 4 @@ -178,7 +175,7 @@ $this - 1 + 3 Top, Bottom, Left, Right @@ -193,7 +190,7 @@ 8, 35 - 520, 373 + 591, 419 5 @@ -211,7 +208,7 @@ $this - 2 + 4 False @@ -241,7 +238,7 @@ $this - 3 + 5 False @@ -271,7 +268,7 @@ $this - 4 + 6 NoControl @@ -298,7 +295,64 @@ $this - 5 + 7 + + + False + + + 328, 8 + + + 32, 23 + + + 6 + + + + + + btnMoveUp + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + False + + + NoControl + + + 360, 8 + + + 32, 23 + + + 7 + + + + + + btnMoveDown + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 True @@ -307,10 +361,10 @@ 6, 13 - 536, 415 + 607, 461 - 552, 200 + 623, 200 CenterScreen