Last Updated: 05 Jun 2018 13:41 by ADMIN
Dess | Tech Support Engineer, Principal
Created on: 08 May 2018 08:25
Category: Diagram, DiagramRibbonBar, DiagramToolBox
Type: Bug Report
FIX. RadDiagram - when using the PanToPosition method the canvas jumps to the initial position when strat moving
To reproduce: run the attached sample project and follow the steps in the gif file.
When you start dragging, (i.e. when MouseMove first fires) there is a large jump to the position of the image.
1 comment
Posted on: 05 Jun 2018 13:41
This is not a bug. In order to avoid canvas jump when using the PanToPosition method, you must include Current GraphPosition property which calculate radDiagram1.DiagramElement.Position, resulting in smooth canvas movement.

using Telerik.Windows.Diagrams.Core;

        private Point originalGraphPosition = new Point(double.NaN, double.NaN);
        private Point currentGraphPosition = new Point(double.NaN, double.NaN);
        private Point updatedGraphPosition = new Point(double.NaN, double.NaN);
        private Point currentPoint;
        private void radDiagram1_MouseMove(object sender, MouseEventArgs e)
            if (e.Button == System.Windows.Forms.MouseButtons.Left)// && mouseDown != Point.Empty)
                this.radDiagram1.DiagramElement.IsMouseCaptured = true;

                var currentPoint = e.Location;
                double newX = this.currentGraphPosition.X + currentPoint.X - this.currentPoint.X;
                double newY = this.currentGraphPosition.Y + currentPoint.Y - this.currentPoint.Y;
                this.updatedGraphPosition = new Point(newX, newY);


                this.currentPoint = currentPoint;
                this.currentGraphPosition = this.updatedGraphPosition;

        private void radDiagram1_MouseDown(object sender, MouseEventArgs e)
            this.originalGraphPosition = this.radDiagram1.DiagramElement.Position;
            this.currentGraphPosition = this.originalGraphPosition;
            this.currentPoint = e.Location;