WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
FormExtensions.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Drawing;
6 
7 
8 namespace System.Windows.Forms
9 {
10  public static class FormExtensions
11  {
12  public static void CenterFormOnMouse(this Form Form)
13  {
14 
15  Point MousePos = Cursor.Position;
16  Rectangle R = Screen.FromPoint(MousePos).WorkingArea;
17 
18  int X = (Cursor.Position.X - Form.Width / 2);
19  int Y = (Cursor.Position.Y - Form.Height / 2);
20 
21 
22  X = X.Limit(R.Left+10, (R.Right - Form.Width-10).Limit(0,R.Right-10));
23  Y = Y.Limit(R.Top+10, (R.Bottom - Form.Height-10).Limit(0,R.Bottom-10));
24 
25 
26  Form.SetDesktopLocation(X, Y);
27  }
28 
29 
30  }
31 }