代码记录生活-倒计时


我不会表达我的内心世界,那么我就用代码来记录我的生活,用一行行代码来表达我的心情。


虽然我写的代码都很简单,毕竟我是初学者,以后会慢慢的好的。


那么今天就先上传我昨天写的一个小计时器吧,就只有一个计时器功能,其他的没有。

源码分享地址链接:http://pan.baidu.com/s/1eQcT0A2 密码:4xru

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 using System.Media;
10
11 namespace 倒计时小工具 {
12 public partial class Form1 : Form {
13     int h, m, s, times;
14     Boolean a = true;
15     public Form1() {
16         InitializeComponent();
17     }
18     public int gettime() {
19         h = Convert.ToInt32 ( numericUpDown1.Value );
20         m = Convert.ToInt32 ( numericUpDown2.Value );
21         s = Convert.ToInt32 ( numericUpDown3 .Value );
22         return h * 3600 + m * 60 + s;
23     }
24     private void button1_Click ( object sender, EventArgs e ) {
25         times = gettime();
26         progressBar1.Maximum = times;
27         progressBar1.Value = 0;
28         button3.Text = "暂停";
29         a = true;
30         button3.Visible = true;
31         timer1.Start();
32         label1.Text = "你设置的倒计时剩余:" + h + "小时" + m + "分钟" + s + "秒";
33     }
34
35     private void button3_Click ( object sender, EventArgs e ) {
36         if ( a == true ) {
37             timer1.Stop();
38             a = false;
39             button3.Text = "继续";
40         } else {
41             timer1.Start();
42             a = true;
43             button3.Text = "暂停";
44         }
45     }
46     private void button2_Click ( object sender, EventArgs e ) {
47         timer1.Stop();
48         progressBar1.Value = 0;
49         a = true;
50         button3.Text = "暂停";
51         label1.Text = "请输入时间并开始";
52         button3.Visible = false;
53     }
54     private void timer1_Tick ( object sender, EventArgs e ) {
55         if ( progressBar1.Value < times ) {
56             progressBar1.Value++;
57             time_1();
58             label1.Text = "你设置的倒计时剩余:" + h + "小时" + m + "分钟" + s + "秒";
59         } else {
60             timer1.Stop();
61             button3.Visible = false;
62             SystemSounds.Exclamation.Play();
63             MessageBox.Show ( "时间到了", "提示" );
64         }
65     }
66     public void time_1() {
67         h = ( times-progressBar1.Value ) / 3600;
68         m = ( times - progressBar1.Value ) % 3600 / 60;
69         s = ( times - progressBar1.Value ) % 3600 % 60;
70     }
71
72
73 }
74 }
时间: 2024-08-07 17:01:24

代码记录生活-倒计时的相关文章

MVVM 代码记录

  一.XML <Page x:Class="MVVM.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MVVM" xmlns:d="http://schemas

记录生活

昨天,部门一起去吃饭,去了一家很奢华的酒店,包厢很大,很宽敞. 大家吃的其乐融融. 这就是生活吧,这就是答案吧. 手机不给力啊,以后要买个好点的手机,记录生活的点滴,也许老了只剩下回忆了.

记录生活,活的更多

所有做过的一切都只会变成记忆和财富的积累,如何记录生活,多记住自己做过的事,就能让自己活的更多...越让自己记住更多快乐的事就会让自己变成越快乐的人,越是让自己记住更多学过的知识就会让自己变成更渊博的人,一切的一切都将转换成记忆和财富而已... 因此努力去记录生活,让自己活的更多吧...

i微影,一款帮你快速记录生活的app

现代人的生活日常,晒娃.晒美食.晒美景.晒自己--而这一系列的动作都离不开一件事--拍照录视频.可用专业相机来拍,美是美,但实在太贵!毕竟"摄影穷三代,单反毁一生"不只是说说而已,一个镜头上万块是稀松平常的事.而且技术要求高,携带也不方便.论方便,那当然非手机APP莫属,随时随地,想拍就拍.不过,想用一些手机app拍出媲美专业相机的照片,对于大多数人来说也不是那么容易的.这时候,你需要的就是这样一款专为大众记录生活的软件-i微影,i微影是深圳市祥和网络科技开发出的一款颠覆性的记录短片A

毕业设计代码记录

最近开始搞毕业论文了,亚历山大,记录一点毕业设计需要用的代码 <html>     <head>           <meta charset="utf-8">           <title>颜色插值</title>     </head>    <style>   </style> <body> <script src="http://d3js.org/d

点点文刊 -- 记录生活的色彩

点点文刊    记录你生活的点点滴滴...让你的生活更富传奇色彩...

超实用的JavaScript代码段 Item1 --倒计时效果

现今团购网.电商网.门户网等,常使用时间记录重要的时刻,如时间显示.倒计时差.限时抢购等,本文分析不同倒计时效果的计算思路及方法,掌握日期对象Date,获取时间的方法,计算时差的方法,实现不同的倒时计效果. 1.简单时间显示 讲解日期对象Date,并通过该对象获取时.分.秒等,让你自由提取所需时间内容. <!DOCTYPE html> <html> <head> <title>获取时间</title> <script type="

OpenCV学习代码记录——Hough线段检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> // http://blog.csdn.net/zh

OpenCV学习代码记录——canny边缘检测

很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tree/master/OpenCVTest. #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> // c