private PointF getPicBoxOffset(Point mouseLocation, drawingProperties dS)
        {   // backwards calculation to keep real coordinates on mouse-pos. on zoom-in -out
            float ratioVisu = dS.rangeX / dS.rangeY;
            float ratioPic  = pictureBox1.Width / pictureBox1.Height;
            float maxposY   = dS.rangeY;

            if (ratioVisu > ratioPic)
            {
                maxposY = dS.rangeX * pictureBox1.Height / pictureBox1.Width;
            }

            float relposX = (picAbsPos.X - dS.minX) / dS.rangeX;
            float relposY = (maxposY - picAbsPos.Y + dS.minY) / dS.rangeY;

            if (ratioVisu > ratioPic)
            {
                relposY = relposY * ratioPic / ratioVisu;
            }
            else
            {
                relposX = relposX * ratioVisu / ratioPic;
            }

            PointF picOffset = new PointF();

            picOffset.X = mouseLocation.X - (relposX * zoomFactor * pictureBox1.Width);
            picOffset.Y = mouseLocation.Y - (relposY * zoomFactor * pictureBox1.Height);
            return(picOffset);
        }
        private void createGridView()
        {
            drawingProperties tmp = new drawingProperties();
            PointF            ul  = getGraphicCoordinateFromPictureBox(new Point(0, 0));
            PointF            lr  = getGraphicCoordinateFromPictureBox(new Point(pictureBox1.Width, pictureBox1.Height));

            tmp.setX((float)Math.Round(ul.X), (float)Math.Round(lr.X));
            tmp.setY((float)Math.Round(ul.Y), (float)Math.Round(lr.Y));
            VisuGCode.createRuler(ruler, tmp);
            createGrid(grid, tmp, (float)nUDRaster.Value);
        }
        private void createGrid(GraphicsPath path, drawingProperties dS, float raster)
        {
            path.Reset();
            float minX = (float)Math.Round(dS.minX / raster) * raster;
            float minY = (float)Math.Round(dS.minY / raster) * raster;

            for (float x = minX; x < (dS.maxX); x += raster)
            {
                path.StartFigure();
                path.AddLine(x, dS.minY, x, dS.maxY);
            }
            for (float y = minY; y < (dS.maxY); y += raster)
            {
                path.StartFigure();
                path.AddLine(dS.minX, y, dS.maxX, y);
            }
        }
 private void logDrawingSize(drawingProperties dS)
 {
     Logger.Trace("logDrawingSize {0} {1} {2} {3}", dS.minX, dS.minY, dS.maxX, dS.maxY);
 }