Click here to Skip to main content
15,890,741 members

Comments by a4ashiq (Top 3 by date)

a4ashiq 29-Jan-14 4:24am View    
Deleted
I Just formed the matrix with t
private void MakeMatrix()
{
label1.Text = ""; int MaxFreeH, MaxFreeV;
int s = 1;
int[] ad1 = new int[] { 4, 4 };
int[] ad2 = new int[] { 3, 2 };
int[] ad3 = new int[] { 2, 5 };

System.Collections.ArrayList a = new System.Collections.ArrayList();

a.Add(ad1);
a.Add(ad2);
a.Add(ad3);

int MaxV = 8, MaxH = 6;
//int HSize = 0, VSize = 0;

int[,] pageMatrix = new int[MaxV, MaxH];

for (int i = 0; i < MaxV; i++)
{
for (int j = 0; j < MaxH; j++)
{
pageMatrix[i, j] = 0;
label1.Text += pageMatrix[i, j].ToString() + " ";
}
label1.Text += Environment.NewLine;
}

foreach (int[] Ad in a)
{
bool Flag = false;
for (int V = 0; V < MaxV; V++)
{
for (int H = 0; H < MaxH; H++)
{
if (V + Ad[0] <= MaxV && H + Ad[1] <= MaxH)
{
if (pageMatrix[V, H] == 0 && pageMatrix[V + (Ad[0]-1), H + (Ad[1]-1)] == 0)
{
for (int i = V; i < V + Ad[0]; i++)
for (int j = H; j < H + Ad[1]; j++)
{
pageMatrix[i, j] = s;
}
Flag = true;
break;
}
}
}
if (Flag)
break;
}
s++;
}

label1.Text += Environment.NewLine + " ------------------------" + Environment.NewLine + Environment.NewLine;

for (int i = 0; i < MaxV; i++)
{
for (int j = 0; j < MaxH; j++)
{
label1.Text += pageMatrix[i, j].ToString() + " ";
}
label1.Text += Environment.NewLine;
}

}


this will make the matrix an print in the above format. But, like i said, i have no further idea about graphics.
a4ashiq 29-Jan-14 3:42am View    
Hi YvesDaoust,
its for asp.net web forms. i forgot to mention that in my question. I already got the answer yesterday. But i think your suggestion will work. I'll try that also for sure. Thanks for the reply.
a4ashiq 8-Aug-12 0:25am View    
You're welcome dude. Rate the answer if it helped you..
Thank you