コード例 #1
0
 void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
 {
     if (!CrowInterface.ProcessMouseWheelChanged(otk_e.DeltaPrecise))
     {
         MouseWheelChanged.Raise(sender, otk_e);
     }
 }
コード例 #2
0
ファイル: GraphicObject.cs プロジェクト: slagusev/Crow
		public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
			GraphicObject p = Parent as GraphicObject;
			if (p != null)
				p.onMouseWheel(sender,e);

			MouseWheelChanged.Raise (this, e);
		}
コード例 #3
0
        public void UpdateMouseInput()
        {
            if (_scheduleMouseWheelFocus != null)
            {
                if (_scheduleMouseWheelFocus.AcceptsMouseWheelFocus)
                {
                    _previousMouseWheelFocus = FocusedMouseWheelWidget;
                    FocusedMouseWheelWidget  = _scheduleMouseWheelFocus;
                }

                _scheduleMouseWheelFocus = null;
            }

            if (MouseInfoGetter == null)
            {
                return;
            }

            var mouseInfo     = MouseInfoGetter();
            var mousePosition = mouseInfo.Position;

            if (SpriteBatchBeginParams.TransformMatrix != null)
            {
                // Apply transform
                var t = Vector2.Transform(
                    new Vector2(mousePosition.X, mousePosition.Y),
                    SpriteBatchBeginParams.InverseTransform);

                mousePosition = new Point((int)t.X, (int)t.Y);
            }

            MousePosition = mousePosition;

            HandleButton(mouseInfo.IsLeftButtonDown, _lastMouseInfo.IsLeftButtonDown, MouseButtons.Left);
            HandleButton(mouseInfo.IsMiddleButtonDown, _lastMouseInfo.IsMiddleButtonDown, MouseButtons.Middle);
            HandleButton(mouseInfo.IsRightButtonDown, _lastMouseInfo.IsRightButtonDown, MouseButtons.Right);
#if STRIDE
            var handleWheel = mouseInfo.Wheel != 0;
#else
            var handleWheel = mouseInfo.Wheel != _lastMouseInfo.Wheel;
#endif

            if (handleWheel)
            {
                var delta = mouseInfo.Wheel;
#if !STRIDE
                delta -= _lastMouseInfo.Wheel;
#endif
                MouseWheelChanged.Invoke(delta);

                if (FocusedMouseWheelWidget != null)
                {
                    FocusedMouseWheelWidget.OnMouseWheel(delta);
                }
            }

            _lastMouseInfo = mouseInfo;
        }
コード例 #4
0
ファイル: NUnitCrowWindow.cs プロジェクト: jpbruyere/crow.deb
 void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
 {
     if (_hoverWidget == null)
     {
         MouseWheelChanged.Raise(this, e);
         return;
     }
     _hoverWidget.onMouseWheel(this, e);
 }
コード例 #5
0
ファイル: CrowWindow.cs プロジェクト: slagusev/Crow
 protected virtual void GL_Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
 {
     if (focusedIdx >= 0)
     {
         if (ifaceControl [focusedIdx].ProcessMouseWheelChanged(otk_e.DeltaPrecise))
         {
             return;
         }
     }
     MouseWheelChanged.Raise(sender, otk_e);
 }
コード例 #6
0
ファイル: Widget.cs プロジェクト: communityus-branch/Myra
 protected void FireMouseWheelChanged(float delta)
 {
     MouseWheelChanged?.Invoke(this, new GenericEventArgs <float>(delta));
 }
コード例 #7
0
 public virtual void OnMouseWheel(float delta)
 {
     MouseWheelChanged.Invoke(this, delta);
 }
