private double WindowLeft() { var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0); var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0); var left = (dip2.X - ActualWidth) / 2 + dip1.X; return(left); }
private double WindowTop() { var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height); var top = (dip2.Y - QueryTextBox.ActualHeight) / 4 + dip1.Y; return(top); }
/// <summary> /// Retrieves the working area for the monitor that is closest to the /// specified point. /// </summary> public static Rectangle GetWorkingArea(Point pt) { return(Screen.FromPoint(pt).WorkingArea); }
/// <summary> /// Retrieves the bounds of the monitor that is closest to the specified /// point. /// </summary> public static Rectangle GetBounds(Point pt) { return(Screen.FromPoint(pt).Bounds); }
public static Screen FromControl(Control control) { var point = control.Parent != null?control.Parent.PointToScreen(control.Location) : control.Location; return(Screen.FromPoint(point)); }
public static Screen FromRectangle(Rectangle rect) { return(Screen.FromPoint(new Point(rect.Left, rect.Top))); }
public static Screen FromControl(Control control) { return(Screen.FromPoint(control.Location)); }