From 39c446343724ffddf13e2948cd5c0b91ee923ad8 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 9 Jan 2024 23:49:00 -0800 Subject: [PATCH] Handle two UI misbehaviors Hover tooltip thread was throwing exceptions (silently, cuz thread); program starts with empty box slots, hovering between them would never show -> can't hide a never-shown (no handle) form Fix quirk with stat ordering and visibility toggling --- PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs | 6 ++++++ PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index 2d17d1712..ff2b42e34 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -615,6 +615,12 @@ private void SetStatOrder(StatEditorStatOrder order) if (order == StatOrder) return; + // https://stackoverflow.com/a/30219698 + // WinForms hack to create the handles and avoid Z-order changing on visibility toggle. + // Otherwise, our stat ordering may be incorrect if we change it more than once. + foreach (Control ctrl in FLP_Stats.Controls) + _ = ctrl.Handle; + // In Generation 1, Special Defense and Special Attack are combined. // Additionally, Speed is shown before Special. const int baseIndex = 1; diff --git a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs index c8b2952fc..695ca2ef8 100644 --- a/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs +++ b/PKHeX.WinForms/Controls/Slots/SummaryPreviewer.cs @@ -68,6 +68,10 @@ public void Clear() var src = _source; Task.Run(async () => { + if (!Previewer.IsHandleCreated) + return; // not shown ever + + // Give a little bit of fade-out delay await Task.Delay(50, CancellationToken.None).ConfigureAwait(false); if (!src.IsCancellationRequested) Previewer.Invoke(Previewer.Hide);