public override void HandleMessages(IntPtr hWnd, WindowMessageType msg, IntPtr wParam, IntPtr lParam)
        {
            base.HandleMessages(hWnd, msg, wParam, lParam);

            // Current mouse position
            int iMouseX = (short)((ulong)lParam & 0xffffU);
            int iMouseY = (short)((ulong)lParam >> 16);

            if (((msg == WindowMessageType.LeftButtonDown || msg == WindowMessageType.LeftButtonDoubleClick) &&
                 (m_nRotateModelButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                ((msg == WindowMessageType.MiddleButtonDown || msg == WindowMessageType.MiddleButtonDoubleClick) &&
                 (m_nRotateModelButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                ((msg == WindowMessageType.RightButtonDown || msg == WindowMessageType.RightButtonDoubleClick) &&
                 (m_nRotateModelButtonMask & SdkCameraMouseKeys.RightButton) != 0))
            {
                m_WorldArcBall.OnBegin(iMouseX, iMouseY);
            }

            if (((msg == WindowMessageType.LeftButtonDown || msg == WindowMessageType.LeftButtonDoubleClick) &&
                 (m_nRotateCameraButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                ((msg == WindowMessageType.MiddleButtonDown || msg == WindowMessageType.MiddleButtonDoubleClick) &&
                 (m_nRotateCameraButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                ((msg == WindowMessageType.RightButtonDown || msg == WindowMessageType.RightButtonDoubleClick) &&
                 (m_nRotateCameraButtonMask & SdkCameraMouseKeys.RightButton) != 0))
            {
                m_ViewArcBall.OnBegin(iMouseX, iMouseY);
            }

            if (msg == WindowMessageType.MouseMove)
            {
                m_WorldArcBall.OnMove(iMouseX, iMouseY);
                m_ViewArcBall.OnMove(iMouseX, iMouseY);
            }

            if ((msg == WindowMessageType.LeftButtonUp && (m_nRotateModelButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                (msg == WindowMessageType.MiddleButtonUp && (m_nRotateModelButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                (msg == WindowMessageType.RightButtonUp && (m_nRotateModelButtonMask & SdkCameraMouseKeys.RightButton) != 0))
            {
                m_WorldArcBall.OnEnd();
            }

            if ((msg == WindowMessageType.LeftButtonUp && (m_nRotateCameraButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                (msg == WindowMessageType.MiddleButtonUp && (m_nRotateCameraButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                (msg == WindowMessageType.RightButtonUp && (m_nRotateCameraButtonMask & SdkCameraMouseKeys.RightButton) != 0))
            {
                m_ViewArcBall.OnEnd();
            }

            if (msg == WindowMessageType.CaptureChanged)
            {
                if (lParam != hWnd)
                {
                    if (((m_nRotateModelButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                        ((m_nRotateModelButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                        ((m_nRotateModelButtonMask & SdkCameraMouseKeys.RightButton) != 0))
                    {
                        m_WorldArcBall.OnEnd();
                    }

                    if (((m_nRotateCameraButtonMask & SdkCameraMouseKeys.LeftButton) != 0) ||
                        ((m_nRotateCameraButtonMask & SdkCameraMouseKeys.MiddleButton) != 0) ||
                        ((m_nRotateCameraButtonMask & SdkCameraMouseKeys.RightButton) != 0))
                    {
                        m_ViewArcBall.OnEnd();
                    }
                }
            }

            if (msg == WindowMessageType.LeftButtonDown ||
                msg == WindowMessageType.LeftButtonDoubleClick ||
                msg == WindowMessageType.MiddleButtonDown ||
                msg == WindowMessageType.MiddleButtonDoubleClick ||
                msg == WindowMessageType.RightButtonDown ||
                msg == WindowMessageType.RightButtonDoubleClick ||
                msg == WindowMessageType.LeftButtonUp ||
                msg == WindowMessageType.MiddleButtonUp ||
                msg == WindowMessageType.RightButtonUp ||
                msg == WindowMessageType.MouseWheel ||
                msg == WindowMessageType.MouseMove)
            {
                m_bDragSinceLastUpdate = true;
            }
        }
示例#2
0
        public void HandleMessages(IntPtr hWnd, WindowMessageType msg, IntPtr wParam, IntPtr lParam)
        {
            // Current mouse position
            int iMouseX = (short)((ulong)lParam & 0xffffU);
            int iMouseY = (short)((ulong)lParam >> 16);

            switch (msg)
            {
            case WindowMessageType.LeftButtonDown:
            case WindowMessageType.MiddleButtonDown:
            case WindowMessageType.RightButtonDown:
            {
                if ((m_nRotateMask.HasFlag(SdkCameraMouseKeys.LeftButton) && msg == WindowMessageType.LeftButtonDown) ||
                    (m_nRotateMask.HasFlag(SdkCameraMouseKeys.MiddleButton) && msg == WindowMessageType.MiddleButtonDown) ||
                    (m_nRotateMask.HasFlag(SdkCameraMouseKeys.RightButton) && msg == WindowMessageType.RightButtonDown))
                {
                    m_ArcBall.OnBegin(iMouseX, iMouseY);
                    NativeMethods.SetCapture(hWnd);
                }

                break;
            }

            case WindowMessageType.MouseMove:
            {
                if (m_ArcBall.IsBeingDragged())
                {
                    m_ArcBall.OnMove(iMouseX, iMouseY);
                    UpdateLightDir();
                }

                break;
            }

            case WindowMessageType.LeftButtonUp:
            case WindowMessageType.MiddleButtonUp:
            case WindowMessageType.RightButtonUp:
            {
                if ((m_nRotateMask.HasFlag(SdkCameraMouseKeys.LeftButton) && msg == WindowMessageType.LeftButtonDown) ||
                    (m_nRotateMask.HasFlag(SdkCameraMouseKeys.MiddleButton) && msg == WindowMessageType.MiddleButtonDown) ||
                    (m_nRotateMask.HasFlag(SdkCameraMouseKeys.RightButton) && msg == WindowMessageType.RightButtonDown))
                {
                    m_ArcBall.OnEnd();
                    NativeMethods.ReleaseCapture();
                }

                UpdateLightDir();
                break;
            }

            case WindowMessageType.CaptureChanged:
            {
                if (lParam != hWnd)
                {
                    if (m_nRotateMask.HasFlag(SdkCameraMouseKeys.LeftButton) ||
                        m_nRotateMask.HasFlag(SdkCameraMouseKeys.MiddleButton) ||
                        m_nRotateMask.HasFlag(SdkCameraMouseKeys.RightButton))
                    {
                        m_ArcBall.OnEnd();
                        NativeMethods.ReleaseCapture();
                    }
                }

                break;
            }
            }
        }