这是一个没有完成的计算器,
有如下程序,请问这些程序时什么意思,如何设置label控件
有三个label控件
// label1
//
this.label1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(12, 63);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 29);
this.label1.TabIndex = 1;
this.label1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.label1_PreviewKeyDown);
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(14, 65);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(37, 27);
this.label2.TabIndex = 1;
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label2.Click += new System.EventHandler(this.num_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 8);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 12);
this.label3.TabIndex = 0;
this.label3.Visible = false;
private void button_Enter(object sender, EventArgs e)
{
this.label1.Focus();
}
private void m_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
if (button.Text == "MC")
{
mem = 0;
label2.Text = "";
}
if (button.Text == "MR")
{
textBox.Text = Convert.ToString(mem);
int temp = (int)mem;
double tm = (double)temp;
if (mem == tm)
textBox.AppendText(".");
compute = false;
}
if (button.Text == "MS")
{
mem = Convert.ToDouble(textBox.Text);
point = 0;
compute = false;
if(mem!=0)
label2.Text = "M";
}
if (button.Text == "M+")
{
mem = mem + Convert.ToDouble(textBox.Text);
}
}
private void label1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.NumPad0)
num_Click(button23,e);
if (e.KeyCode == Keys.NumPad1)
num_Click(button18, e);
if (e.KeyCode == Keys.NumPad2)
num_Click(button19, e);
if (e.KeyCode == Keys.NumPad3)
num_Click(button20, e);
if (e.KeyCode == Keys.NumPad4)
num_Click(button13, e);
if (e.KeyCode == Keys.NumPad5)
num_Click(button14, e);
if (e.KeyCode == Keys.NumPad6)
num_Click(button15, e);
if (e.KeyCode == Keys.NumPad7)
num_Click(button8, e);
if (e.KeyCode == Keys.NumPad8)
num_Click(button9, e);
if (e.KeyCode == Keys.NumPad9)
num_Click(button10, e);
if (e.KeyCode == Keys.Subtract)
oper_Click(button21, e);
if (e.KeyCode == Keys.Add)
oper_Click(button26, e);
if (e.KeyCode == Keys.Multiply)
oper_Click(button16, e);
if (e.KeyCode == Keys.Divide)
oper_Click(button11, e);
if (e.KeyCode == Keys.Enter)
oper_Click(button27, e);
if (e.KeyCode == Keys.Decimal)
num_Click(button25, e);
}
}
}