📄 frmmain.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Calculator
{
/// <summary>
/// frmMain 的摘要说明。
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtInput;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Label lblResult;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public static void Main()
{
Application.Run(new frmMain());
}
public frmMain()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.txtInput = new System.Windows.Forms.TextBox();
this.btnSubmit = new System.Windows.Forms.Button();
this.lblResult = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtInput
//
this.txtInput.Location = new System.Drawing.Point(8, 8);
this.txtInput.Name = "txtInput";
this.txtInput.Size = new System.Drawing.Size(200, 21);
this.txtInput.TabIndex = 0;
this.txtInput.Text = "";
//
// btnSubmit
//
this.btnSubmit.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnSubmit.Location = new System.Drawing.Point(208, 8);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.TabIndex = 1;
this.btnSubmit.Text = "计算(&S)";
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// lblResult
//
this.lblResult.Location = new System.Drawing.Point(8, 40);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(272, 23);
this.lblResult.TabIndex = 2;
//
// frmMain
//
this.AcceptButton = this.btnSubmit;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.lblResult);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.txtInput);
this.Name = "frmMain";
this.Text = "frmMain";
this.Load += new System.EventHandler(this.frmMain_Load);
this.ResumeLayout(false);
}
#endregion
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Calculator calculator = new Calculator();
double result = 0d;
try
{
result = calculator.Calculat(txtInput.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
lblResult.Text = txtInput.Text + " = " + result.ToString();
}
private void frmMain_Load(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -