示例#1
0
        private void UpdateDragPosition()
        {
            if (this._dragService == null)
            {
                this._dragService = new DragService(this);
                this.SetIsDragging(true);
            }
            Point deviceDPI = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());

            this._dragService.UpdateMouseLocation(deviceDPI);
        }
示例#2
0
        protected virtual IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            bool flag;

            handled = false;
            if (msg <= 274)
            {
                if (msg != 6)
                {
                    if (msg == 274)
                    {
                        int num = (int)wParam & 65520;
                        if (num == 61488 || num == 61728)
                        {
                            this.UpdateMaximizedState(num == 61488);
                        }
                    }
                }
                else if (((int)wParam & 65535) == 0 && lParam == this.GetParentWindowHandle())
                {
                    Win32Helper.SetActiveWindow(this._hwndSrc.Handle);
                    handled = true;
                }
            }
            else if (msg == 514)
            {
                if (this._dragService != null && Mouse.LeftButton == MouseButtonState.Released)
                {
                    this._dragService.Abort();
                    this._dragService = null;
                    this.SetIsDragging(false);
                }
            }
            else if (msg == 534)
            {
                this.UpdateDragPosition();
            }
            else if (msg == 562)
            {
                this.UpdatePositionAndSizeOfPanes();
                if (this._dragService != null)
                {
                    Point deviceDPI = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
                    this._dragService.Drop(deviceDPI, out flag);
                    this._dragService = null;
                    this.SetIsDragging(false);
                    if (flag)
                    {
                        this.InternalClose();
                    }
                }
            }
            return(IntPtr.Zero);
        }
示例#3
0
        private void UpdateDragPosition()
        {
            if (_dragService == null)
            {
                _dragService = new DragService(this);
                SetIsDragging(true);
            }

            var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());

            _dragService.UpdateMouseLocation(mousePosition);
        }
        private void UpdateDragPosition()
        {
            if (_dragService == null) {
                _dragService = new DragService(this);
                SetIsDragging(true);
            }

            var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
            _dragService.UpdateMouseLocation(mousePosition);
        }
        protected virtual IntPtr FilterMessage(
            IntPtr hwnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled
            )
        {
            handled = false;

            switch (msg) {
                case Win32Helper.WM_ACTIVATE:
                    if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE) {
                        if (lParam == this.GetParentWindowHandle()) {
                            Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                            handled = true;
                        }
                    }
                    break;
                case Win32Helper.WM_EXITSIZEMOVE:
                    UpdatePositionAndSizeOfPanes();

                    if (_dragService != null) {
                        bool dropFlag;
                        var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
                        _dragService.Drop(mousePosition, out dropFlag);
                        _dragService = null;
                        SetIsDragging(false);

                        if (dropFlag)
                            InternalClose();
                    }

                    break;
                case Win32Helper.WM_MOVING: {
                        UpdateDragPosition();
                    }
                    break;
                case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu)
                    if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released) {
                        _dragService.Abort();
                        _dragService = null;
                        SetIsDragging(false);
                    }
                    break;
                case Win32Helper.WM_SYSCOMMAND:
                    IntPtr wMaximize = new IntPtr(Win32Helper.SC_MAXIMIZE);
                    IntPtr wRestore = new IntPtr(Win32Helper.SC_RESTORE);
                    if (wParam == wMaximize || wParam == wRestore) {
                        UpdateMaximizedState(wParam == wMaximize);
                    }
                    break;
            }

            return IntPtr.Zero;
        }
示例#6
0
        protected virtual IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            handled = false;

            switch (msg)
            {
            case Win32Helper.WM_ACTIVATE:
                if ((( int )wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
                {
                    if (lParam == this.GetParentWindowHandle())
                    {
                        Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                        handled = true;
                    }
                }
                break;

            case Win32Helper.WM_EXITSIZEMOVE:
                UpdatePositionAndSizeOfPanes();

                if (_dragService != null)
                {
                    bool dropFlag;
                    var  mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
                    _dragService.Drop(mousePosition, out dropFlag);
                    _dragService = null;
                    SetIsDragging(false);

                    if (dropFlag)
                    {
                        InternalClose();
                    }
                }

                break;

            case Win32Helper.WM_MOVING:
            {
                UpdateDragPosition();
                if (this.IsMaximized)
                {
                    this.UpdateMaximizedState(false);
                }
            }
            break;

            case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu)
                if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released)
                {
                    _dragService.Abort();
                    _dragService = null;
                    SetIsDragging(false);
                }
                break;

            case Win32Helper.WM_SYSCOMMAND:
                int command = ( int )wParam & 0xFFF0;
                if (command == Win32Helper.SC_MAXIMIZE || command == Win32Helper.SC_RESTORE)
                {
                    UpdateMaximizedState(command == Win32Helper.SC_MAXIMIZE);
                }
                break;
            }



            return(IntPtr.Zero);
        }
