UIMouseEventArgs GetTranslatedUIMouseEventArgs(System.Windows.Forms.MouseEventArgs e)
        {
            UIMouseButtons mouseButton = UIMouseButtons.Left;

            switch (e.Button)
            {
            case MouseButtons.Left:
                mouseButton = UIMouseButtons.Left;
                break;

            case MouseButtons.Right:
                mouseButton = UIMouseButtons.Right;
                break;

            case MouseButtons.Middle:
                mouseButton = UIMouseButtons.Middle;
                break;

            default:
                mouseButton = UIMouseButtons.Left;
                break;
            }

            UIMouseEventArgs mouseEventArgs = (_mouseEventStack.Count > 0) ? _mouseEventStack.Pop() : new UIMouseEventArgs();

            mouseEventArgs.SetEventInfo(
                e.X + _canvasViewport.ViewportX,
                e.Y + _canvasViewport.ViewportY,
                mouseButton,
                e.Clicks,
                e.Delta);
            return(mouseEventArgs);
        }
        void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button)
        {
            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            this.isMouseDown = true;
            this.isDragging = false;
            UIMouseEventArgs e = GetFreeMouseEvent();
            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            e.PreviousMouseDown = this.latestMouseDown;
            iTopBoxEventPortal.PortalMouseDown(e);
            this.currentMouseActiveElement = this.latestMouseDown = e.CurrentContextElement;
            this.localMouseDownX = e.X;
            this.localMouseDownY = e.Y;
            if (e.DraggingElement != null)
            {
                if (e.DraggingElement != e.CurrentContextElement)
                {
                    //change captured element
                    int globalX, globalY;
                    e.DraggingElement.GetGlobalLocation(out globalX, out globalY);
                    //find new capture pos
                    this.localMouseDownX = e.GlobalX - globalX;
                    this.localMouseDownY = e.GlobalY - globalY;
                }
                this.draggingElement = e.DraggingElement;
            }
            else
            {
                this.draggingElement = this.currentMouseActiveElement;
            }


            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
示例#3
0
 public void HostInvokeMouseMove(int xpos, int ypos, UIMouseButtons button)
 {
     if (_isMouseDown)
     {
         //dragging ...
     }
 }
示例#4
0
            public override void MouseEvent(IntPtr winPtr, int button, int action, int modifier)
            {
                switch (button)
                {
                case Glfw3.GLFW_MOUSE_BUTTON_LEFT:
                    _ui_button = UIMouseButtons.Left;
                    break;

                case Glfw3.GLFW_MOUSE_BUTTON_RIGHT:
                    _ui_button = UIMouseButtons.Right;
                    break;

                case Glfw3.GLFW_MOUSE_BUTTON_MIDDLE:
                    _ui_button = UIMouseButtons.Middle;
                    break;
                }
                if (action == Glfw3.GLFW_PRESS)
                {
                    _mouseArgs.SetMouseDownEventInfo(_mouseMoveX, _mouseMoveY, _ui_button, 1);
                    _myTopWindowBridge.HandleMouseDown(_mouseArgs);
                }
                else
                {
                    _mouseArgs.SetMouseUpEventInfo(_mouseMoveX, _mouseMoveY, _ui_button);
                    _myTopWindowBridge.HandleMouseUp(_mouseArgs);


                    _ui_button = UIMouseButtons.Left;//reset after mouseup
                }
                base.MouseEvent(winPtr, button, action, modifier);
            }
示例#5
0
        //------------------------------------------------------------------------
        UIMouseEventArgs GetTranslatedUIMouseEventArgs(MouseButton btn, int x, int y)
        {
            UIMouseButtons mouseButton = UIMouseButtons.Left;

            switch (btn)
            {
            case MouseButton.LeftButton:
                mouseButton = UIMouseButtons.Left;
                break;

            case MouseButton.RightButton:
                mouseButton = UIMouseButtons.Right;
                break;

            case MouseButton.MiddleButton:
                mouseButton = UIMouseButtons.Middle;
                break;

            default:
                mouseButton = UIMouseButtons.Left;
                break;
            }

            UIMouseEventArgs mouseEventArgs = (_mouseEventStack.Count > 0) ? _mouseEventStack.Pop() : new UIMouseEventArgs();

            mouseEventArgs.SetEventInfo(
                x + _canvasViewport.ViewportX,
                y + _canvasViewport.ViewportY,
                mouseButton,
                0,  //temp fix
                0); //temp fix
            return(mouseEventArgs);
        }
示例#6
0
 public void HostInvokeMouseDown(int xpos, int ypos, UIMouseButtons button)
 {
     this._mousedown_X = xpos;
     this._mousedown_Y = ypos;
     _visualLine.SetCharIndexFromPos(xpos, ypos);
     _isMouseDown = true;
     UpdateOutput();
 }
        public virtual void HostInvokeMouseDown(int xpos, int ypos, UIMouseButtons button)
        {
            _mousedown_X = xpos;
            _mousedown_Y = ypos;

            _isMouseDown = true;
            UpdateOutput();
        }
 void SetUIMouseEventArgsInfo(UIMouseEventArgs mouseEventArg, int x, int y, UIMouseButtons button, int delta)
 {
     mouseEventArg.SetEventInfo(
         x, y,
         (UIMouseButtons)button,
         0,
         delta);
 }
示例#9
0
        void ITopWindowEventRoot.RootMouseUp(int x, int y, UIMouseButtons button)
        {
            int xdiff = x - _prevLogicalMouseX;
            int ydiff = y - _prevLogicalMouseY;

            _prevLogicalMouseX = x;
            _prevLogicalMouseY = y;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);

            e.SetDiff(xdiff, ydiff);
            //----------------------------------
            e.IsDragging = _isDragging;
            _isMouseDown = _isDragging = false;
            DateTime snapMouseUpTime = DateTime.Now;
            TimeSpan timediff        = snapMouseUpTime - _lastTimeMouseUp;

            _lastTimeMouseUp = snapMouseUpTime;

            if (_isDragging)
            {
                if (_draggingElement != null)
                {
                    //send this to dragging element first
                    _draggingElement.GetGlobalLocation(out int d_GlobalX, out int d_globalY);
                    e.SetLocation(e.GlobalX - d_GlobalX, e.GlobalY - d_globalY);
                    e.CapturedMouseX = _localMouseDownX;
                    e.CapturedMouseY = _localMouseDownY;
                    var iportal = _draggingElement as IEventPortal;
                    if (iportal != null)
                    {
                        iportal.PortalMouseUp(e);
                        if (!e.IsCanceled)
                        {
                            _draggingElement.ListenMouseUp(e);
                        }
                    }
                    else
                    {
                        _draggingElement.ListenMouseUp(e);
                    }
                }
            }
            else
            {
                e.IsAlsoDoubleClick = timediff.Milliseconds < _dblClickSense;
                if (e.IsAlsoDoubleClick)
                {
                }
                _iTopBoxEventPortal.PortalMouseUp(e);
            }


            _localMouseDownX  = _localMouseDownY = 0;
            _mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
示例#10
0
 public void SetEventInfo(int x, int y, UIMouseButtons button, int clicks, int delta)
 {
     this.GlobalX = x;
     this.GlobalY = y;
     this.SetLocation(x, y);
     Button = button;
     Clicks = clicks;
     Delta  = delta;
 }
示例#11
0
        void ITopWindowEventRoot.RootMouseMove(int x, int y, UIMouseButtons button)
        {
            int xdiff = x - prevLogicalMouseX;
            int ydiff = y - prevLogicalMouseY;

            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            if (xdiff == 0 && ydiff == 0)
            {
                return;
            }

            //-------------------------------------------------------
            //when mousemove -> reset hover!
            hoverMonitoringTask.Reset();
            hoverMonitoringTask.Enabled = true;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            e.SetDiff(xdiff, ydiff);
            //-------------------------------------------------------
            e.IsDragging = this.isDragging = this.isMouseDown;
            if (this.isDragging)
            {
                if (draggingElement != null)
                {
                    //send this to dragging element first
                    int d_GlobalX, d_globalY;
                    draggingElement.GetGlobalLocation(out d_GlobalX, out d_globalY);
                    e.SetLocation(e.GlobalX - d_GlobalX, e.GlobalY - d_globalY);
                    e.CapturedMouseX = this.localMouseDownX;
                    e.CapturedMouseY = this.localMouseDownY;
                    var iportal = draggingElement as IEventPortal;
                    if (iportal != null)
                    {
                        iportal.PortalMouseMove(e);
                        if (!e.IsCanceled)
                        {
                            draggingElement.ListenMouseMove(e);
                        }
                    }
                    else
                    {
                        draggingElement.ListenMouseMove(e);
                    }
                }
            }
            else
            {
                iTopBoxEventPortal.PortalMouseMove(e);
                draggingElement = null;
            }
            //-------------------------------------------------------

            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
示例#12
0
 public static void SetEventInfo(this UIMouseEventArgs e, int x, int y, UIMouseButtons button, int clicks, int delta)
 {
     e.GlobalX  = x;
     e.GlobalY  = y;
     e.X        = x;
     e.Y        = y;
     e._buttons = button;
     e._click   = clicks;
     e._delta   = delta;
 }
示例#13
0
        void SetUIMouseEventArgsInfo(UIMouseEventArgs mouseEventArg, int x, int y, UIMouseButtons button, int delta)
        {
            mouseEventArg.SetEventInfo(
                x, y,
                button,
                0,
                delta);

            mouseEventArg.Alt   = _lastKeydownWithAlt;
            mouseEventArg.Shift = _lastKeydownWithShift;
            mouseEventArg.Ctrl  = _lastKeydownWithControl;
        }
 public void HandleMouseMove(int x, int y, UIMouseButtons b)
 {
     _topWinEventRoot.RootMouseMove(
         x + _canvasViewport.ViewportX,
         y + _canvasViewport.ViewportY,
         b);
     if (_currentCursorStyle != _topWinEventRoot.MouseCursorStyle)
     {
         ChangeCursorStyle(_currentCursorStyle = _topWinEventRoot.MouseCursorStyle);
     }
     PrepareRenderAndFlushAccumGraphics();
 }
 //static UIMouseButtons GetMouseButton(System.Windows.Forms.MouseButtons button)
 //{
 //    switch (button)
 //    {
 //        case MouseButtons.Left:
 //            return UIMouseButtons.Left;
 //        case MouseButtons.Right:
 //            return UIMouseButtons.Right;
 //        case MouseButtons.Middle:
 //            return UIMouseButtons.Middle;
 //        default:
 //            return UIMouseButtons.Left;
 //    }
 //}
 public void HandleMouseUp(int x, int y, UIMouseButtons b)
 {
     canvasViewport.FullMode = false;
     topWinEventRoot.RootMouseUp(
         x + this.canvasViewport.ViewportX,
         y + this.canvasViewport.ViewportY,
         b);
     if (currentCursorStyle != this.topWinEventRoot.MouseCursorStyle)
     {
         ChangeCursorStyle(this.currentCursorStyle = this.topWinEventRoot.MouseCursorStyle);
     }
     PrepareRenderAndFlushAccumGraphics();
 }
示例#16
0
        //
        void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button)
        {
            _prevLogicalMouseX = x;
            _prevLogicalMouseY = y;
            _isMouseDown       = true;
            _isDragging        = false;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            //
            e.Shift = _lastKeydownWithShift;
            e.Alt   = _lastKeydownWithAlt;
            e.Ctrl  = _lastKeydownWithControl;
            //
            e.PreviousMouseDown = _latestMouseDown;
            //
            _iTopBoxEventPortal.PortalMouseDown(e);
            //
            _currentMouseActiveElement = _latestMouseDown = e.CurrentContextElement;
            _localMouseDownX           = e.X;
            _localMouseDownY           = e.Y;
            if (e.DraggingElement != null)
            {
                if (e.DraggingElement != e.CurrentContextElement)
                {
                    //change captured element

                    e.DraggingElement.GetGlobalLocation(out int globalX, out int globalY);
                    //find new capture pos
                    _localMouseDownX = e.GlobalX - globalX;
                    _localMouseDownY = e.GlobalY - globalY;
                }
                _draggingElement = e.DraggingElement;
            }
            else
            {
                if (_currentMouseActiveElement != null &&
                    !_currentMouseActiveElement.BypassAllMouseEvents)
                {
                    _draggingElement = _currentMouseActiveElement;
                }
            }


            _mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
示例#17
0
        void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button)
        {
            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            this.isMouseDown       = true;
            this.isDragging        = false;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            //
            e.Shift = lastKeydownWithShift;
            e.Alt   = lastKeydownWithAlt;
            e.Ctrl  = lastKeydownWithControl;
            //
            e.PreviousMouseDown = this.latestMouseDown;
            //
            iTopBoxEventPortal.PortalMouseDown(e);
            //
            this.currentMouseActiveElement = this.latestMouseDown = e.CurrentContextElement;
            this.localMouseDownX           = e.X;
            this.localMouseDownY           = e.Y;
            if (e.DraggingElement != null)
            {
                if (e.DraggingElement != e.CurrentContextElement)
                {
                    //change captured element
                    int globalX, globalY;
                    e.DraggingElement.GetGlobalLocation(out globalX, out globalY);
                    //find new capture pos
                    this.localMouseDownX = e.GlobalX - globalX;
                    this.localMouseDownY = e.GlobalY - globalY;
                }
                this.draggingElement = e.DraggingElement;
            }
            else
            {
                this.draggingElement = this.currentMouseActiveElement;
            }


            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
        //------------------------------------------------------------------------
        public void HandleMouseDown(int x, int y, UIMouseButtons b)
        {
            _canvasViewport.FullMode = false;
            _topWinEventRoot.RootMouseDown(
                x + _canvasViewport.ViewportX,
                y + _canvasViewport.ViewportY,
                b);
            if (_currentCursorStyle != _topWinEventRoot.MouseCursorStyle)
            {
                ChangeCursorStyle(_currentCursorStyle = _topWinEventRoot.MouseCursorStyle);
            }

            PrepareRenderAndFlushAccumGraphics();
#if DEBUG
            RootGraphic visualroot = this.dbugTopwin.dbugVRoot;
            if (visualroot.dbug_RecordHitChain)
            {
                dbug_rootDocHitChainMsgs.Clear();
                visualroot.dbug_DumpCurrentHitChain(dbug_rootDocHitChainMsgs);
                dbug_InvokeHitChainMsg();
            }
#endif
        }
示例#19
0
 public void SetEventInfo(int x, int y, UIMouseButtons button, int clicks, int delta)
 {
     this.GlobalX = x;
     this.GlobalY = y;
     this.SetLocation(x, y);
     Button = button;
     Clicks = clicks;
     Delta = delta;
 }
示例#20
0
 public override void HostInvokeMouseDown(int xpos, int ypos, UIMouseButtons button)
 {
     _visualLine.SetCharIndexFromPos(xpos, ypos);
     base.HostInvokeMouseDown(xpos, ypos, button);
 }
示例#21
0
 public void HostInvokeMouseUp(int xpos, int ypos, UIMouseButtons button)
 {
     _isMouseDown = false;
 }
示例#22
0
 void SetUIMouseEventArgsInfo(UIMouseEventArgs mouseEventArg, int x, int y, UIMouseButtons button, int delta)
 {
     mouseEventArg.SetEventInfo(
         x, y,
        (UIMouseButtons)button,
         0,
         delta);
 }
示例#23
0
        void ITopWindowEventRoot.RootMouseMove(int x, int y, UIMouseButtons button)
        {
            int xdiff = x - prevLogicalMouseX;
            int ydiff = y - prevLogicalMouseY;
            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            if (xdiff == 0 && ydiff == 0)
            {
                return;
            }

            //-------------------------------------------------------
            //when mousemove -> reset hover!            
            hoverMonitoringTask.Reset();
            hoverMonitoringTask.Enabled = true;
            UIMouseEventArgs e = GetFreeMouseEvent();
            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            e.SetDiff(xdiff, ydiff);
            //-------------------------------------------------------
            e.IsDragging = this.isDragging = this.isMouseDown;
            if (this.isDragging)
            {
                if (draggingElement != null)
                {
                    //send this to dragging element first
                    int d_GlobalX, d_globalY;
                    draggingElement.GetGlobalLocation(out d_GlobalX, out d_globalY);
                    e.SetLocation(e.GlobalX - d_GlobalX, e.GlobalY - d_globalY);
                    e.CapturedMouseX = this.localMouseDownX;
                    e.CapturedMouseY = this.localMouseDownY;
                    var iportal = draggingElement as IEventPortal;
                    if (iportal != null)
                    {
                        iportal.PortalMouseMove(e);
                        if (!e.IsCanceled)
                        {
                            draggingElement.ListenMouseMove(e);
                        }
                    }
                    else
                    {
                        draggingElement.ListenMouseMove(e);
                    }
                }
            }
            else
            {
                iTopBoxEventPortal.PortalMouseMove(e);
                draggingElement = null;
            }
            //-------------------------------------------------------

            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
示例#24
0
        void ITopWindowEventRoot.RootMouseUp(int x, int y, UIMouseButtons button)
        {
            int xdiff = x - prevLogicalMouseX;
            int ydiff = y - prevLogicalMouseY;
            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            UIMouseEventArgs e = GetFreeMouseEvent();
            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            e.SetDiff(xdiff, ydiff);
            //----------------------------------
            e.IsDragging = isDragging;
            this.isMouseDown = this.isDragging = false;
            DateTime snapMouseUpTime = DateTime.Now;
            TimeSpan timediff = snapMouseUpTime - lastTimeMouseUp;

           
            if (this.isDragging)
            {
                if (draggingElement != null)
                {
                    //send this to dragging element first
                    int d_GlobalX, d_globalY;
                    draggingElement.GetGlobalLocation(out d_GlobalX, out d_globalY);
                    e.SetLocation(e.GlobalX - d_GlobalX, e.GlobalY - d_globalY);
                    e.CapturedMouseX = this.localMouseDownX;
                    e.CapturedMouseY = this.localMouseDownY;
                    var iportal = draggingElement as IEventPortal;
                    if (iportal != null)
                    {
                        iportal.PortalMouseUp(e);
                        if (!e.IsCanceled)
                        {
                            draggingElement.ListenMouseUp(e);
                        }
                    }
                    else
                    {
                        draggingElement.ListenMouseUp(e);
                    }
                }
            }
            else
            {
                e.IsAlsoDoubleClick = timediff.Milliseconds < dblClickSense;  
                iTopBoxEventPortal.PortalMouseUp(e);
            }
            this.lastTimeMouseUp = snapMouseUpTime;

            this.localMouseDownX = this.localMouseDownY = 0;
            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }