Fix Stat Editor randomize buttons centering

Hiding and Showing doesn't trigger an update to the FlowLayoutPanel's width; force a layout to happen so the size updates prior to re-centering controls. Only move if it is a different X coordinate (perf?)
This commit is contained in:
Kurt 2023-07-08 19:29:46 -07:00
parent b5f0296fe6
commit 04e7baaeee
2 changed files with 4 additions and 1 deletions

View File

@ -638,6 +638,8 @@ public void ToggleInterface(PKM pk, int gen)
foreach (var mtb in MT_EVs)
mtb.Visible = !showAV;
FLP_PKMEditors.PerformLayout();
var showGV = pk is IGanbaru;
Label_GVs.Visible = showGV;
foreach (var mtb in MT_GVs)

View File

@ -36,7 +36,8 @@ internal static void CenterToForm(this Control child, Control? parent)
internal static void HorizontallyCenter(this Control child, Control parent)
{
int midpoint = (parent.Width - child.Width) / 2;
child.SetBounds(midpoint, 0, 0, 0, BoundsSpecified.X);
if (child.Location.X != midpoint)
child.SetBounds(midpoint, 0, 0, 0, BoundsSpecified.X);
}
public static T? FirstFormOfType<T>() where T : Form => (T?)Application.OpenForms.Cast<Form>().FirstOrDefault(form => form is T);