示例#7
0
        protected virtual IntPtr FilterMessage(
            IntPtr hwnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled
            )
        {
            handled = false;

            switch (msg)
            {
            case Win32Helper.WM_ACTIVATE:
                if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
                {
                    if (lParam == this.GetParentWindowHandle())
                    {
                        Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                        handled = true;
                    }
                }
                break;

            case Win32Helper.WM_EXITSIZEMOVE:
                UpdatePositionAndSizeOfPanes();

                if (_dragService != null)
                {
                    bool dropFlag;
                    var  mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
                    var  manager       = _model.Root.Manager;
                    _dragService.Drop(mousePosition, out dropFlag);
                    _dragService = null;
                    SetIsDragging(false);

                    if (dropFlag)
                    {
                        InternalClose();
                        if (manager != null)
                        {
                            manager.OnLayoutConfigurationChanged();
                        }
                    }
                    else
                    {
                        var floatingWindow = Model as LayoutDocumentFloatingWindow;
                        if (floatingWindow != null)
                        {
                            floatingWindow.RootDocument.Dock();
                        }
                    }
                }

                break;

            case Win32Helper.WM_MOVING:
            {
                UpdateDragPosition();
            }
            break;

            case Win32Helper.WM_LBUTTONUP:                     //set as handled right button click on title area (after showing context menu)
                if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released)
                {
                    _dragService.Abort();
                    _dragService = null;
                    SetIsDragging(false);
                }
                break;

            case Win32Helper.WM_SYSCOMMAND:
                IntPtr wMaximize = new IntPtr(Win32Helper.SC_MAXIMIZE);
                IntPtr wRestore  = new IntPtr(Win32Helper.SC_RESTORE);
                if (wParam == wMaximize || wParam == wRestore)
                {
                    UpdateMaximizedState(wParam == wMaximize);
                }
                break;
            }



            return(IntPtr.Zero);
        }
        protected virtual IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            handled = false;

            switch (msg)
            {
            case Win32Helper.NCCALCSIZE:
                if (wParam != IntPtr.Zero)
                {
                    handled = true;
                    var client = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT));
                    client.Bottom -= 1;
                    Marshal.StructureToPtr(client, lParam, false);
                }
                break;

            //case Win32Helper.WM_NCHITTEST:
            //  {
            //    handled = true;
            //    //var htLocation = DefWindowProc( hwnd, msg, wParam, lParam ).ToInt32();
            //    //switch( htLocation )
            //    //{
            //    //  case (int)HitTestResult.HTBOTTOM:
            //    //  case (int)HitTestResult.HTBOTTOMLEFT:
            //    //  case (int)HitTestResult.HTBOTTOMRIGHT:
            //    //  case (int)HitTestResult.HTLEFT:
            //    //  case (int)HitTestResult.HTRIGHT:
            //    //  case (int)HitTestResult.HTTOP:
            //    //  case (int)HitTestResult.HTTOPLEFT:
            //    //  case (int)HitTestResult.HTTOPRIGHT:
            //    //    htLocation = (int)HitTestResult.HTBORDER;
            //  }
            //  break;

            case Win32Helper.WM_ACTIVATE:
                if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
                {
                    if (lParam == this.GetParentWindowHandle())
                    {
                        Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                        handled = true;
                    }
                }
                break;

            case Win32Helper.WM_EXITSIZEMOVE:
                UpdatePositionAndSizeOfPanes();

                if (_dragService != null)
                {
                    bool dropFlag;
                    var  mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
                    _dragService.Drop(mousePosition, out dropFlag);
                    _dragService = null;
                    SetIsDragging(false);

                    if (dropFlag)
                    {
                        InternalClose();
                    }
                }

                break;

            case Win32Helper.WM_MOVING:
            {
                UpdateDragPosition();
                if (this.IsMaximized)
                {
                    this.UpdateMaximizedState(false);
                }
            }
            break;

            case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu)
                if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released)
                {
                    _dragService.Abort();
                    _dragService = null;
                    SetIsDragging(false);
                }
                break;

            case Win32Helper.WM_SYSCOMMAND:
                int command = (int)wParam & 0xFFF0;
                if (command == Win32Helper.SC_MAXIMIZE || command == Win32Helper.SC_RESTORE)
                {
                    UpdateMaximizedState(command == Win32Helper.SC_MAXIMIZE);
                }
                break;
            }



            return(IntPtr.Zero);
        }
