?? form1.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace calc
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Calculator1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btn1;
private System.Windows.Forms.Button btn2;
private System.Windows.Forms.Button btn3;
private System.Windows.Forms.Button btn4;
private System.Windows.Forms.Button btn5;
private System.Windows.Forms.Button btn6;
private System.Windows.Forms.Button btn7;
private System.Windows.Forms.Button btn8;
private System.Windows.Forms.Button btn9;
private System.Windows.Forms.Button btn0;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnSubtract;
private System.Windows.Forms.Button btnMultiply;
private System.Windows.Forms.Button btnDivide;
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.Button btnEquals;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Button btnNegative;
private System.Windows.Forms.Button btnDecimal;
private int opMain = 0; // 1(加法) 2(減法) 3(乘法) 4(除法)
private double mainNum1 = 0; // 存儲第一個數
private double mainNum2 = 0; // 存儲第二個數
private bool isSecond = false; // 用來判斷輸入的是第一個還是第二個數
private bool isDone = false; // 用來判斷是否按了等于按鈕
private bool isDecimal = false; // 用了判斷是否有小數
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Calculator1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSubtract = new System.Windows.Forms.Button();
this.btnDivide = new System.Windows.Forms.Button();
this.btnEquals = new System.Windows.Forms.Button();
this.btnDecimal = new System.Windows.Forms.Button();
this.btn2 = new System.Windows.Forms.Button();
this.btn3 = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.btn1 = new System.Windows.Forms.Button();
this.btn6 = new System.Windows.Forms.Button();
this.btn7 = new System.Windows.Forms.Button();
this.btn4 = new System.Windows.Forms.Button();
this.btn5 = new System.Windows.Forms.Button();
this.btn8 = new System.Windows.Forms.Button();
this.btn9 = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.btnMultiply = new System.Windows.Forms.Button();
this.btnNegative = new System.Windows.Forms.Button();
this.btn0 = new System.Windows.Forms.Button();
this.txtResult = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnSubtract
//
this.btnSubtract.Location = new System.Drawing.Point(136, 80);
this.btnSubtract.Name = "btnSubtract";
this.btnSubtract.Size = new System.Drawing.Size(32, 32);
this.btnSubtract.TabIndex = 0;
this.btnSubtract.TabStop = false;
this.btnSubtract.Text = "-";
this.btnSubtract.Click += new System.EventHandler(this.btnSubtract_Click);
//
// btnDivide
//
this.btnDivide.Location = new System.Drawing.Point(136, 160);
this.btnDivide.Name = "btnDivide";
this.btnDivide.Size = new System.Drawing.Size(32, 32);
this.btnDivide.TabIndex = 0;
this.btnDivide.TabStop = false;
this.btnDivide.Text = "/";
this.btnDivide.Click += new System.EventHandler(this.btnDivide_Click);
//
// btnEquals
//
this.btnEquals.Location = new System.Drawing.Point(136, 200);
this.btnEquals.Name = "btnEquals";
this.btnEquals.Size = new System.Drawing.Size(32, 32);
this.btnEquals.TabIndex = 0;
this.btnEquals.TabStop = false;
this.btnEquals.Text = "=";
this.btnEquals.Click += new System.EventHandler(this.btnEquals_Click);
//
// btnDecimal
//
this.btnDecimal.Location = new System.Drawing.Point(88, 200);
this.btnDecimal.Name = "btnDecimal";
this.btnDecimal.Size = new System.Drawing.Size(32, 32);
this.btnDecimal.TabIndex = 0;
this.btnDecimal.TabStop = false;
this.btnDecimal.Text = ".";
this.btnDecimal.Click += new System.EventHandler(this.btnDecimal_Click);
//
// btn2
//
this.btn2.Location = new System.Drawing.Point(48, 40);
this.btn2.Name = "btn2";
this.btn2.Size = new System.Drawing.Size(32, 32);
this.btn2.TabIndex = 0;
this.btn2.TabStop = false;
this.btn2.Text = "2";
this.btn2.Click += new System.EventHandler(this.btn2_Click);
//
// btn3
//
this.btn3.Location = new System.Drawing.Point(88, 40);
this.btn3.Name = "btn3";
this.btn3.Size = new System.Drawing.Size(32, 32);
this.btn3.TabIndex = 0;
this.btn3.TabStop = false;
this.btn3.Text = "3";
this.btn3.Click += new System.EventHandler(this.btn3_Click);
//
// btnClear
//
this.btnClear.ForeColor = System.Drawing.Color.OrangeRed;
this.btnClear.Location = new System.Drawing.Point(8, 200);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(32, 32);
this.btnClear.TabIndex = 0;
this.btnClear.TabStop = false;
this.btnClear.Text = "C";
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// btn1
//
this.btn1.Location = new System.Drawing.Point(8, 40);
this.btn1.Name = "btn1";
this.btn1.Size = new System.Drawing.Size(32, 32);
this.btn1.TabIndex = 0;
this.btn1.TabStop = false;
this.btn1.Text = "1";
this.btn1.Click += new System.EventHandler(this.btn1_Click);
//
// btn6
//
this.btn6.Location = new System.Drawing.Point(88, 80);
this.btn6.Name = "btn6";
this.btn6.Size = new System.Drawing.Size(32, 32);
this.btn6.TabIndex = 0;
this.btn6.TabStop = false;
this.btn6.Text = "6";
this.btn6.Click += new System.EventHandler(this.btn6_Click);
//
// btn7
//
this.btn7.Location = new System.Drawing.Point(8, 120);
this.btn7.Name = "btn7";
this.btn7.Size = new System.Drawing.Size(32, 32);
this.btn7.TabIndex = 0;
this.btn7.TabStop = false;
this.btn7.Text = "7";
this.btn7.Click += new System.EventHandler(this.btn7_Click);
//
// btn4
//
this.btn4.Location = new System.Drawing.Point(8, 80);
this.btn4.Name = "btn4";
this.btn4.Size = new System.Drawing.Size(32, 32);
this.btn4.TabIndex = 0;
this.btn4.TabStop = false;
this.btn4.Text = "4";
this.btn4.Click += new System.EventHandler(this.btn4_Click);
//
// btn5
//
this.btn5.Location = new System.Drawing.Point(48, 80);
this.btn5.Name = "btn5";
this.btn5.Size = new System.Drawing.Size(32, 32);
this.btn5.TabIndex = 0;
this.btn5.TabStop = false;
this.btn5.Text = "5";
this.btn5.Click += new System.EventHandler(this.btn5_Click);
//
// btn8
//
this.btn8.Location = new System.Drawing.Point(48, 120);
this.btn8.Name = "btn8";
this.btn8.Size = new System.Drawing.Size(32, 32);
this.btn8.TabIndex = 0;
this.btn8.TabStop = false;
this.btn8.Text = "8";
this.btn8.Click += new System.EventHandler(this.btn8_Click);
//
// btn9
//
this.btn9.Location = new System.Drawing.Point(88, 120);
this.btn9.Name = "btn9";
this.btn9.Size = new System.Drawing.Size(32, 32);
this.btn9.TabIndex = 0;
this.btn9.TabStop = false;
this.btn9.Text = "9";
this.btn9.Click += new System.EventHandler(this.btn9_Click);
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(136, 40);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(32, 32);
this.btnAdd.TabIndex = 0;
this.btnAdd.TabStop = false;
this.btnAdd.Text = "+";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnMultiply
//
this.btnMultiply.Location = new System.Drawing.Point(136, 120);
this.btnMultiply.Name = "btnMultiply";
this.btnMultiply.Size = new System.Drawing.Size(32, 32);
this.btnMultiply.TabIndex = 0;
this.btnMultiply.TabStop = false;
this.btnMultiply.Text = "*";
this.btnMultiply.Click += new System.EventHandler(this.btnMultiply_Click);
//
// btnNegative
//
this.btnNegative.Location = new System.Drawing.Point(48, 200);
this.btnNegative.Name = "btnNegative";
this.btnNegative.Size = new System.Drawing.Size(32, 32);
this.btnNegative.TabIndex = 0;
this.btnNegative.TabStop = false;
this.btnNegative.Text = "+/-";
this.btnNegative.Click += new System.EventHandler(this.btnNegative_Click);
//
// btn0
//
this.btn0.Location = new System.Drawing.Point(48, 160);
this.btn0.Name = "btn0";
this.btn0.Size = new System.Drawing.Size(32, 32);
this.btn0.TabIndex = 0;
this.btn0.TabStop = false;
this.btn0.Text = "0";
this.btn0.Click += new System.EventHandler(this.btn0_Click);
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(8, 8);
this.txtResult.Name = "txtResult";
this.txtResult.Size = new System.Drawing.Size(160, 21);
this.txtResult.TabIndex = 1;
this.txtResult.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.txtResult.TextChanged += new System.EventHandler(this.txtResult_TextChanged);
//
// Calculator1
//
this.ClientSize = new System.Drawing.Size(176, 237);
this.Controls.Add(this.btnDecimal);
this.Controls.Add(this.btnNegative);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -