嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
该计数器基本实现了加减乘除的运算
private void btnVal_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
string numberStr = this.txtValue.Text;
if (this._IsNew)
{
numberStr = btn.Text;
this._ValueL = double.Parse(numberStr);
}
else
{
if (new string[] { "0", "0.", "-0", "-0." }.Contains(numberStr))
{
numberStr = "";
}
numberStr = btn.Text;
this._ValueF = double.Parse(numberStr);
}
this.txtValue.Text = numberStr;
this._IsNew = false;
}
private void btnPI_Click(object sender, EventArgs e)
{
if(this._IsNew)
{
this._ValueL = Math.PI;
}
else
{
this._ValueF = Math.PI;
}
this.txtValue.Text = Math.PI.ToString();
this._IsNew = true;
}
private void btnResult_Click(object sender, EventArgs e)
{
switch(_CalculateType)
{
case CalcuType.Addition:
this.txtValue.Text = (_ValueF _ValueL).ToString();
break;
case CalcuType.Substraction:
this.txtValue.Text = (_ValueF - _ValueL).ToString();
break;
case CalcuType.Multipication:
this.txtValue.Text = (_ValueF * _ValueL).ToString();
break;
case CalcuType.Division:
this.txtValue.Text = (_ValueF / _ValueL).ToString();
break;
case CalcuType.Involution:
this.txtValue.Text = Math.Pow((double)_ValueF, (double)_ValueL).ToString();
break;
case CalcuType.Square:
this.txtValue.Text = Math.Pow((double)_ValueF, 1 / (double)_ValueL).ToString();
break;
}
this._ValueF = double.Parse(this.txtValue.Text);
this._IsNew = true;
}
private void btnClears_Click(object sender, EventArgs e)
{
this._ValueF = null;
this._ValueL = null;
this._CalculateType = CalcuType.None;
this.txtValue.Text = "0.";
}
private void btnAddition_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Addition;
this._IsNew = true;
}
private void btnSubstraction_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Substraction;
this._IsNew = true;
}
private void btnMultiplication_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Multipication;
this._IsNew = true;
}
private void btnDivision_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Division;
this._IsNew = true;
}
private void btnSquare_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Square;
this._IsNew = true;
}
private void btnInvelution_Click(object sender, EventArgs e)
{
this.btnResult_Click(sender, e);
this._CalculateType = CalcuType.Involution;
this._IsNew = true;
}
private void btnBackspace_Click(object sender, EventArgs e)
{
if(this.txtValue.Text.Length==1)
{
this.txtValue.Text = "0.";
}
else
{
this.txtValue.Text = txtValue.Text.Substring(0, txtValue.Text.Length - 1);
}
}