資源簡介
winform項目,動態顯示紅綠燈,功能較簡單,代碼易懂,希望給大家帶來點幫助。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing.Drawing2D;
namespace?Ex19_13
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//重寫
????????protected?override?void?OnPaint(System.Windows.Forms.PaintEventArgs?e)
????????{
????????????getFillColor();//?????????
????????}
????????//自定義繪制紅綠黃燈方法一個填沖函數
????????public?void?getFillColor()
????????{
????????????Graphics?g?=?this.CreateGraphics();//實例一個?Graphics對像
????????????switch?(intFalg)
????????????{
????????????????case?0:
????????????????????g.FillEllipse(Brushes.DarkBlue?20?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?110?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?200?8?60?60);
????????????????????break;
????????????????case?1://?//紅燈
????????????????????g.FillEllipse(Brushes.Red?20?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?110?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?200?8?60?60);
????????????????????break;
????????????????case?2:?//綠燈
????????????????????g.FillEllipse(Brushes.DarkBlue?20?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?110?8?60?60);
????????????????????g.FillEllipse(Brushes.Green?200?8?60?60);
????????????????????break;//
????????????????case?3:
????????????????????g.FillEllipse(Brushes.DarkBlue?20?8?60?60);
????????????????????g.FillEllipse(Brushes.Yellow?110?8?60?60);
????????????????????g.FillEllipse(Brushes.DarkBlue?200?8?60?60);
????????????????????break;////黃燈
????????????}//end?switch
????????}//?
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
?????????
????????????intTime=65;
????????????label1.Text?=?intTime.ToString();
????????????label1.ForeColor?=?Color.Red;
????????????timer1.Enabled=true;
????????}
????????public?int?intTime?=?0;//?計時
????????public?int?intFalg?=?0;//標記
????????//?紅燈
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????Graphics?g?=?this.CreateGraphics();
?????????????????????if?(intTime?!=?0)
?????????????????????{
?????????????????????????if?(intTime?10)
?????????????????????????{
?????????????????????????????label1.Text?=?“0“?+?intTime.ToString();
?????????????????????????????label1.ForeColor?=?Color.Red;
?????????????????????????}
?????????????????????????else
?????????????????????????{
?????????????????????????????label1.Text?=?intTime.ToString();
?????????????????????????????label1.ForeColor?=?Color.Red;
?????????????????????????}
?????????????????????????intTime--;
?????????????????????????intFalg?=?1;//控制紅綠黃燈刷新
?????????????????????????getFillColor();//調用填沖函數
????????????
????????????????????????
?????????????????????}
?????????????????????else
????????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????20480??2008-11-13?20:13??Ex19_13\Ex19_13\bin\Debug\Ex19_13.exe
?????文件??????30208??2008-11-13?20:13??Ex19_13\Ex19_13\bin\Debug\Ex19_13.pdb
?????文件???????5632??2007-07-11?11:35??Ex19_13\Ex19_13\bin\Debug\Ex19_13.vshost.exe
?????文件???????3221??2007-07-11?11:35??Ex19_13\Ex19_13\Ex19_13.csproj
?????文件???????5523??2007-07-11?11:35??Ex19_13\Ex19_13\Form1.cs
?????文件???????3226??2007-07-11?11:35??Ex19_13\Ex19_13\Form1.Designer.cs
?????文件???????6398??2007-07-11?11:35??Ex19_13\Ex19_13\Form1.resx
?????文件????????842??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Debug\Ex19_13.csproj.GenerateResource.Cache
?????文件??????20480??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Debug\Ex19_13.exe
?????文件????????180??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Debug\Ex19_13.Form1.resources
?????文件??????30208??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Debug\Ex19_13.pdb
?????文件????????180??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Debug\Ex19_13.Properties.Resources.resources
?????文件????????842??2007-07-11?11:35??Ex19_13\Ex19_13\obj\Debug\Ex20_13.csproj.GenerateResource.Cache
?????文件????????180??2007-07-11?11:35??Ex19_13\Ex19_13\obj\Debug\Ex20_13.Form1.resources
?????文件????????180??2007-07-11?11:35??Ex19_13\Ex19_13\obj\Debug\Ex20_13.Properties.Resources.resources
?????文件????????268??2007-07-11?11:35??Ex19_13\Ex19_13\obj\Ex19_13.csproj.FileList.txt
?????文件????????532??2008-11-13?20:13??Ex19_13\Ex19_13\obj\Ex19_13.csproj.FileListAbsolute.txt
?????文件????????268??2007-07-11?11:35??Ex19_13\Ex19_13\obj\Ex20_13.csproj.FileList.txt
?????文件????????466??2007-07-11?11:35??Ex19_13\Ex19_13\Program.cs
?????文件???????1162??2007-07-11?11:35??Ex19_13\Ex19_13\Properties\AssemblyInfo.cs
?????文件???????2868??2007-07-11?11:35??Ex19_13\Ex19_13\Properties\Resources.Designer.cs
?????文件???????5612??2007-07-11?11:35??Ex19_13\Ex19_13\Properties\Resources.resx
?????文件???????1090??2007-07-11?11:35??Ex19_13\Ex19_13\Properties\Settings.Designer.cs
?????文件????????249??2007-07-11?11:35??Ex19_13\Ex19_13\Properties\Settings.settings
?????文件????????910??2007-07-11?11:35??Ex19_13\Ex19_13.sln
????..A..H.?????19968??2008-11-13?20:13??Ex19_13\Ex19_13.suo
?????文件??????20480??2007-07-11?11:35??Ex19_13\Ex20_13\bin\Debug\Ex20_13.exe
?????文件??????32256??2007-07-11?11:35??Ex19_13\Ex20_13\bin\Debug\Ex20_13.pdb
?????文件???????5658??2007-07-11?11:35??Ex19_13\Ex20_13\bin\Debug\Ex20_13.vshost.exe
?????文件???????3221??2007-07-11?11:35??Ex19_13\Ex20_13\Ex20_13.csproj
............此處省略35個文件信息
- 上一篇:ASP.NET/C# +SQL小區收費系統
- 下一篇:c#Form窗體增刪改操作
評論
共有 條評論