public void Insert(DesktopWindow window, Int32Point dropPoint) { var activeScreen = ScreenHelper.GetScreen(dropPoint).WorkingArea.ToInt32Rect(); // For borders between screens, allow a greater margin var leftActivationWidth = 2; var rightActivationWidth = 2; if (ScreenHelper.AllScreens.Any(s => s.WorkingArea.X < activeScreen.X)) leftActivationWidth = 50; if (ScreenHelper.AllScreens.Any(s => s.WorkingArea.X > activeScreen.X)) rightActivationWidth = 50; TwoColumns layout; if (!screens.TryGetValue(activeScreen, out layout)) { layout = new TwoColumns(activeScreen); screens.Add(activeScreen, layout); } if (dropPoint.X < activeScreen.X + leftActivationWidth) { layout.LeftColumn.Insert(window, dropPoint.Y); } if (dropPoint.X > activeScreen.X + activeScreen.Width - rightActivationWidth) { layout.RightColumn.Insert(window, dropPoint.Y); } }
internal static DesktopWindow WindowFromPoint(Int32Point point) { var window = NativeMethods.RealChildWindowFromPoint(NativeMethods.GetDesktopWindow(), point); Int32Point cpoint= new Int32Point(); NativeMethods.ScreenToClient(window, ref cpoint); return DesktopWindow.GetDesktopWindow(window); }
public static extern bool GetCursorPos(out Int32Point lpPoint);
internal static bool IsInTitleBar(DesktopWindow window, Int32Point point) { var result = (int)NativeMethods.SendMessage(window.Handle, WM_NCHITTEST, 0, (point.Y << 16) + point.X); return result == HT_CAPTION; }
internal static extern IntPtr WindowFromPoint(Int32Point point);
internal static extern bool ScreenToClient(IntPtr hWnd, ref Int32Point lpPoint);
internal static extern IntPtr RealChildWindowFromPoint(IntPtr parent, Int32Point point);
public static bool Contains(this Int32Rect rect, Int32Point point) { return rect.X <= point.X && rect.Y <= point.Y && rect.X + rect.Width > point.X && rect.Y + rect.Height > point.Y; }
public static Screen GetScreen(Int32Point mousePosition) { return Screen.AllScreens.Single(s => s.Bounds.ToInt32Rect().Contains(mousePosition)); }