Hey everyone,
Im trying to implement a tiling algorithm in C#. I'm having a couple of issues,
my approach is to take the size of a grid m x m as input, and then draw the grid using DrawRectangles method on my graphics object. the user then selects a tile around which the grid gets tiled.
My issues:
one : the OnPaint eventhandler only shows the graphics i want to generate when called on the form. I tried calling it on a picturebox control and a panel control but the graphics dont show up?
two: im trying to put my rectangles in an array so i can identify which rectangle is selected and apply a tiling algo based on which tile(rectangle) is selected. But its not working. NullExceptionReference is what is says when i run the code. Im an amateur, so please let me know if i'm declaring it incorrectly? or Am i using the wrong data structure?
public Rectangle [] rect;
rect[(m*m)]=new Rectangle();
k=1;
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
rect [k]=new Rectangle((x+(j*offset)),(y+i*offset)),offset,offset);
g.DrawRectangle(myPen,rect[k]);
k++;
}
}