📄 form1.cs
字号:
namespace WinAPP_FCConvert
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.WinForms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components;
private System.WinForms.Button button2;
private System.WinForms.Button button1;
private System.WinForms.TextBox textBox2;
private System.WinForms.TextBox textBox1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
public override void Dispose()
{
base.Dispose();
components.Dispose();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container ();
this.button1 = new System.WinForms.Button ();
this.button2 = new System.WinForms.Button ();
this.textBox1 = new System.WinForms.TextBox ();
this.textBox2 = new System.WinForms.TextBox ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
button1.Location = new System.Drawing.Point (40, 80);
button1.Size = new System.Drawing.Size (72, 24);
button1.TabIndex = 2;
button1.Text = "C to F";
button1.Click += new System.EventHandler (this.button1_Click);
button2.Visible = true;
button2.Location = new System.Drawing.Point (216, 80);
button2.Size = new System.Drawing.Size (72, 24);
button2.TabIndex = 4;
button2.Text = "F to C";
button2.Click += new System.EventHandler (this.button2_Click);
textBox1.Location = new System.Drawing.Point (40, 16);
textBox1.TabIndex = 0;
textBox1.Size = new System.Drawing.Size (72, 21);
textBox2.Location = new System.Drawing.Point (216, 16);
textBox2.TabIndex = 1;
textBox2.Size = new System.Drawing.Size (72, 21);
textBox2.Visible = true;
this.Text = "C->F && F->C";
this.AutoScaleBaseSize = new System.Drawing.Size (6, 14);
this.ClientSize = new System.Drawing.Size (352, 141);
this.Controls.Add (this.button2);
this.Controls.Add (this.button1);
this.Controls.Add (this.textBox2);
this.Controls.Add (this.textBox1);
}
protected void button2_Click (object sender, System.EventArgs e)
{
double dc=0;
double df=0;
df=textBox2.Text.ToDouble();
dc=(df-32)/1.8;
textBox1.Text=dc.ToString();
}
protected void button1_Click (object sender, System.EventArgs e)
{
double dc=0;
double df=0;
try
{
dc=textBox1.Text.ToDouble();
}
catch(Exception)
{
textBox1.Clear();
textBox2.Clear();
return;
}
df=dc*1.8+32;
textBox2.Text=df.ToString();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -