예제 #1
0
        public void MouseWheel(object sender, MouseEventArgs e)
        {
            float fNewStart;
            float fNewEnd;
            float fDiff;

            //_form.bUserMovingGraph = true; // Stop graph sliding from timer

            fNewStart = Projection.XMin;
            fNewEnd   = Projection.XMax;
            fDiff     = (fNewEnd - fNewStart) / 10; // zopm with 10%

            if (e.Delta < 0)                        // Zoom in
            {
                fNewStart -= fDiff;
                fNewEnd   += fDiff;
            }
            else  // Zoom out
            {
                fNewStart += fDiff;
                fNewEnd   -= fDiff;
            }

            float nPermitedMin = float.MaxValue;
            float nPermitedMax = float.MinValue;

            foreach (Graph source in _graphList) // find start and end "X" for all graphs
            {
                if (source.Length > 0)
                {
                    if (nPermitedMin > source.Samples[0].X)
                    {
                        nPermitedMin = source.Samples[0].X;
                    }

                    if (nPermitedMax < source.Samples[source.Length - 1].X)
                    {
                        nPermitedMax = source.Samples[source.Length - 1].X;
                    }
                }
            }

            if (fNewStart < nPermitedMin)  // Prevent zooming out of min/max
            {
                fNewStart = nPermitedMin;
            }

            if (fNewEnd > nPermitedMax)
            {
                fNewEnd = nPermitedMax;
            }

            if (fNewStart < fNewEnd)
            {
                Projection.setRangeX(fNewStart, fNewEnd);
            }
        }
예제 #2
0
        public void Zoom_X(bool bIn, int graphWidth)
        {
            // int graphWidth = ((PictureBox)sender).Width;

            Point screenPoint = Cursor.Position;
            Point graphPoint  = _pictureBox.PointToClient(screenPoint);

            // TODO: min/max X should be found when adding points to graphs. Change "GetMinimuxX()";
            float graphicMinX   = _graphList[0].GetFirstPoint().X; // GetMinimumX();
            float graphicMaxX   = _graphList[0].GetLastPoint().X;  //GetMaximumX();
            float graphicRangeX = graphicMaxX - graphicMinX;

            float fZoomingPointProportion = ((float)graphPoint.X) / graphWidth;
            float fZoomingPoint_real      = Projection.XMin + (Projection.XRange * fZoomingPointProportion);

            float newRange;

            if (bIn)
            {
                newRange = Projection.XRange / 2;
            }
            else
            {
                newRange = Projection.XRange * 2;
            }

            float fNewX_start = fZoomingPoint_real - fZoomingPointProportion * newRange;
            float fNewX_end   = fNewX_start + newRange;

            if (fNewX_start < graphicMinX)
            {
                fNewX_start = graphicMinX;
            }

            if (fNewX_end > graphicMaxX)
            {
                fNewX_end = graphicMaxX;
            }

            Projection.setRangeX(fNewX_start, fNewX_end);
            Refresh();
            _form.positionPanel_Refresh();
        }
예제 #3
0
        public GraphPainter(PictureBox pictureBox, MainForm form)
        {
            _form       = form;
            _pictureBox = pictureBox;

            graphWidth          = pictureBox.Width;
            graphHeight         = pictureBox.Height - ScalePixelWidth;
            _bitmapGraph        = new Bitmap(pictureBox.Width, pictureBox.Height);
            _graphicsPictureBox = Graphics.FromImage(_bitmapGraph);
            _pictureBox.Image   = _bitmapGraph;

            Projection.SetSize(graphWidth, graphHeight);

            clearRange();

            Projection.setRangeX(10, 60);

            SetXAxisGridFontColor(Color.Gray);
            SetXAxisGridColor(Color.Blue);
        }
예제 #4
0
 public void SetRangeX(float xMin, float xMax)
 {
     Projection.setRangeX(xMin, xMax); // Common x-axis for all graphs
     paintAll(_graphicsPictureBox);
 }
예제 #5
0
        public void MouseWheel(object sender, MouseEventArgs e)
        {
            Point screenPoint = Cursor.Position;
            Point graphPoint  = _pictureBox.PointToClient(screenPoint);
            float fZoomingPoint_real;
            float newRange;

            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
            {
                zoom_Y(sender, e);
                return;
            }
            else if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt)
            {
                float fMax        = _graphList[1].projection.YMax;
                float fMin        = _graphList[1].projection.YMin;
                int   graphHeight = ((PictureBox)sender).Height;

                Point relatMousePoint = _pictureBox.PointToClient(screenPoint);

                float fZoomingCoef = ((float)relatMousePoint.Y) / graphHeight; // Projection.Height;
                fZoomingPoint_real = fMax - (_graphList[1].projection.YRange * fZoomingCoef);

                if (e.Delta > 0)
                {
                    newRange = _graphList[1].projection.YRange / 1.2f;
                }
                else
                {
                    newRange = _graphList[1].projection.YRange * 1.2f;
                }

                float fNewY_end = fZoomingPoint_real + fZoomingCoef * newRange;

                float fNewY_start = fNewY_end - newRange;

                /*
                 * if (fNewY_start < graphicMinX)
                 *  fNewY_start = graphicMinX;
                 *
                 * if (fNewY_end > graphicMaxX)
                 *  fNewY_end = graphicMaxX;
                 */

                _graphList[1].projection.SetY_Limit(fNewY_start, fNewY_end);


                Refresh();
                _form.positionPanel_Refresh();

                return;
            }

            int graphWidth = ((PictureBox)sender).Width;



            // TODO: min/max X should be found when adding points to graphs. Change "GetMinimuxX()";
            float graphicMinX   = _graphList[0].GetFirstPoint().X; // GetMinimumX();
            float graphicMaxX   = _graphList[0].GetLastPoint().X;  //GetMaximumX();
            float graphicRangeX = graphicMaxX - graphicMinX;

            float fZoomingPointProportion = ((float)graphPoint.X) / graphWidth;

            fZoomingPoint_real = Projection.XMin + (Projection.XRange * fZoomingPointProportion);

            if (e.Delta > 0)
            {
                newRange = Projection.XRange / 2;
            }
            else
            {
                newRange = Projection.XRange * 2;
            }

            float fNewX_start = fZoomingPoint_real - fZoomingPointProportion * newRange;
            float fNewX_end   = fNewX_start + newRange;

            if (fNewX_start < graphicMinX)
            {
                fNewX_start = graphicMinX;
            }

            if (fNewX_end > graphicMaxX)
            {
                fNewX_end = graphicMaxX;
            }

            Projection.setRangeX(fNewX_start, fNewX_end);
            Refresh();
            _form.positionPanel_Refresh();
        }