예제 #1
0
        private void OnMouseMove(MouseMoveEventArgs ev)
        {
            if (_window.IsMouseButtonDown(MouseButton.Right))
            {
                _graph.IsCameraAutoControlled = false;
                var delta = ev.Delta;
                delta.Y = -delta.Y;
                _graph.Camera.Target.Position += (delta / _window.ClientSize.Y) * _graph.Camera.Target.VerticalSize;
            }

            if (_window.IsMouseButtonDown(MouseButton.Left))
            {
                var p = ClientToView(ev.Position);
                var r = new Box2(p, p);
                r.Inflate(_mouseDownStartPt);
                _graph.DragRectangle = r;
            }

            _graph.ViewportWidth  = _window.ClientSize.X;
            _graph.ViewportHeight = _window.ClientSize.Y;
            _graph.MousePosition  = ClientToView(ev.Position);

            if (_graph.TryGetMouseover(ClientToView(ev.Position), out var targetPt))
            {
                _graph.MouseoverTarget = targetPt;
            }
            else
            {
                _graph.MouseoverTarget = default;
            }
        }