Esempio n. 1
0
        private static void MouseHook_MouseUpEvent(object sender, MouseEventArgs e)
        {
            if (filter.Spying)
            {
                filter.picSpy.Image = Properties.Resources.Spy.ToBitmap();
                shadow.Cursor       = Cursors.Default;
                filter.Spying       = false;

                IntPtr handle = WindowFromPoint(e.Location);
                WindowsInfoHelper.GetTopWindow(ref handle);
                filter.FillInfo(handle);
            }

            if (canDock)
            {
                hForegroundWindow = GetForegroundWindow();

                DwmGetWindowAttribute(hForegroundWindow, DWMWA_EXTENDED_FRAME_BOUNDS, out Rect rectFrame, Marshal.SizeOf(typeof(Rect)));
                GetWindowRect(hForegroundWindow, out Rect rectWindow);
                int shadowWidth  = ((rectWindow.Right - rectWindow.Left) - (rectFrame.Right - rectFrame.Left)) / 2;
                int shadowHeight = ((rectWindow.Bottom - rectWindow.Top) - (rectFrame.Bottom - rectFrame.Top));


                Task.Run(() => { Thread.Sleep(100); SetWindowPos(hForegroundWindow, IntPtr.Zero, rectDockArea.X - shadowWidth, rectDockArea.Y, rectDockArea.Width + shadowWidth * 2, rectDockArea.Height + shadowHeight, 0); });

                shadow.ClearShadow();
            }

            shallDock = false;
        }
Esempio n. 2
0
        private static void MouseHook_MouseDownEvent(object sender, MouseEventArgs e)
        {
            hCurrentWindow = WindowFromPoint(e.Location);
            WindowsInfoHelper.GetTopWindow(ref hCurrentWindow);
            GetWindowRect(hCurrentWindow, out rectCurrentWindow);

            WindowsInfoHelper.WindowInfo currentWindow = new WindowsInfoHelper.WindowInfo(hCurrentWindow);

            foreach (XmlElement xe in xeFilters)
            {
                string windowClass      = ((XmlElement)xe.SelectSingleNode("WindowClass")).GetAttribute("Text");
                string windowTitle      = ((XmlElement)xe.SelectSingleNode("WindowTitle")).GetAttribute("Text");
                string windowTitleLogic = ((XmlElement)xe.SelectSingleNode("WindowTitle")).GetAttribute("Logic");
                string filePath         = ((XmlElement)xe.SelectSingleNode("FilePath")).GetAttribute("Text");

                if (currentWindow.WindowClass == windowClass && string.Equals(currentWindow.FilePath, filePath, StringComparison.OrdinalIgnoreCase) && ((windowTitleLogic == "Include" && currentWindow.WindowTitle.Contains(windowTitle)) || (windowTitleLogic == "Equal" && currentWindow.WindowTitle == windowTitle)))
                {
                    shallDock = false;
                    return;
                }
            }

            if (hCurrentWindow == dock.Handle || hCurrentWindow == filter.Handle)
            {
                shallDock = false;
                return;
            }

            shallDock = true;
        }
Esempio n. 3
0
        private static void MouseHook_MouseMoveEvent(object sender, MouseEventArgs e)
        {
            if (shallSmartDock)
            {
                if ((e.X - SmartDockPoint.X) * (e.X - SmartDockPoint.X) + (e.Y - SmartDockPoint.Y) * (e.Y - SmartDockPoint.Y) > 512)
                {
                    shallSmartDock = false;
                }
            }
            else
            {
                rectWorkingArea = Screen.FromPoint(e.Location).WorkingArea;

                int x = e.X < rectWorkingArea.X ? rectWorkingArea.X : e.X;
                int y = e.Y < rectWorkingArea.Y ? rectWorkingArea.Y : e.Y;
                x = x > rectWorkingArea.Width + rectWorkingArea.X ? rectWorkingArea.Width + rectWorkingArea.X : x;
                y = y > rectWorkingArea.Height + rectWorkingArea.Y ? rectWorkingArea.Height + rectWorkingArea.Y : y;

                hForegroundWindow = GetForegroundWindow();
                WindowsInfoHelper.GetTopWindow(ref hForegroundWindow);
                GetWindowRect(hForegroundWindow, out Rect rectForegroundWindow);

                if (shallDock && ((hCurrentWindow == hForegroundWindow) && ((rectCurrentWindow.Left != rectForegroundWindow.Left || rectCurrentWindow.Top != rectForegroundWindow.Top) && (rectCurrentWindow.Bottom - rectCurrentWindow.Top == rectForegroundWindow.Bottom - rectForegroundWindow.Top && rectCurrentWindow.Right - rectCurrentWindow.Left == rectForegroundWindow.Right - rectForegroundWindow.Left))))
                {
                    foreach (XmlElement xe in xeDocks)
                    {
                        XmlElement xeTrigger = (XmlElement)xe.SelectSingleNode("Trigger");
                        XmlElement xeDock    = (XmlElement)xe.SelectSingleNode("Dock");

                        Rectangle rectTrigger = ConvertRealRect(Convert.ToInt32(xeTrigger.GetAttribute("Top")), Convert.ToInt32(xeTrigger.GetAttribute("Bottom")), Convert.ToInt32(xeTrigger.GetAttribute("Left")), Convert.ToInt32(xeTrigger.GetAttribute("Right")));

                        if (rectTrigger.Contains(x, y))
                        {
                            canDock      = true;
                            rectDockArea = ConvertRealRect((xeDock.GetAttribute("Top") != "-" ? Convert.ToInt32(xeDock.GetAttribute("Top")) : 0), (xeDock.GetAttribute("Bottom") != "-" ? Convert.ToInt32(xeDock.GetAttribute("Bottom")) : 100), (xeDock.GetAttribute("Left") != "-" ? Convert.ToInt32(xeDock.GetAttribute("Left")) : 0), (xeDock.GetAttribute("Right") != "-" ? Convert.ToInt32(xeDock.GetAttribute("Right")) : 100));

                            if (xeDock.GetAttribute("Top") == "-")
                            {
                                rectDockArea = new Rectangle(rectDockArea.X, rectForegroundWindow.Top, rectDockArea.Width, rectDockArea.Height - rectForegroundWindow.Top + rectWorkingArea.Y);
                            }

                            if (xeDock.GetAttribute("Bottom") == "-")
                            {
                                rectDockArea = new Rectangle(rectDockArea.X, rectDockArea.Y, rectDockArea.Width, rectForegroundWindow.Bottom - rectDockArea.Y);
                            }

                            if (xeDock.GetAttribute("Left") == "-")
                            {
                                rectDockArea = new Rectangle(rectForegroundWindow.Left, rectDockArea.Y, rectDockArea.Width - rectForegroundWindow.Left + rectWorkingArea.X, rectDockArea.Height);
                            }

                            if (xeDock.GetAttribute("Right") == "-")
                            {
                                rectDockArea = new Rectangle(rectDockArea.X, rectDockArea.Y, rectForegroundWindow.Right - rectDockArea.X, rectDockArea.Height);
                            }

                            shadow.FillShadow(rectDockArea);
                            return;
                        }
                    }
                }

                canDock = false;
                shadow.ClearShadow();
            }
        }