Пример #1
0
        private void pictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            Point screenPoint = Cursor.Position;
            Point graphPoint  = pictureBox.PointToClient(screenPoint);

            if ((graphPoint.X < 0) || (graphPoint.X > pictureBox.Width))
            {
                _isClicked     = false;
                Cursor.Current = Cursors.Arrow;
                return;
            }

            if ((graphPoint.Y < 0) || (graphPoint.Y > pictureBox.Height))
            {
                _isClicked     = false;
                Cursor.Current = Cursors.Arrow;
                return;
            }

            Projection projection = graphPainter.GraphList[0].projection;

            if ((e.Button == MouseButtons.Left) && (_isClicked == false))
            {
                _isClicked  = true;
                _startPoint = graphPoint;
            }

            if ((e.Button == MouseButtons.Left) && (_isClicked == true))
            {
                Point stopPoint = graphPoint;
                // No change in position happened, therefore no translation is required
                int pixelDifference = stopPoint.X - _startPoint.X;
                if (pixelDifference == 0)
                {
                    return;
                }

                // Setting up hand cursor
                Cursor.Current = Cursors.Hand;

                float sensivity  = 3.0f;
                float difference = sensivity * (projection.ConvertScreenXToRealValue(stopPoint.X) - projection.ConvertScreenXToRealValue(_startPoint.X));


                // Updating new X range based on difference
                graphPainter.SetRangeX(Projection.XMin - difference, Projection.XMax - difference);
                _isClicked  = false;
                _startPoint = stopPoint;

                // positionPanel.Refresh();
                return;
            }

            _isClicked = false;
        }