-
大小: 0.10M文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2024-04-27
- 語(yǔ)言: C#
- 標(biāo)簽: 實(shí)現(xiàn)??程序??C#??
資源簡(jiǎn)介
C#實(shí)現(xiàn)一個(gè)閃屏小程序,可自定義閃屏間隔時(shí)長(zhǎng)
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?blink
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//colorIndex計(jì)數(shù)
????????private?int?colorIndex;
????????//定義顏色數(shù)組
????????private?Color[]?colors;
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????//給背景添加顏色,以colorIndex計(jì)數(shù)為索引
????????????BackColor?=?colors[colorIndex];
????????????//?button5.BackColor?=?colors[colorIndex];
????????????//?button5.BackColor
????????????//計(jì)數(shù)遞增
????????????colorIndex++;
????????????//如果計(jì)數(shù)大于設(shè)定的顏色數(shù)量,則計(jì)數(shù)歸0,實(shí)現(xiàn)循環(huán)
????????????if?(colorIndex?>=?colors.Length)
????????????{
????????????????colorIndex?=?0;
????????????}
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????}
????????private?void?blink(int?a)
????????{
????????????//for?(int?i?=?255;?i?>=?0;?i=i-10)
????????????//????for?(int?j?=?255;?j>=?0;?j?=?j?-?10)
????????????//????????for?(int?k?=?255;?k?>=?0;?k?=?k?-?10)
????????????//????????{
????????????//????????????{
????????????//????????????????{
????????????//????????????????????Color?c?=?new?Color();???????????????//定義一個(gè)Color類型的實(shí)例c?????????????//為實(shí)例c賦值
????????????//????????????????????c?=?Color.FromArgb(i?jk);//通過(guò)設(shè)置紅綠藍(lán)的值變化
????????????//????????????????????button1.BackColor?=?c;
??????????????????????????????
????????????//????????????????}
????????????//????????????}
????????????//????????}
????????????//Color?c?=?Color.FromArgb(140?140?140);
????????????colors?=?new?Color[]?{?Color.Red?Color.Blue?Color.Cyan};?//
????????????//創(chuàng)建定時(shí)器
????????????//Timer?timer?=?new?Timer();
????????????timer1.Interval?=?a;
????????????//timer2.Tick?+=?Timer_Tick;
????????????//timer1.Start();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????//int?a?=?200;
????????????timer1.Start();
????????????int?a;
????????????if?(textBox1.Text?==?““)?{?a?=?2000;?}
????????????else?{?a?=?int.Parse(textBox1.Text);?}
????????????blink(a);
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????timer1.Stop();
????????}
????????//private?void?timer2_Tick(object?sender?EventArgs?e)
????????//{
????????//????btn_left_led.BackColor?=?btn_left_led.BackColor?==?Color.DarkGray???Color.Red?:?Color.DarkGray;
????????//}
????????/*
????????private?int?colorIndex;
????????//定義顏色數(shù)組
????????private?Color[]?colors;
????????private?void?timer2_Tick(object?sender?EventArgs?e)
????????{
????????????Graphics?gra?=?this.pictureBox2.CreateGraphics();
????????????Brush?bush?=?new?SolidBrush(colors[colorIndex]);//填充的顏色
????????????gra.FillEllipse(bush?10?10?100?100);//畫填充橢圓的方法,x坐標(biāo)、y坐標(biāo)
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-10-10?08:27??.vs\
?????目錄???????????0??2020-10-10?08:27??.vs\bl
?????目錄???????????0??2020-10-10?08:27??.vs\bl
?????文件???????41472??2020-10-14?13:54??.vs\bl
?????文件?????????189??2020-08-19?18:13??App.config
?????目錄???????????0??2020-10-14?13:42??bin\
?????目錄???????????0??2020-11-05?10:55??bin\Debug\
?????文件?????????189??2020-08-19?18:13??bin\Debug\bl
?????文件???????19464??2020-11-05?10:55??bin\Debug\bl
?????文件???????32256??2020-10-14?13:40??bin\Debug\bl
?????目錄???????????0??2020-10-14?13:54??bin\Release\
?????文件???????28672??2020-10-14?13:54??bin\Release\bl
?????文件?????????189??2020-08-19?18:13??bin\Release\bl
?????文件???????30208??2020-10-14?13:54??bin\Release\bl
?????文件????????3763??2020-10-14?13:54??bl
?????文件????????1115??2020-08-19?18:13??bl
?????文件????????9662??2020-10-14?13:38??favicon48.ico
?????文件????????4172??2020-10-14?13:40??Form1.cs
?????文件????????3926??2020-10-14?13:40??Form1.Designer.cs
?????文件???????20811??2020-10-14?13:40??Form1.resx
?????目錄???????????0??2020-10-14?13:42??obj\
?????目錄???????????0??2020-10-14?13:42??obj\Debug\
?????文件?????????214??2020-10-10?15:11??obj\Debug\.NETfr
?????文件??????????42??2020-10-14?13:40??obj\Debug\bl
?????文件????????1190??2020-10-14?13:40??obj\Debug\bl
?????文件????????1012??2020-10-14?13:40??obj\Debug\bl
?????文件????????8435??2020-10-14?13:41??obj\Debug\bl
?????文件???????19456??2020-10-14?13:40??obj\Debug\bl
?????文件???????10228??2020-10-14?13:40??obj\Debug\bl
?????文件???????32256??2020-10-14?13:40??obj\Debug\bl
?????文件?????????180??2020-10-14?13:40??obj\Debug\bl
............此處省略24個(gè)文件信息
評(píng)論
共有 條評(píng)論