基于C#窗体程序的一个简单计算器,进制转换的小数部分没有完善,初学者,继续努力中...各位大侠请指教,各位小白大家互相学习,一起进步usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Threading;namespacejs_easy{publicpartialclassForm1:Form{stringFh=;//定义符号位doublea,b,c;//定义a第一个值,b第二个值,c输出值longs=1;//定义小数最初为一位publicForm1(){InitializeComponent();}publicvoidanniu(doublei)//按钮方法{if(Fh.Equals())//是否当前有运算符{if(s==1)//判断是否有小数点{a=a*10+i;//计算无小数的值}else{a=a+i/s;//计算有小数的值s=s*10;//计算下一个小数的位置}textBox1.Text=a.ToString();//显示计算的结果}else//当前有运算符的方法{if(!(c==0)){b=0;c=0;}//当有计算结果就清除B的值if(s==1)//判断是否有小数点{b=b*10+i;//计算无小数的值}else{if(i==0)//判断在小数位后添加0{s=s*10;//计算下一个小数的位置}else{b=b+i/s;//计算有小数的值s=s*10;//计算下一个小数的位置}}textBox1.Text=b.ToString();//显示计算的结果}}publicvoidjs(){//数学计算的方法if(Fh==/)//判断是否除数等于0{if(b==0)//是则不计算{textBox1.Text=0;//被除数不能为0return;//返回}else{c=a/b;}}else//如果不是出发计算则执行其他计算{if(Fh.Equals(+)){c=a+b;}if(Fh.Equals(-)){c=a-b;}if(Fh.Equals(*)){c=a*b;}if(Fh.Equals(%)){c=a%b;}}textBox1.Text=c.ToString();//显示计算结果a=c;//将结果给第一个变量作为}publicvoidfh(stringstr)//接收运算符的方法{if(Fh.Equals())//当前是否已经有运算符{Fh=str;s=1;//没有则接收运算符,小数点失效}else{js();s=1;Fh=str;//有则计算当前的值,小数点失效}}/*暂不支持小数进制转换*/publicvoidjz2(stringjg)//2进制转换{longtemp=Convert.ToInt64(jg);if(temp2){textBox2.Text=temp.ToString();}else{inti=0;int[]array=newint[1000];while(temp0){array[i++]=(int)temp%2;temp/=2;}int[]array_1=newint[i];for(intj=i-1;j=0;j--)array_1[j]=array[i-1-j];//Array.Reverse(array_1);foreach(intkinarray_1)textBox2.Text+=k.ToString();}}publicvoidjz8(stringjg)//8进制转换{longtemp=Convert.ToInt64(jg);if(temp9){textBox2.Text=temp.ToString();}else{inti=0;int[]array=newint[1000];while(temp0){array[i++]=(int)temp%8;temp/=8;}int[]array_1=newint[i];for(intj=i-1;j=0;j--)array_1[j]=array[i-1-j];//Array.Reverse(array_1);foreach(intkinarray_1)textBox2.Text+=k.ToString();}}publicvoidjz16(stringjg)//十六进制转换{longtemp=Convert.ToInt64(jg);if(temp16){textBox2.Text=temp.ToString();}else{inti=0;int[]array=newint[1000];//浪费空间,节省时间while(temp0){array[i++]=(int)temp%16;temp/=16;}int[]array_1=newint[i];for(intj=i-1;j=0;j--)array_1[j]=array[i-1-j];foreach(intkinarray_1)textBox2.Text+=k.ToString(X);}}publiclongJiec(longjg)//阶乘{longtemp=jg;if(temp==1){return1;}else{longtemp1=Jiec(temp-1);temp=temp*temp1;returntemp;}}privatevoidForm1_Load(objectsender,EventArgse){textBox1.Font=newFont(宋体,14,FontStyle.Bold);textBox2.Font=newFont(宋体,14,FontStyle.Bold);this.Text=简单计算器;stringdir=@image\angry.jpg;pictureBox1.Image=Image.FromFile(dir);pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage;pictureBox1.Dock=DockStyle.Fill;button1.Text==;button2.Text=2;button3.Text=3;button4.Text=4;button5.Text=5;button6.Text=C1;button7.Text=7;button8.Text=8;button9.Text=9;button10.Text=0;button12.Text=+;button13.Text=-;button14.Text=*;button15.Text=%;button16.Text=/;button17.Text=6;button18.Text=.;button19.Text=1;button11.Text=C2;button20.Text=Sin;button21.Text=Cos;button22.Text=Tan;button23.Text=Log10;button24.Text=Lg;button25.Text=!;button25.Font=newFont(,10,FontStyle.Bold);button26.Text=^2;radioButton1.Text=二进制;radioButton2.Text=八进制;radioButton3.Text=十六进制;radioButton4.Text=十进制;}privatevoidtextBox1_TextChanged(objectsender,EventArgse){textBox1.BackColor=Color.White;textBox1.Enabled=false;}privatevoidtextBox2_TextChanged(objectsender,EventArgse){textBox1.BackColor=Color.White;textBox1.Enabled=false;}privatevoidbutton19_Click(objectsender,EventArgse){anniu(1);}privatevoidbutton2_Click(objectsender,EventArgse){anniu(2);}privatevoidbutton3_Click(objectsender,EventArgse){anniu(3);}privatevoidbutton4_Click(objectsender,EventArgse){anniu(4);}privatevoidbutton5_Click(objectsender,EventArgse){anniu(5);}privatevoidbutton17_Click(objectsender,EventArgse){anniu(6);}privatevoidbutton7_Click(objectsender,EventArgse){anniu(7);}privatevoidbutton8_Click(objectsender,EventArgse){anniu(8);}privatevoidbutton9_Click(objectsender,EventArgse){anniu(9);}privatevoidbutton10_Click(objectsender,EventArgse){if(!textBox1.Text.Equals(0)){anniu(0);}}privatevoidbutton18_Click(objectsender,EventArgse){if(s==1){s=10;}}privatevoidbutton14_Click(objectsender,EventArgse){fh(*);button14.BackColor=Color.BlueViolet;}privatevoidbutton15_Click(objectsender,EventArgse){fh(%);button15.BackColor=Color.BlueViolet;}privatevoidbutton12_Click(objectsender,EventArgse){fh(+);button12.BackColor=Color.BlueViolet;}privatevoidbutton13_Click(objectsender,EventArgse){fh(-);button13.BackColor=Color.BlueViolet;}privatevoidbutton16_Click(objectsender,EventArgse){fh(/);button16.BackColor=Color.BlueViolet;}privatevoidbutton6_Click(objectsender,EventArgse){textBox1.Text=0;//清空TEXTBOX的显示值a=0;b=0;c=0;s=1;Fh=;//初始化所有值}privatevoidbutton1_Click(objectsender,EventArgse){fh(=);Thread.Sleep(300);//颜色改变延迟button12.BackColor=SystemColors.Control;//还原按钮颜色button13.BackColor=SystemColors.Control;button14.BackColor=SystemColors.Control;button15.BackColor=SystemColors.Control;button16.BackColor=SystemColors.Control;}privatevoidradioButton1_Check