mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
20 lines
692 B
C#
20 lines
692 B
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace mRemoteNG.UI
|
|
{
|
|
public static class FormExtensions
|
|
{
|
|
public static void CenterOnTarget(this Form formToMove, Form formToCenterOn)
|
|
{
|
|
var targetFormCenterX = formToCenterOn.Location.X + formToCenterOn.Width/2;
|
|
var targetFormCenterY = formToCenterOn.Location.Y + formToCenterOn.Height/2;
|
|
|
|
var thisFormCenterX = formToMove.Location.X + formToMove.Width/2;
|
|
var thisFormCenterY = formToMove.Location.Y + formToMove.Height/2;
|
|
|
|
formToMove.Location = new Point(targetFormCenterX - thisFormCenterX, targetFormCenterY - thisFormCenterY);
|
|
}
|
|
}
|
|
} |