示例#1
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            if (null == ViewModel)
            {
                return;
            }

            if (!_IsWheeling)
            {
                History.NodeGraphHistory history = ViewModel.Model.History;
                history.BeginTransaction("Zooming");
                _ZoomAndPanStartMatrix = ZoomAndPan.Matrix;
            }

            _WheelStartTime = _CurrentTime;
            _IsWheeling     = true;

            double newScale = _ZoomAndPan.Scale;

            newScale += (0.0 > e.Delta) ? -0.05 : 0.05;
            newScale  = Math.Max(0.1, Math.Min(1.0, newScale));

            Point vsZoomCenter = e.GetPosition(this);
            Point zoomCenter   = _ZoomAndPan.MatrixInv.Transform(vsZoomCenter);

            _ZoomAndPan.Scale = newScale;

            Point vsNextZoomCenter = _ZoomAndPan.Matrix.Transform(zoomCenter);
            Point vsDelta          = new Point(vsZoomCenter.X - vsNextZoomCenter.X, vsZoomCenter.Y - vsNextZoomCenter.Y);

            _ZoomAndPan.StartX -= vsDelta.X;
            _ZoomAndPan.StartY -= vsDelta.Y;
        }
示例#2
0
        protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseRightButtonDown(e);

            if (null == ViewModel)
            {
                return;
            }

            Keyboard.Focus(this);

            _RightButtonDownPos = e.GetPosition(this);

            _ZoomAndPanStartMatrix = ZoomAndPan.Matrix;

            if (!NodeGraphManager.IsDragging)
            {
                _IsDraggingCanvas = true;

                Mouse.Capture(this, CaptureMode.SubTree);

                History.NodeGraphHistory history = ViewModel.Model.History;
                history.BeginTransaction("Panning");
            }
        }