예제 #1
0
        private void GraphicsBoxMouseMove(object sender, HwndMouseEventArgs e)
        {
            Point position = e.Position;

            if (VM.GridSize > 1)
            {
                position = RoundToNearestGridPoint(e.Position);
            }

            if (isDragging)
            {
                VM.CurrentSelection = new xnaFrameworkAlias.Microsoft.Xna.Framework.Rectangle(
                    (int)(downPosition.X * windowsScalingOffset),
                    (int)(downPosition.Y * windowsScalingOffset),
                    (int)((-downPosition.X + position.X) * windowsScalingOffset),
                    (int)((-downPosition.Y + position.Y) * windowsScalingOffset)
                );
            }
        }
예제 #2
0
        private void GraphicsBoxMouseLeftDown(object sender, HwndMouseEventArgs e)
        {
            if (VM.GridSize > 1)
            {
                downPosition = RoundToNearestGridPoint(e.Position);
            }
            else
            {
                downPosition = e.Position;
            }

            isDragging = true;
        }
예제 #3
0
        private void ResetMouseState()
        {
            bool fireL = mouseState.LeftButton == MouseButtonState.Pressed;
            bool fireM = mouseState.MiddleButton == MouseButtonState.Pressed;
            bool fireR = mouseState.RightButton == MouseButtonState.Pressed;
            mouseState.LeftButton = MouseButtonState.Released;
            mouseState.MiddleButton = MouseButtonState.Released;
            mouseState.RightButton = MouseButtonState.Released;

            HwndMouseEventArgs args = new HwndMouseEventArgs(mouseState);
            if (fireL && HwndLButtonUp != null)
                HwndLButtonUp(this, args);
            if (fireM && HwndMButtonUp != null)
                HwndMButtonUp(this, args);
            if (fireR && HwndRButtonUp != null)
                HwndRButtonUp(this, args);

            mouseInWindow = false;
        }