C#编程科学计算器文档格式.docx
《C#编程科学计算器文档格式.docx》由会员分享,可在线阅读,更多相关《C#编程科学计算器文档格式.docx(17页珍藏版)》请在冰豆网上搜索。
^region功能键
privatevoidon_Click(objectsender,EventArgs。
)〃开始
flag=1;
sp=0;
max=0;
this.numinput.Text="
(T;
this.txtlnput.Text=
privatevoidoff_Click(objectsender,EventArgse)〃关闭
flag=0;
this.numinput.Text=m,;
this.txtlnput.Text=m,;
1
privatevoidbutton9_Click(objectsender,EventArgse)〃删除
if(flag==1&
&
sp==0)
stringnumstring=this.numinput.Text;
if(numstring.Length>
0)
(
stringtemp=numstring.Substring(0,numstring.Length・1);
this.numinput.Text=temp.7bString();
else
0"
;
privatevoidclear_Click(objectsender,EventArgs@)〃c清零
if(flag==1)
sp=o;
this.txtlnput.Text=,w;
privatevoiddelete_Click(objectsender,EventArgs。
)〃洁零
O"
)
#endregion
^region运算符
privatevoidequaLClick(objectsender,EventArgse)〃等
eq=1;
if(flag==1&
sp==0)
num2=Convert.TbDoublefthis.numinput.Text);
this.txtinput.Text+=num2.TbString();
this.txtlnput.1ext+=”=”;
txtinput.Text=null;
sv/itch(op)
case1:
result=num1+num2;
break;
case2:
result=num1・num2;
case3:
result=num1*num2;
case4:
result=numI/num2;
case5:
result=Math.Pow(num1,num2);
case6:
result=Mod(numl,num2);
default:
return;
if(op==4&
num2==0)
this.numinput.Text=”除数不能为0”;
sp=1;
}else
//this,txtinput.Text+=result.ToString();
this.numinput.Text=result.TbString();
privatevoidsub_Click(objectsender,EventArgs。
)〃微法{
num1=Convert.TDDouble(this.numinput.Text);
this.txtinput.Text+=nuni1・7bString();
numinput.Text=m,;
this.txtlnput.7ext+=
op=2;
privatevoidmul_Click(objectsender,EventArgse)〃乘法
if(flag==1aasp==0)
this.txtinput.Text+=num1.7bString();
this.numinput.Text=
op=3;
privatevoiddivide_Click(objectsender,EventArgse)〃除法{
this.txtinput.Text+=num1・7bString();
op=4;
privatevoidplus_Click(objectsender,EventArgse)〃加法
ftsp==0)
this.txtinput.Text+=%”;
op=1;
publicdoubleMod(doublex,doubley)〃取模运算
inttemp=Convert.7blnt32(x/y);
return(x-y*temp);
privatevoidpower_Click(objectsender,EventArgs。
)//'
繇运算
asp==0)
num1=Convert.TDDouble(numlnput.Text);
this.numinput.Text=,M,;
this.txtlnput.7ext+=RA"
op=5;
privatevoidrecip_Click(objectsender,EventArgs。
)〃倒数
doubletemp=0;
temp=1/numl;
this.txtlnput.7ext=n1/n+num1.7bString()+官;
privatevoidpercent_Click(objectsender,EventArgse)
//doubletemp=Convert.TbDouble(this.numinput.Text);
//this,txtinput.Text+=temp.7bString();
//temp=temp/100;
//this,numinput.Text=temp.lbStnng();
//this.txtinput.Text+=
num1=Convert.TbDoublefthis.numinput.Text);
this.numinput.Text=,,M;
this.txtlnput.7ext+=”%”;
op=6;
^region数字
privatevoidone_Click(objectsender,EventArgse)//1
sp==0&
max==0)
if(this.numinput.Text=="
0n)
if(eq==1)
1"
eq=0;
this.numinput.Text+=111n;
privatevoidtwo_Click(objectsender,EventArgse)//2
if(this.numinput.Text==”0”)
this.numinput.Text=n"
2"
this.numinput.Text+=”2”;
//this.txtinput.Text+="
Z"
privatevoidthree_Click(objectsender,EventArgse)//3
if(flag==18t&
3"
this.numinput.Text+="
3n;
//this.txtinput.Text+=”3”;
privatevoidfour_Click(objectsender,EventArgse)//4
this.numinput.Text=n4r,;
4n;
//this.txtlnput.Text+="
4"
privatevoidfive_Click(objectsender,EventArgse)//5
5"
5n;
//this,txtinput.Text+="
privatevoidsix_Click(objectsender,EventArgse)//6
if(this.numinput.Text==,,0H)
this.numinput.Text=M6M;
this.numinput.Text+=u6n;
6"
privatevoidseven_Click(objectsender,EventArgse)//7
this.numinput.Text=”7”;
this.numinput.Text+=,,7n;
//this,txtinput,"
fext+=“7”;
privatevoideight_Click(objectsender,EventArgse)//8
0”)
this.numinput.Text=”8”;
this.numinput.Text+=”8”;
fext+=u8"
privatevoidnight_Click(objectsender,EventArgse)//9
9"
//this.txtlnput.Iext+=“9”;
privatevoidzero_Click(objectsender,EventArgse)//0
0。
0”;
O'
1;
privatevoiddian_Click(objectsender,EventArgs。
)〃小数点
.,f;
this.numinput.Text+=
//this,txtinput.Text+=
Region三角函数
privatevoidsin_Click(objectsender,EventArgse)//sin
num1=Convert.TDDoublefthis.numinput.Text);
doubletemp=Math.PI*(num1/180);
this.txtlnput.1ext+=Msin(H+numI+”)=“;
num1=Math.Sin(temp);
this.numinput.Text=numl.7bStnng();
//this,txtinput.Text+=num1.ToString();
privatevoidcos_Click(objectsender,EventArgse)//cos
this.txtinput.Text+=”cos(”+num1+n)="
num1=Math.Cos(temp);
this.numinput.Text=numl.7bString();
privatevoidtan_Click(objectsender,EventArgse)//tan
this.txtlnput.7ext+=ntan(H+numl+"
)=n;
num1=Math.Tan(temp);
this.numinput.Text=numI.ToString();
#region帮助
privatevoid关于产品7bolStnpMenultem_Click(objectsender,EventArgse){
MenuAboutabout=nev/MenuAbout();
about.Show();
privatevoidchange_Click(objectsender,EventArgse)
if(flag==l&
ftsp==0)
numl=Convert.TDDoublefthis.numinput.Text);
num1=-numI;
privatevoid使用手册7bolStnpMenultem_Click(objectsender,EventArgse){
MenuUseuse=newMenuUse();
use.Shov/();
Region皮肤
privatevoid皮肤17bolStnpMenultem_Click(objectsender,EventArgse)
skinEngineI.SkinFile=Application.StartupPath+"
XCalmness-ssk"
privatevoid皮肤27bolStripMenultem_Click(objectsender,EventArgse)
\DeepCyan.ssk,1;
privatevoid皮肤37bolStripMenultem_Click(objectsender,EventArgse)
\Eighteen.ssk"
privatevoid皮肤47bolStripMenultem_Click(objectsender,EventArgse)
\GlassGreen.ssk"
privatevoid皮fl^57bolStripMenultem_Click(objectsender,EventArgse)
XSilvenssk"
#region复制粘贴
privatevoid复fti]lbolStripMenultem_Click(objectsender,EventArgse)
if(numinput.SelectionLength>
numinput.Copy();
privatevoid粘贴7bolStripMenultem-Click(objectsender,EventArgse)
numinput.Paste();
privatevoidCounter^Load(objectsender,EventArgse)
numinput.SelectAll();
RectangleScreenArea=System.Windows.Forms.Screen.GetBounds(this);
intwidth=ScreenArea.Width;
intheigth=ScreenArea.Height;
this.Location=newPoint((width/2)・(this.Width/2),(heigth/2)-(this.Height/
2));
privatevoidnumlnput_TextChanged(objectsender,EventArgse)//numtext