From 81f6988d3e2e99e0f9aae1046f2fb86ae56580e8 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 4 Sep 2018 15:01:14 -0700 Subject: [PATCH] Prevent sort/clear reverse on shortcut use Closes #2111 by preventing the user error --- PKHeX.Core/Editing/Saves/BoxManipulator.cs | 14 ++++++++++++++ PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Editing/Saves/BoxManipulator.cs b/PKHeX.Core/Editing/Saves/BoxManipulator.cs index 879577eb5..ccce64aaa 100644 --- a/PKHeX.Core/Editing/Saves/BoxManipulator.cs +++ b/PKHeX.Core/Editing/Saves/BoxManipulator.cs @@ -39,6 +39,20 @@ public bool Execute(IBoxManip manip, int box, bool allBoxes, bool reverse = fals return true; } + /// + /// Executes the provided with the provided parameters. + /// + /// Manipulation to perform on the box data. + /// Single box to modify; if is set, this param is ignored. + /// Indicates if all boxes are to be manipulated, or just one box. + /// Manipulation action should be inverted (criteria) or reversed (sort). + /// True if operation succeeded, false if no changes made. + public bool Execute(BoxManipType type, int box, bool allBoxes, bool reverse = false) + { + var manip = type.GetManip(); + return Execute(manip, box, allBoxes, reverse); + } + /// /// Sanity check for modifying the box data. /// diff --git a/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs b/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs index 5b81c5858..289069839 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs @@ -106,8 +106,8 @@ public void ToggleVisibility() Resources.wand, }; - public void Clear() => ((ToolStripMenuItem)Items[0]).DropDownItems[0].PerformClick(); - public void Sort() => ((ToolStripMenuItem)Items[1]).DropDownItems[0].PerformClick(); + public void Clear() => Manipulator.Execute(BoxManipType.DeleteAll, sav.SAV.CurrentBox, All); + public void Sort() => Manipulator.Execute(BoxManipType.SortSpecies, sav.SAV.CurrentBox, All); private static bool All => (ModifierKeys & Keys.Shift) != 0; private static bool Reverse => (ModifierKeys & Keys.Control) != 0;