Esempio n. 1
0
        private void Resize(WIN32Rectangle newWindowRect, bool force = false)
        {
            if (!force)
            {
                TimeSpan t = DateTime.Now - lastResizeSent;
                if (t.TotalMilliseconds < 35)
                {
                    return;
                }
            }
            var props = new JObject
            {
                ["windowName"]   = dockingWindowName,
                ["width"]        = newWindowRect.Right - newWindowRect.Left,
                ["height"]       = newWindowRect.Bottom - newWindowRect.Top,
                ["top"]          = newWindowRect.Top,
                ["left"]         = newWindowRect.Left,
                ["bottom"]       = newWindowRect.Bottom,
                ["right"]        = newWindowRect.Right,
                ["scaled"]       = false,
                ["windowAction"] = "resize"
            };

            //bridge.SendRPCCommand("NativeWindow", props.ToString(), this.dockingChannel);
            lastResizeSent = DateTime.Now;
        }
Esempio n. 2
0
        //https://stackoverflow.com/questions/12376141/intercept-a-move-event-in-a-wpf-window-before-the-move-happens-on-the-screen
        private IntPtr HwndMessageHook(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool bHandled)
        {
            switch (msg)
            {
            case WM_SIZING:
                bHandled = true;

                if (!resizing)
                {
                    GetWindowRect(hWnd, out windowRect);
                    resizing = true;
                    Debug.WriteLine("resize start");
                }

                Debug.WriteLine("resizing: " + resizing.ToString());

                newWindowRect = (WIN32Rectangle)Marshal.PtrToStructure(lParam, typeof(WIN32Rectangle));
                Marshal.StructureToPtr(windowRect, lParam, true);

                resizeHandle = (int)wParam;

                Resize(newWindowRect);

                /*switch (resizeHandle)
                 * {
                 *  case WMSZ_LEFT:
                 *      WindowResizeEndLocation.X = newWindowRect.;
                 *      break;
                 *  case WMSZ_RIGHT:
                 *      WindowResizeEndBottomRight.X = mousePosition.X;
                 *      break;
                 *  case WMSZ_TOP:
                 *      WindowResizeEndLocation.Y = mousePosition.Y;
                 *      break;
                 *  case WMSZ_BOTTOM:
                 *      WindowResizeEndBottomRight.Y = mousePosition.Y;
                 *      break;
                 *  case WMSZ_TOPLEFT:
                 *      WindowResizeEndLocation.Y = mousePosition.Y;
                 *      WindowResizeEndLocation.X = mousePosition.X;
                 *      break;
                 *  case WMSZ_TOPRIGHT:
                 *      WindowResizeEndLocation.Y = mousePosition.Y;
                 *      WindowResizeEndBottomRight.X = mousePosition.X;
                 *      break;
                 *  case WMSZ_BOTTOMLEFT:
                 *      WindowResizeEndLocation.X = mousePosition.X;
                 *      WindowResizeEndBottomRight.Y = mousePosition.Y;
                 *      break;
                 *  case WMSZ_BOTTOMRIGHT:
                 *      WindowResizeEndBottomRight.Y = mousePosition.Y;
                 *      WindowResizeEndBottomRight.X = mousePosition.X;
                 *      break;
                 * }*/



                /*double scale = 1;
                 *  Application.Current.Dispatcher.Invoke(delegate //main thread
                 *  {
                 * scale = (rectangle.Right - rectangle.Left) / dockingWindow.Width;
                 * WindowResizeEndLocation = new Point(dockingWindow.Left, dockingWindow.Top);
                 * WindowResizeEndBottomRight = new Point(dockingWindow.Left + dockingWindow.Width, dockingWindow.Top + dockingWindow.Height);
                 * //Resize(WindowResizeEndLocation, WindowResizeEndBottomRight);
                 *  });*/

                break;

            case WM_LBUTTONDOWN:
                if (!resizing)
                {
                    dockingWindow.Activate();
                    bHandled = false;
                }
                break;

            case WM_EXITSIZEMOVE:
                if (resizing)
                {
                    Debug.WriteLine("End Resize");
                    bHandled = true;
                    resizing = false;
                    Resize(newWindowRect, true);
                    dynamic props = new ExpandoObject();
                    props.windowName   = dockingWindowName;
                    props.windowAction = "endMove";
                    bridge.RouterClient.Transmit("NativeWindow", JObject.FromObject(props));
                    lastResizeSent = DateTime.Now;
                    //Mouse.Capture(null);

                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        dockingWindow.Opacity = 1.0;
                    });
                }
                break;
            }
            return(IntPtr.Zero);
        }
Esempio n. 3
0
 static extern bool GetWindowRect(IntPtr hWnd, out WIN32Rectangle lpRect);