番茄钟倒计时器代码

2022-06-18 17:09:11   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《番茄钟倒计时器代码》,欢迎阅读!
倒计时器,番茄,代码
using System;

using System.Collections.Generic;// using System.ComponentModel;//

using System.Data;//定义ADO.NET数据库结构

using System.Drawing;//提供对基本图形功能的访问 using System.Text;//字符编码处理

using System.Windows.Forms;//创建使用标准windows图形接口基于windows应用程序

namespace fanqiezhong {

public partial class Form1 : Form {

public Form1() {

InitializeComponent(); }

private int totalSecond; private int tenthSecond; private int js;

private void button1_Click(object sender, EventArgs e) {

totalSecond = 59; tenthSecond = 9; js = 0;

timer1.Enabled = true; button2.Enabled = true; button2.Text = "停止阅读";

label1.BackColor = Color.FromArgb(0, 0, 255); label1.ForeColor = Color.FromArgb(255, 255, 255); }

private void button2_Click(object sender, EventArgs e) {

if (this.button2.Text == "停止阅读") {

timer1.Enabled = false; button2.Text = "继续阅读";//需要修改成这样、 } else {

timer1.Enabled = true; button2.Text = "停止阅读"; } }

private void Form1_Load(object sender, EventArgs e) {

label1.Text = "0:01:00"; label2.Text = "番茄数:0"; progressBar1.Value = 1800; button2.Text = "停止阅读";


button2.Enabled = false;

label1.BackColor = Color.FromArgb(0, 0, 255); label1.ForeColor = Color.FromArgb(255, 255, 255); }

private void timer1_Tick(object sender, EventArgs e) {

int minute = totalSecond / 60; int second = totalSecond % 60;

string str = minute.ToString() + ":" + second.ToString() + ":" + tenthSecond.ToString(); label1.Text = str; tenthSecond--; if (tenthSecond == -1) {

tenthSecond = 9; totalSecond--;

if (totalSecond == -1) {

totalSecond = 9; js++;

label2.Text = "番茄数:" +js.ToString();

} else {

progressBar1.Value = totalSecond; } } }

private void label1_Click(object sender, EventArgs e) {

}

} }




本文来源:https://www.wddqxz.cn/37060b614431b90d6c85c788.html

相关推荐