This post shows how to create a background "grid" on the drawing surface. Right click on the TestDiagram window to switch from Design to Code (RC Form > View Code). You can toggle back to the Designer from the Code window using RC Code > View Designer.
First define an attribute for the grid_gap or spacing between grid points and set its value to 10. Add the following code above the form constructor:
public const int grid_gap = 10;
The grid is a BitMap with points draw over its xy coordinates. The schematicCanvas (pictureBox) has a graphics capability which can be accessed from its Paint and Resize events.
Add the following method after the form constructor:
private void DrawBackgroundGrid()
Bitmap bm = new Bitmap(
2000);
for (int x = 0; x < 2000; x += grid_gap)
for (int y = 0; y < 2000; y += grid_gap)
bm.SetPixel(x, y, Color.DarkGray); //Color.DarkGray);
}
}
schematicCanvas.BackgroundImage = bm;
}
DrawBackgroundGrid();
}
No comments:
Post a Comment