示例#1
0
        private void OnMouseMoveEvent(Vector2 pixelPosition)
        {
            var previousMousePosition = CurrentMousePosition;

            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);
            // Discard this event if it has been triggered by the replacing the cursor to its capture initial position
            if (IsMousePositionLocked && Cursor.Position == capturedPosition)
            {
                return;
            }

            CurrentMouseDelta = CurrentMousePosition - previousMousePosition;

            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }

            if (IsMousePositionLocked)
            {
                Cursor.Position = capturedPosition;
            }
        }
        protected override void SetMousePosition(Vector2 normalizedPosition)
        {
            var newPos = UiControl.PointToScreen(
                new System.Drawing.Point((int)(UiControl.ClientRectangle.Width * normalizedPosition.X), (int)(UiControl.ClientRectangle.Height * normalizedPosition.Y)));

            Cursor.Position = newPos;
        }
示例#3
0
        private void OnMouseInputEvent(Vector2 pixelPosition, MouseButton button, InputEventType type, float value = 0)
        {
            // The mouse wheel event are still received even when the mouse cursor is out of the control boundaries. Discard the event in this case.
            if (type == InputEventType.Wheel && !uiControl.ClientRectangle.Contains(uiControl.PointToClient(Control.MousePosition)))
            {
                return;
            }

            // the mouse events series has been interrupted because out of the window.
            if (type == InputEventType.Up && !MouseButtonCurrentlyDown[(int)button])
            {
                return;
            }

            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);

            var mouseInputEvent = new MouseInputEvent {
                Type = type, MouseButton = button, Value = value
            };

            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            if (type != InputEventType.Wheel)
            {
                var buttonId = (int)button;
                MouseButtonCurrentlyDown[buttonId] = type == InputEventType.Down;
                HandlePointerEvents(buttonId, CurrentMousePosition, InputEventTypeToPointerState(type), PointerType.Mouse);
            }
        }
示例#4
0
        protected override void SetMousePosition(Vector2 normalizedPosition)
        {
            var newPos = UiControl.PointToScreen(
                new System.Windows.Point((int)(ClientWidth(UiControl) * normalizedPosition.X), (int)(ClientHeight(UiControl) * normalizedPosition.Y)));

            Cursor.Position = new System.Drawing.Point((int)newPos.X, (int)newPos.Y);
        }
        private void OnMouseMoveEvent(Vector2 pixelPosition)
        {
            var previousMousePosition = CurrentMousePosition;

            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);
            // Discard this event if it has been triggered by the replacing the cursor to its capture initial position
            if (IsMousePositionLocked && Cursor.Position == capturedPosition)
            {
                return;
            }

            CurrentMouseDelta += CurrentMousePosition - previousMousePosition;

            // trigger touch move events
            for (int buttonId = 0; buttonId < MouseButtonCurrentlyDown.Length; ++buttonId)
            {
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }

            // TODO: have a proper distinction between Touch and Mouse
            HandlePointerEvents(-1, CurrentMousePosition, PointerState.Move, PointerType.Mouse);

            if (IsMousePositionLocked)
            {
                Cursor.Position = capturedPosition;
            }
        }
示例#6
0
 void Mouse_Move(object sender, MouseMoveEventArgs e)
 {
     CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);
     
     // trigger touch move events
     foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
     {
         var buttonId = (int)button;
         if (MouseButtonCurrentlyDown[buttonId])
             HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
     }
 }
示例#7
0
        void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
        {
            var button = ConvertMouseButtonFromOpenTK(e.Button);
            var buttonId = (int)button;

            CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);
            var mouseInputEvent = new MouseInputEvent { Type = InputEventType.Down, MouseButton = button };
            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            MouseButtonCurrentlyDown[buttonId] = true;
            HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Down, PointerType.Mouse);
        }
        private void OnMouseMoveEvent(Vector2 pixelPosition)
        {
            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);

            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }
        }
示例#9
0
        void Mouse_Move(object sender, MouseMoveEventArgs e)
        {
            CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);

            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }
        }
示例#10
0
        void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
        {
            var button   = ConvertMouseButtonFromOpenTK(e.Button);
            var buttonId = (int)button;

            CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);
            var mouseInputEvent = new MouseInputEvent {
                Type = InputEventType.Down, MouseButton = button
            };

            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            MouseButtonCurrentlyDown[buttonId] = true;
            HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Down, PointerType.Mouse);
        }
示例#11
0
        void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
        {
            var button = ConvertMouseButtonFromOpenTK(e.Button);
            var buttonId = (int)button;

            // the mouse events series has been interrupted because out of the window.
            if (!MouseButtonCurrentlyDown[buttonId])
                return;
            
            CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);
            var mouseInputEvent = new MouseInputEvent { Type = InputEventType.Up, MouseButton = button };
            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            MouseButtonCurrentlyDown[buttonId] = false;
            HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Up, PointerType.Mouse);
        }