示例#9
0
        public void UpdateMouseLocation(Point dragPosition)
        {
            Func <IDropTarget, bool> func2             = null;
            ILayoutElement           model             = this._floatingWindow.Model;
            IOverlayWindowHost       overlayWindowHost = this._overlayWindowHosts.FirstOrDefault <IOverlayWindowHost>((IOverlayWindowHost oh) => oh.HitTest(dragPosition));

            if (this._currentHost != null || this._currentHost != overlayWindowHost)
            {
                if (this._currentHost != null && !this._currentHost.HitTest(dragPosition) || this._currentHost != overlayWindowHost)
                {
                    if (this._currentDropTarget != null)
                    {
                        this._currentWindow.DragLeave(this._currentDropTarget);
                    }
                    this._currentDropTarget = null;
                    this._currentWindowAreas.ForEach((IDropArea a) => this._currentWindow.DragLeave(a));
                    this._currentWindowAreas.Clear();
                    if (this._currentWindow != null)
                    {
                        this._currentWindow.DragLeave(this._floatingWindow);
                    }
                    if (this._currentHost != null)
                    {
                        this._currentHost.HideOverlayWindow();
                    }
                    this._currentHost = null;
                }
                if (this._currentHost != overlayWindowHost)
                {
                    this._currentHost   = overlayWindowHost;
                    this._currentWindow = this._currentHost.ShowOverlayWindow(this._floatingWindow);
                    this._currentWindow.DragEnter(this._floatingWindow);
                }
            }
            if (this._currentHost == null)
            {
                return;
            }
            if (this._currentDropTarget != null && !this._currentDropTarget.HitTest(dragPosition))
            {
                this._currentWindow.DragLeave(this._currentDropTarget);
                this._currentDropTarget = null;
            }
            List <IDropArea> dropAreas = new List <IDropArea>();

            this._currentWindowAreas.ForEach((IDropArea a) => {
                if (!a.DetectionRect.Contains(dragPosition))
                {
                    this._currentWindow.DragLeave(a);
                    dropAreas.Add(a);
                }
            });
            dropAreas.ForEach((IDropArea a) => this._currentWindowAreas.Remove(a));
            List <IDropArea> list = this._currentHost.GetDropAreas(this._floatingWindow).Where <IDropArea>((IDropArea cw) => {
                if (this._currentWindowAreas.Contains(cw))
                {
                    return(false);
                }
                return(cw.DetectionRect.Contains(dragPosition));
            }).ToList <IDropArea>();

            this._currentWindowAreas.AddRange(list);
            list.ForEach((IDropArea a) => this._currentWindow.DragEnter(a));
            if (this._currentDropTarget == null)
            {
                this._currentWindowAreas.ForEach((IDropArea wa) => {
                    if (this._currentDropTarget != null)
                    {
                        return;
                    }
                    DragService u003cu003e4_this           = this;
                    IEnumerable <IDropTarget> targets      = this._currentWindow.GetTargets();
                    Func <IDropTarget, bool> u003cu003e9_7 = func2;
                    if (u003cu003e9_7 == null)
                    {
                        Func <IDropTarget, bool> func  = (IDropTarget dt) => dt.HitTest(dragPosition);
                        Func <IDropTarget, bool> func1 = func;
                        func2         = func;
                        u003cu003e9_7 = func1;
                    }
                    u003cu003e4_this._currentDropTarget = targets.FirstOrDefault <IDropTarget>(u003cu003e9_7);
                    if (this._currentDropTarget == null)
                    {
                        return;
                    }
                    this._currentWindow.DragEnter(this._currentDropTarget);
                });
            }
        }