mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-05 01:09:00 -05:00
Bring injector window to original position if already open
Show doesn't do anything if it's already hidden; we want to bring it to the front of the screen and then reposition it CenterParent.
This commit is contained in:
parent
0203eb4017
commit
a2ed2889a2
|
|
@ -93,6 +93,8 @@ private void B_Inject_Click(object sender, EventArgs e)
|
|||
if (exist != null)
|
||||
{
|
||||
exist.Show();
|
||||
exist.BringToFront();
|
||||
exist.CenterToForm(this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
|
@ -68,5 +69,17 @@ internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines
|
|||
public static T? FirstFormOfType<T>() where T : Form => (T?)Application.OpenForms.Cast<Form>().FirstOrDefault(form => form is T);
|
||||
|
||||
public static void RemoveDropCB(object sender, KeyEventArgs e) => ((ComboBox)sender).DroppedDown = false;
|
||||
|
||||
/// <summary>
|
||||
/// Centers the <see cref="child"/> horizontally and vertically so that its center is the same as the <see cref="parent"/>'s center.
|
||||
/// </summary>
|
||||
/// <param name="child"></param>
|
||||
/// <param name="parent"></param>
|
||||
internal static void CenterToForm(this Control child, Control parent)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user