示例#12
0
        public override void Serialize(ref Strategy.BasicCameraController obj, ArchiveMode mode, SerializationStream stream)
        {
            // Serialize parent (for now we don't copy reference back because it shouldn't change)
            SiliconStudio.Xenko.Engine.SyncScript parentObj = obj;
            parentSerializer.Serialize(ref parentObj, mode, stream);
            obj = (Strategy.BasicCameraController)parentObj;

            SiliconStudio.Core.Mathematics.Vector3 keyboardMovementSpeed = mode == ArchiveMode.Serialize ? obj.KeyboardMovementSpeed : default(SiliconStudio.Core.Mathematics.Vector3);
            KeyboardMovementSpeedSerializer.Serialize(ref keyboardMovementSpeed, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.KeyboardMovementSpeed = keyboardMovementSpeed;
            }
            SiliconStudio.Core.Mathematics.Vector3 touchMovementSpeed = mode == ArchiveMode.Serialize ? obj.TouchMovementSpeed : default(SiliconStudio.Core.Mathematics.Vector3);
            KeyboardMovementSpeedSerializer.Serialize(ref touchMovementSpeed, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.TouchMovementSpeed = touchMovementSpeed;
            }
            System.Single speedFactor = mode == ArchiveMode.Serialize ? obj.SpeedFactor : default(System.Single);
            SpeedFactorSerializer.Serialize(ref speedFactor, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.SpeedFactor = speedFactor;
            }
            SiliconStudio.Core.Mathematics.Vector2 keyboardRotationSpeed = mode == ArchiveMode.Serialize ? obj.KeyboardRotationSpeed : default(SiliconStudio.Core.Mathematics.Vector2);
            KeyboardRotationSpeedSerializer.Serialize(ref keyboardRotationSpeed, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.KeyboardRotationSpeed = keyboardRotationSpeed;
            }
            SiliconStudio.Core.Mathematics.Vector2 mouseRotationSpeed = mode == ArchiveMode.Serialize ? obj.MouseRotationSpeed : default(SiliconStudio.Core.Mathematics.Vector2);
            KeyboardRotationSpeedSerializer.Serialize(ref mouseRotationSpeed, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.MouseRotationSpeed = mouseRotationSpeed;
            }
            SiliconStudio.Core.Mathematics.Vector2 touchRotationSpeed = mode == ArchiveMode.Serialize ? obj.TouchRotationSpeed : default(SiliconStudio.Core.Mathematics.Vector2);
            KeyboardRotationSpeedSerializer.Serialize(ref touchRotationSpeed, mode, stream);
            if (mode == ArchiveMode.Deserialize)
            {
                obj.TouchRotationSpeed = touchRotationSpeed;
            }
        }
示例#13
0
        void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
        {
            var button   = ConvertMouseButtonFromOpenTK(e.Button);
            var buttonId = (int)button;

            // the mouse events series has been interrupted because out of the window.
            if (!MouseButtonCurrentlyDown[buttonId])
            {
                return;
            }

            CurrentMousePosition = new Vector2(e.X / ControlWidth, e.Y / ControlHeight);
            var mouseInputEvent = new MouseInputEvent {
                Type = InputEventType.Up, MouseButton = button
            };

            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            MouseButtonCurrentlyDown[buttonId] = false;
            HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Up, PointerType.Mouse);
        }
 protected override void SetMousePosition(Vector2 normalizedPosition)
 {
     var newPos = uiControl.PointToScreen(
         new System.Drawing.Point((int)(uiControl.ClientRectangle.Width*normalizedPosition.X), (int)(uiControl.ClientRectangle.Height*normalizedPosition.Y)));
     Cursor.Position = newPos;
 }
        private void OnMouseMoveEvent(Vector2 pixelPosition)
        {
            var previousMousePosition = CurrentMousePosition;
            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);
            // Discard this event if it has been triggered by the replacing the cursor to its capture initial position
            if (IsMousePositionLocked && Cursor.Position == capturedPosition)
                return;

            CurrentMouseDelta += CurrentMousePosition - previousMousePosition;
            
            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
            }

            if (IsMousePositionLocked)
            {
                Cursor.Position = capturedPosition;
            }
        }
        private void OnMouseInputEvent(Vector2 pixelPosition, MouseButton button, InputEventType type, float value = 0)
        {
            // The mouse wheel event are still received even when the mouse cursor is out of the control boundaries. Discard the event in this case.
            if (type == InputEventType.Wheel && !uiControl.ClientRectangle.Contains(uiControl.PointToClient(Control.MousePosition)))
                return;

            // the mouse events series has been interrupted because out of the window.
            if (type == InputEventType.Up && !MouseButtonCurrentlyDown[(int)button])
                return;

            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);

            var mouseInputEvent = new MouseInputEvent { Type = type, MouseButton = button, Value = value};
            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            if (type != InputEventType.Wheel)
            {
                var buttonId = (int)button;
                MouseButtonCurrentlyDown[buttonId] = type == InputEventType.Down;
                HandlePointerEvents(buttonId, CurrentMousePosition, InputEventTypeToPointerState(type), PointerType.Mouse);
            }
        }