コード例 #8
0
        public void Start()
        {
            if (isRunning)
            {
                return;
            }

            Prepare();
            isRunning = true;

            IntPtr handleIn = GetStdHandle(STD_INPUT_HANDLE);

            thread = new Thread(
                () =>
            {
                while (true)
                {
                    uint numRead          = 0;
                    INPUT_RECORD[] record = new INPUT_RECORD[1];
                    record[0]             = new INPUT_RECORD();
                    ReadConsoleInput(handleIn, record, 1, ref numRead);
                    if (isRunning)
                    {
                        switch (record[0].EventType)
                        {
                        case INPUT_RECORD.MOUSE_EVENT:
                            var mouseEvent = record[0].MouseEvent;
                            if (mouseEvent.dwButtonState == dwButtonStates.FROM_LEFT_1ST_BUTTON_PRESSED)
                            {
                                MouseClicked?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            if (mouseEvent.dwEventFlags == dwEventFlags.DOUBLE_CLICK)
                            {
                                MouseDoubleClicked?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            else if (mouseEvent.dwEventFlags == dwEventFlags.MOUSE_MOVED)
                            {
                                MouseMoved?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            else if (mouseEvent.dwEventFlags == dwEventFlags.MOUSE_HWHEELED || mouseEvent.dwEventFlags == dwEventFlags.MOUSE_WHEELED)
                            {
                                MouseWheelChanged?.Invoke(this, CreateEventArgs(mouseEvent));
                            }

                            break;

                        case INPUT_RECORD.KEY_EVENT:
                            var keyEvent = record[0].KeyEvent;

                            if (keyEvent.bKeyDown)
                            {
                                KeyDown?.Invoke(this, CreateEventArgs(keyEvent));
                            }

                            break;

                        case INPUT_RECORD.WINDOW_BUFFER_SIZE_EVENT:
                            WindowBufferSizeEvent?.Invoke(record[0].WindowBufferSizeEvent);
                            break;
                        }
                    }
                    else
                    {
                        uint numWritten = 0;
                        WriteConsoleInput(handleIn, record, 1, ref numWritten);
                        return;
                    }
                }
            });

            thread.Start();
        }
コード例 #9
0
        public void UpdateInput()
        {
            if (MouseInfoGetter != null)
            {
                var mouseInfo     = MouseInfoGetter();
                var mousePosition = mouseInfo.Position;

                if (SpriteBatchBeginParams.TransformMatrix != null)
                {
                    // Apply transform
                    var t = Vector2.Transform(
                        new Vector2(mousePosition.X, mousePosition.Y),
                        SpriteBatchBeginParams.InverseTransform);

                    mousePosition = new Point((int)t.X, (int)t.Y);
                }

                MousePosition = mousePosition;

                HandleButton(mouseInfo.IsLeftButtonDown, _lastMouseInfo.IsLeftButtonDown, MouseButtons.Left);
                HandleButton(mouseInfo.IsMiddleButtonDown, _lastMouseInfo.IsMiddleButtonDown, MouseButtons.Middle);
                HandleButton(mouseInfo.IsRightButtonDown, _lastMouseInfo.IsRightButtonDown, MouseButtons.Right);
#if XENKO
                var handleWheel = mouseInfo.Wheel != 0;
#else
                var handleWheel = mouseInfo.Wheel != _lastMouseInfo.Wheel;
#endif

                if (handleWheel)
                {
                    var delta = mouseInfo.Wheel;
#if !XENKO
                    delta -= _lastMouseInfo.Wheel;
#endif
                    MouseWheelChanged.Invoke(this, delta);

                    if (FocusedMouseWheelWidget != null)
                    {
                        FocusedMouseWheelWidget.OnMouseWheel(delta);
                    }
                }

                _lastMouseInfo = mouseInfo;
            }

            if (DownKeysGetter != null)
            {
                _downKeys = DownKeysGetter();

                if (_downKeys != null && _lastDownKeys != null)
                {
                    var now = DateTime.Now;
                    foreach (var key in _downKeys)
                    {
                        if (!_lastDownKeys.Contains(key))
                        {
                            KeyDownHandler?.Invoke(key);

                            _lastKeyDown  = now;
                            _keyDownCount = 0;
                        }
                    }

                    foreach (var key in _lastDownKeys)
                    {
                        if (!_downKeys.Contains(key))
                        {
                            // Key had been released
                            KeyUp.Invoke(this, key);
                            if (_focusedKeyboardWidget != null && _focusedKeyboardWidget.Active)
                            {
                                _focusedKeyboardWidget.OnKeyUp(key);
                            }

                            _lastKeyDown  = null;
                            _keyDownCount = 0;
                        }
                        else if (_lastKeyDown != null &&
                                 ((_keyDownCount == 0 && (now - _lastKeyDown.Value).TotalMilliseconds > RepeatKeyDownStartInMs) ||
                                  (_keyDownCount > 0 && (now - _lastKeyDown.Value).TotalMilliseconds > RepeatKeyDownInternalInMs)))
                        {
                            KeyDownHandler?.Invoke(key);

                            _lastKeyDown = now;
                            ++_keyDownCount;
                        }
                    }
                }

                _lastDownKeys = _downKeys.ToArray();
            }

#if !XENKO
            try
            {
                UpdateTouch();
            }
            catch (Exception)
            {
            }
#endif
        }
コード例 #10
0
ファイル: MouseWheelBinding.cs プロジェクト: hgrandry/Mgx
 public MouseWheelBinding(MouseWheelChanged handler)
 {
     Handler = handler;
 }
コード例 #11
0
ファイル: Game.cs プロジェクト: deblob/GaLi
 private void onMouseWheelChanged(object sender, MouseWheelEventArgs e)
 {
     MouseWheelChanged?.Invoke(e);
 }