2005-03-14 00:14:19AC Huang
|||||0313C#|||||
哎呀呀
為什麼每個假日都要為了C#的作業煩腦
今天還是第一次做作業
上禮拜的沒交
真是罪過
不過我這次有認真到
以下就是我寫PIC的程式碼
很多
但三分之二都是設定後自已跑出來的
嘿嘿嘿
不過可以執行
真的很令人感動
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WinAp1
{
///
/// Form1 的摘要描述。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label mywork;
private System.Windows.Forms.Button Red;
private System.Windows.Forms.Button Green;
private System.Windows.Forms.Button Yello;
private System.Windows.Forms.Button Clean;
///
/// 設計工具所需的變數。
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
}
///
/// 清除任何使用中的資源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form 設計工具產生的程式碼
///
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
///
private void InitializeComponent()
{
this.mywork = new System.Windows.Forms.Label();
this.Red = new System.Windows.Forms.Button();
this.Green = new System.Windows.Forms.Button();
this.Yello = new System.Windows.Forms.Button();
this.Clean = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// mywork
//
this.mywork.Font = new System.Drawing.Font("標楷體", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.mywork.ForeColor = System.Drawing.SystemColors.ControlText;
this.mywork.Location = new System.Drawing.Point(48, 24);
this.mywork.Name = "mywork";
this.mywork.Size = new System.Drawing.Size(176, 48);
this.mywork.TabIndex = 0;
this.mywork.Text = "C++";
this.mywork.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Red
//
this.Red.Font = new System.Drawing.Font("標楷體", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.Red.Location = new System.Drawing.Point(56, 96);
this.Red.Name = "Red";
this.Red.Size = new System.Drawing.Size(152, 48);
this.Red.TabIndex = 1;
this.Red.Text = "Red";
this.Red.Click += new System.EventHandler(this.Red_Click);
//
// Green
//
this.Green.Font = new System.Drawing.Font("標楷體", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.Green.Location = new System.Drawing.Point(56, 160);
this.Green.Name = "Green";
this.Green.Size = new System.Drawing.Size(152, 48);
this.Green.TabIndex = 2;
this.Green.Text = "Green";
this.Green.Click += new System.EventHandler(this.Green_Click);
//
// Yello
//
this.Yello.Font = new System.Drawing.Font("標楷體", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.Yello.ForeColor = System.Drawing.SystemColors.ControlText;
this.Yello.Location = new System.Drawing.Point(56, 224);
this.Yello.Name = "Yello";
this.Yello.Size = new System.Drawing.Size(152, 48);
this.Yello.TabIndex = 3;
this.Yello.Text = "Yello";
this.Yello.Click += new System.EventHandler(this.Yello_Click);
//
// Clean
//
this.Clean.Font = new System.Drawing.Font("標楷體", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.Clean.Location = new System.Drawing.Point(56, 288);
this.Clean.Name = "Clean";
this.Clean.Size = new System.Drawing.Size(152, 48);
this.Clean.TabIndex = 4;
this.Clean.Text = "Clean";
this.Clean.Click += new System.EventHandler(this.Clean_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(256, 342);
this.Controls.Add(this.Clean);
this.Controls.Add(this.Yello);
this.Controls.Add(this.Green);
this.Controls.Add(this.Red);
this.Controls.Add(this.mywork);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// 應用程式的主進入點。
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Red_Click(object sender, System.EventArgs e)
{
mywork.Text="紅燈";
mywork.ForeColor=Color.Red;
}
private void Green_Click(object sender, System.EventArgs e)
{
mywork.Text="綠燈";
mywork.ForeColor=Color.Green;
}
private void Yello_Click(object sender, System.EventArgs e)
{
mywork.Text="黃燈";
mywork.ForeColor=Color.Yellow;
}
private void Clean_Click(object sender, System.EventArgs e)
{
mywork.Text=" ";
}
}
}