Example #1
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)
            {
                //VS Does not behave like this, so commented out
                case Win32Helper.WmActivate:
                    if (((int) wParam & 0xFFFF) == Win32Helper.WaInactive)
                    {
                        //if (lParam == this.GetParentWindowHandle())
                        //{
                        //	Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                        //	handled = true;
                        //}
                    }
                    break;
                case Win32Helper.WmExitsizemove:
                    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.WmMoving:
                {
                    UpdateDragPosition();
                }
                    break;
                case Win32Helper.WmLbuttonup: //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.WmSyscommand:
                    IntPtr wMaximize = new IntPtr(Win32Helper.ScMaximize);
                    IntPtr wRestore = new IntPtr(Win32Helper.ScRestore);
                    if (wParam == wMaximize || wParam == wRestore)
                    {
                        UpdateMaximizedState(wParam == wMaximize);
                    }
                    break;
            }

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

            switch (msg)
            {
            //VS Does not behave like this, so commented out
            case Win32Helper.WmActivate:
                if (((int)wParam & 0xFFFF) == Win32Helper.WaInactive)
                {
                    //if (lParam == this.GetParentWindowHandle())
                    //{
                    //	Win32Helper.SetActiveWindow(_hwndSrc.Handle);
                    //	handled = true;
                    //}
                }
                break;

            case Win32Helper.WmExitsizemove:
                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.WmMoving:
            {
                UpdateDragPosition();
            }
            break;

            case Win32Helper.WmLbuttonup:                     //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.WmSyscommand:
                IntPtr wMaximize = new IntPtr(Win32Helper.ScMaximize);
                IntPtr wRestore  = new IntPtr(Win32Helper.ScRestore);
                if (wParam == wMaximize || wParam == wRestore)
                {
                    UpdateMaximizedState(wParam == wMaximize);
                }
                break;
            }


            return(IntPtr.Zero);
        }