stelasagni / diagramnet

Automatically exported from code.google.com/p/diagramnet
0 stars 0 forks source link

- Draw Engine - Grid Performance / Bug #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
resize the window with zoom different to 100%

What is the expected output? What do you see instead?
the grid does not resize properly

Original issue reported on code.google.com by dalssoft on 29 Jun 2009 at 4:35

GoogleCodeExporter commented 9 years ago
I changed the DrawGrid (document.cs) to this, I think this solved the problem:

        internal void DrawGrid(Graphics g, Rectangle clippingRegion)
        {
//          ControlPaint.DrawGrid(g, clippingRegion, gridSize, Color.LightGray);

            Pen p = new Pen(new HatchBrush(HatchStyle.LargeGrid | HatchStyle.Percent90, Color.LightGray, Color.Transparent), 1);

            //Pen p = new Pen(Color.LightGray, 1);

            int maxX = location.X + this.Size.Width;
            int maxY = location.Y + this.Size.Height;

            if (windowSize.Width > maxX)
                maxX = windowSize.Width;

            if (windowSize.Height > maxY)
                maxY = windowSize.Height;

            int gsWidth = (int)(gridSize.Width * zoom);
            int gsHeight = (int)(gridSize.Height * zoom);

            if (gsWidth < 1) gsWidth = 1;
            if (gsHeight < 1) gsHeight = 1;

            for (int i = 0; i < maxX; i += gsWidth)
            {
                g.DrawLine(p, i, 0, i, maxY);
            }

            for (int i = 0; i < maxY; i += gsHeight)
            {
                g.DrawLine(p, 0, i, maxX, i);
            }

            p.Dispose();
        }

Original comment by ManuelBr...@gmail.com on 25 Jun 2012 at 5:15