Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static extern bool GetCursorPos(out Int32Point lpPoint);
Beispiel #4
0
 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;
 }
Beispiel #5
0
 internal static extern IntPtr WindowFromPoint(Int32Point point);
Beispiel #6
0
 internal static extern bool ScreenToClient(IntPtr hWnd, ref Int32Point lpPoint);
Beispiel #7
0
 internal static extern IntPtr RealChildWindowFromPoint(IntPtr parent, Int32Point point);
Beispiel #8
0
 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;
 }
Beispiel #9
0
 public static Screen GetScreen(Int32Point mousePosition)
 {
     return Screen.AllScreens.Single(s => s.Bounds.ToInt32Rect().Contains(mousePosition));
 }