using PKHeX.Core;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using static PKHeX.Core.MessageStrings;
using Exception = System.Exception;
namespace PKHeX.WinForms
{
public static class WinFormsUtil
{
internal static void TranslateInterface(Control form, string lang) => form.TranslateInterface(lang);
///
/// Centers the horizontally and vertically so that its center is the same as the 's center.
///
///
///
internal static void CenterToForm(this Control child, Control? parent)
{
if (parent == null)
return;
int x = parent.Location.X + ((parent.Width - child.Width) / 2);
int y = parent.Location.Y + ((parent.Height - child.Height) / 2);
child.Location = new Point(Math.Max(x, 0), Math.Max(y, 0));
}
internal static void CenterWithin(this Control child, Control parent)
{
child.Location = new Point((parent.Width - child.Width) / 2, child.Location.Y);
}
///
/// Horizontally centers the to the 's horizontal center.
///
internal static void HorizontallyCenter(this Control child, Control parent)
{
int x = ((parent.Width - child.Width) / 2);
child.Location = new Point(x, child.Location.Y);
}
public static T? FirstFormOfType() where T : Form => (T?)Application.OpenForms.Cast