?? form1.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 多功能計算機器
{
public class Form : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox expressBox;
private System.ComponentModel.Container components = null;
//***往下為自已定義的變量***
//定義存放運算符(包括:'+','-',...,'sin',...,'arcsin',...,'(',...等)及其特性的數據結構
public struct opTable //定義存放運算符及其優先級和單雙目的結構
{
public string op; //用于存放運算符 op為oprater的簡寫
public int code; //用存放運算符的優先級
public char grade; //用于判斷存放的運算符是單目還是雙目
}
public opTable[] opchTbl=new opTable[19]; //用于存放制定好的運算符及其特性(優先級和單雙目)的運算符表,其初始化在方法Initialize()中
public opTable[] operateStack=new opTable[30]; //用于存放從鍵盤掃描的運算符的棧
//定義優先級列表 1,2,3,4,5,6,7,8,9,
public int[]osp=new int[19]{6,6,6,6,6,6,6,6,6,6,6,5,3,3,2,2,7,0,1}; //數組中元素依次為: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/","+","-","(",")","" 的棧外(因為有的運算符是從右向左計算,有的是從左往右計算,用內外優先級可以限制其執行順序)優先級
public int[]isp=new int[18]{5,5,5,5,5,5,5,5,5,5,5,4,3,3,2,2,1,1}; //數組中元素依次為: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/","+","-","(" ,"end" 的棧內(因為有的運算符是從右向左計算,有的是從左往右計算,用內外優先級可以限制其執行順序)優先級
//定義存放從鍵盤掃描的數據的棧
public double[]dataStack=new double[30]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//定義表態指針
public int opTop=-1; //指向存放(從鍵盤掃描的)運算符棧的指針
public int dataTop=-1;//指向存放(從鍵盤掃描的)數據棧指針
//定義存放從鍵盤輸入的起始字符串
public string startString;
public int startTop=0;
public double variableX=0;
public double variableY=0;
const double PI=3.1415926;
int number=1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button17;
private System.Windows.Forms.Button button18;
private System.Windows.Forms.Button button19;
private System.Windows.Forms.Button button20;
private System.Windows.Forms.Button button21;
private System.Windows.Forms.Button button22;
private System.Windows.Forms.Button button23;
private System.Windows.Forms.Button button24;
private System.Windows.Forms.Button button25;
private System.Windows.Forms.Button button26;
private System.Windows.Forms.Button button27;
private System.Windows.Forms.Button button28;
private System.Windows.Forms.Button button29;
private System.Windows.Forms.Button button30;
private System.Windows.Forms.Button button31;
private System.Windows.Forms.Button button32;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox endbox;
private System.Windows.Forms.Button button33;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox endList;
private System.Windows.Forms.Button button34;
private System.Windows.Forms.Button button35;
private System.Windows.Forms.Button button40;
public int startTopMoveCount=0;
//*******
//int x=0;
#region Windows Form Designer generated code
public Form()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.expressBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button();
this.button16 = new System.Windows.Forms.Button();
this.button17 = new System.Windows.Forms.Button();
this.button18 = new System.Windows.Forms.Button();
this.button19 = new System.Windows.Forms.Button();
this.button20 = new System.Windows.Forms.Button();
this.button21 = new System.Windows.Forms.Button();
this.button22 = new System.Windows.Forms.Button();
this.button23 = new System.Windows.Forms.Button();
this.button24 = new System.Windows.Forms.Button();
this.button25 = new System.Windows.Forms.Button();
this.button26 = new System.Windows.Forms.Button();
this.button27 = new System.Windows.Forms.Button();
this.button28 = new System.Windows.Forms.Button();
this.button29 = new System.Windows.Forms.Button();
this.button30 = new System.Windows.Forms.Button();
this.button31 = new System.Windows.Forms.Button();
this.button32 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.endbox = new System.Windows.Forms.TextBox();
this.button33 = new System.Windows.Forms.Button();
this.endList = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.button34 = new System.Windows.Forms.Button();
this.button35 = new System.Windows.Forms.Button();
this.button40 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// expressBox
//
this.expressBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.expressBox.Location = new System.Drawing.Point(112, 32);
this.expressBox.Name = "expressBox";
this.expressBox.Size = new System.Drawing.Size(288, 21);
this.expressBox.TabIndex = 0;
this.expressBox.Text = "";
this.expressBox.TextChanged += new System.EventHandler(this.expressBox_TextChanged);
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(16, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 24);
this.label2.TabIndex = 6;
this.label2.Text = "請輸入表達式:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// button1
//
this.button1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button1.Location = new System.Drawing.Point(216, 288);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(32, 23);
this.button1.TabIndex = 8;
this.button1.Text = "1";
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// button2
//
this.button2.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button2.Location = new System.Drawing.Point(216, 248);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(32, 23);
this.button2.TabIndex = 9;
this.button2.Text = "4";
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// button3
//
this.button3.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button3.Location = new System.Drawing.Point(328, 288);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(32, 23);
this.button3.TabIndex = 10;
this.button3.Text = "3";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button4.Location = new System.Drawing.Point(272, 288);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(32, 23);
this.button4.TabIndex = 11;
this.button4.Text = "2";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button5.Location = new System.Drawing.Point(272, 248);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(32, 23);
this.button5.TabIndex = 12;
this.button5.Text = "5";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button6.Location = new System.Drawing.Point(328, 248);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(32, 23);
this.button6.TabIndex = 13;
this.button6.Text = "6";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button7
//
this.button7.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button7.Location = new System.Drawing.Point(328, 208);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(32, 23);
this.button7.TabIndex = 14;
this.button7.Text = "9";
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// button8
//
this.button8.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button8.Location = new System.Drawing.Point(272, 208);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(32, 23);
this.button8.TabIndex = 15;
this.button8.Text = "8";
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button9
//
this.button9.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button9.Location = new System.Drawing.Point(216, 208);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(32, 23);
this.button9.TabIndex = 16;
this.button9.Text = "7";
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button10
//
this.button10.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button10.Location = new System.Drawing.Point(216, 328);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(32, 23);
this.button10.TabIndex = 17;
this.button10.Text = "0";
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button11
//
this.button11.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button11.Location = new System.Drawing.Point(272, 328);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(32, 23);
this.button11.TabIndex = 18;
this.button11.Text = "DEL";
this.button11.Click += new System.EventHandler(this.button11_Click);
//
// button12
//
this.button12.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button12.Location = new System.Drawing.Point(384, 248);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(32, 23);
this.button12.TabIndex = 19;
this.button12.Text = "*";
this.button12.Click += new System.EventHandler(this.button12_Click);
//
// button13
//
this.button13.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button13.Location = new System.Drawing.Point(432, 248);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(32, 23);
this.button13.TabIndex = 20;
this.button13.Text = "/";
this.button13.Click += new System.EventHandler(this.button13_Click);
//
// button14
//
this.button14.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button14.Location = new System.Drawing.Point(384, 288);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(32, 23);
this.button14.TabIndex = 21;
this.button14.Text = "+";
this.button14.Click += new System.EventHandler(this.button14_Click);
//
// button15
//
this.button15.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button15.Location = new System.Drawing.Point(432, 288);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(32, 23);
this.button15.TabIndex = 22;
this.button15.Text = "-";
this.button15.Click += new System.EventHandler(this.button15_Click);
//
// button16
//
this.button16.BackColor = System.Drawing.SystemColors.InactiveCaption;
this.button16.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button16.Location = new System.Drawing.Point(24, 208);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(32, 23);
this.button16.TabIndex = 23;
this.button16.Text = "Sin";
this.button16.Click += new System.EventHandler(this.button16_Click);
//
// button17
//
this.button17.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button17.Location = new System.Drawing.Point(24, 248);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(32, 23);
this.button17.TabIndex = 24;
this.button17.Text = "Cos";
this.button17.Click += new System.EventHandler(this.button17_Click);
//
// button18
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -