2009年5月11日 星期一

[C#] Dynamic create button array

int i, j;
this.buttonArr = new Button[4, 4];
for (i = 0; i <= 3; i++)
{
for (j = 0; j <= 3; j++)
{
this.buttonArr[i, j] = new System.Windows.Forms.Button();
this.buttonArr[i, j].Location = new System.Drawing.Point(70 + i * 80, 70 + j * 40);
this.buttonArr[i, j].Name = "buttonarr" + (i + j * 4).ToString();
this.buttonArr[i, j].Size = new System.Drawing.Size(80, 40);
this.buttonArr[i, j].TabIndex = i * 10 + j;
this.buttonArr[i, j].Text = "button" + (i + j * 4).ToString();
this.buttonArr[i, j].UseVisualStyleBackColor = true;
this.buttonArr[i, j].Click += new System.EventHandler(this.button1_Click);
this.Controls.Add( this.buttonArr[i, j]);
}
}
*********************************************************************
private void button1_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
MessageBox.Show(b.Name.ToString());
}

2009年5月7日 星期四

Exposed terminal problem

A,B,C,D four node ,when B transmit to A ,and C want to transmit to D,it sensor it`s area,C think it can`t send to D because it sensor B is transmitting

Hidden Node Problem

Node A,C are B`s neighbor,but be hidden for each other,when fire a message to B simultaneously ,the collision would occur

802.11 use RTS(Request To Send) and CTS(Clear To Send) to solve this problem