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
This commit is contained in:
Kurt
2024-01-09 23:49:00 -08:00
parent b4aeb1ac7c
commit 39c4463437
2 changed files with 10 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);