form1.cs
来自「Sams Teach Yourself C# Web Programming i」· CS 代码 · 共 141 行
CS
141 行
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Static_Methods
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class fclsExample : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnDrawEllipse;
private System.Windows.Forms.Button btnClearEllipse;
private System.Windows.Forms.Button btnComputeLength;
private System.Windows.Forms.TextBox txtInputForLength;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public fclsExample()
{
//
// 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.btnDrawEllipse = new System.Windows.Forms.Button();
this.btnClearEllipse = new System.Windows.Forms.Button();
this.btnComputeLength = new System.Windows.Forms.Button();
this.txtInputForLength = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnDrawEllipse
//
this.btnDrawEllipse.Name = "btnDrawEllipse";
this.btnDrawEllipse.Size = new System.Drawing.Size(80, 23);
this.btnDrawEllipse.TabIndex = 0;
this.btnDrawEllipse.Text = "Draw Ellipse";
this.btnDrawEllipse.Click += new System.EventHandler(this.btnDrawEllipse_Click);
//
// btnClearEllipse
//
this.btnClearEllipse.Location = new System.Drawing.Point(283, 0);
this.btnClearEllipse.Name = "btnClearEllipse";
this.btnClearEllipse.Size = new System.Drawing.Size(80, 23);
this.btnClearEllipse.TabIndex = 1;
this.btnClearEllipse.Text = "Clear Ellipse";
this.btnClearEllipse.Click += new System.EventHandler(this.btnClearEllipse_Click);
//
// btnComputeLength
//
this.btnComputeLength.Location = new System.Drawing.Point(0, 250);
this.btnComputeLength.Name = "btnComputeLength";
this.btnComputeLength.Size = new System.Drawing.Size(100, 23);
this.btnComputeLength.TabIndex = 2;
this.btnComputeLength.Text = "Compute Length";
this.btnComputeLength.Click += new System.EventHandler(this.btnComputeLength_Click);
//
// txtInputForLength
//
this.txtInputForLength.Location = new System.Drawing.Point(110, 250);
this.txtInputForLength.Name = "txtInputForLength";
this.txtInputForLength.TabIndex = 3;
this.txtInputForLength.Text = "";
//
// fclsExample
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(363, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.txtInputForLength,
this.btnComputeLength,
this.btnClearEllipse,
this.btnDrawEllipse});
this.Name = "fclsExample";
this.Text = "Method Example";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new fclsExample());
}
private void btnDrawEllipse_Click(object sender, System.EventArgs e)
{
clsStaticExample.DrawEllipse(this);
}
private void btnClearEllipse_Click(object sender, System.EventArgs e)
{
clsStaticExample.ClearEllipse(this);
}
private void btnComputeLength_Click(object sender, System.EventArgs e)
{
int intLength;
intLength = clsStaticExample.ComputeLength(txtInputForLength.Text);
System.Diagnostics.Debug.WriteLine("length = " + intLength);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?