• 大小: 69KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C#
  • 标签:

资源简介

c#红绿灯程序源代码,c#红绿灯程序源代码

资源截图

代码片段和文件信息

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个文件信息

评论

共有 条评论

相关资源