using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Timer
{
    public partial class Timer : Form
    {
        public Timer()
        {
            InitializeComponent();
        }
        int days;
        int hours;
        int mins;
        int seconds;
        private void Timer_Load(object sender, EventArgs e)
        {
            List<int> listYear = new List<int>();
            ; i < ; i++)
            {
                listYear.Add(i);
            }
            comboBox1.DataSource = listYear;

            label1.ForeColor = Color.Red;
            label2.ForeColor = Color.Green;
            label3.ForeColor = Color.Yellow;
            label4.ForeColor = Color.Blue;
            label5.ForeColor = Color.Brown;
            button1.Visible = false;

            ; //设置间隔时间,为1000毫秒;
            this.timer1.Tick += new System.EventHandler(this.button1_Click);////设置每间隔3000毫秒(3秒)执行一次函数timer1_Tick

            this.timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
             && hours >=  && mins >= )
            {
                seconds--;
                label4.Text = seconds.ToString() + "秒";
                label5.Text = (days *  *  + hours *  + mins *  + seconds).ToString() + "秒";
                )
                {
                    mins--;
                    seconds = ;
                    label3.Text = mins.ToString() +"分";
                    )
                    {
                        hours--;
                        mins = ;
                        label2.Text = hours.ToString() + "时";
                        )
                        {
                            days--;
                            hours = ;
                            label1.Text = days.ToString() + "天";
                        }
                    }
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form frm = new GetHome();
            frm.Show();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<int> listMonth = new List<int>();
            ; i < ; i++)
            {
                listMonth.Add(i);
            }
            comboBox2.DataSource = listMonth;
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<int> listDay = new List<int>();
            switch (comboBox2.Text)
            {
                 ":
                ":
                ":
                ":
                ":
                ":
                ":
                    ; i < ; i++)
                    {
                        listDay.Add(i);
                    }
                    break;
                ":
                     ==  && Convert.ToInt32(comboBox1.SelectedValue) %  != ) || Convert.ToInt32(comboBox1.SelectedValue) %  == )
                    {
                        ; i < ; i++)
                        {
                            listDay.Add(i);
                        }
                    }
                    else
                    {
                        ; i < ; i++)
                        {
                            listDay.Add(i);
                        }
                    }
                    break;
                ":
                ":
                ":
                ":
                    ; i < ; i++)
                    {
                        listDay.Add(i);
                    }
                    break;
            }
            comboBox3.DataSource = listDay;
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            DateTime dt1 = , , );
            DateTime dt2 = DateTime.Now;
            comboBox1.Text = dt2.Year.ToString();
            TimeSpan ts = dt1.Subtract(dt2);
            days = ts.Days;
            hours = ts.Hours;
            mins = ts.Minutes;
            seconds = ts.Seconds;
            label1.Text = days.ToString() + "天";
            label2.Text = hours.ToString() + "时";
            label3.Text = mins.ToString() + "分";
            label4.Text = seconds.ToString() + "秒";
            label5.Text = (days *  *  + hours *  + mins *  + seconds).ToString() + "秒";
        }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Timer
{
    public partial class GetHome : Form
    {
        public GetHome()
        {
            InitializeComponent();
        }
        int time;
        private void GetHome_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            button1.Visible = false;
            DateTime dt = DateTime.Now;
            int day = dt.Day;
            int year = dt.Year;
            int month = dt.Month;
            DateTime dt1 = ,,);
            TimeSpan ts = dt1.Subtract(dt);
            time = ts.Hours *  + ts.Minutes *  + ts.Seconds;
            label1.Text = time.ToString() + "s";

            timer1.Interval = ;
            timer1.Tick += new System.EventHandler(this.button1_Click);
            timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            )
            {
                time--;
                string s = time.ToString();
                char[] str = s.ToCharArray();
                List<char> list = new List<char>();
                list.AddRange(str);
                )
                {
                    list.Insert(, ');
                }
                label1.Text = list[].ToString();
                label2.Text = list[].ToString();
                label3.Text = list[].ToString();
                label4.Text = list[].ToString();
                label5.Text = list[].ToString();
                label6.Text = "s";
                Thread th1 = new Thread(RandomColor);
                th1.IsBackground = true;
                th1.Start();
                Thread th2 = new Thread(RandomLocation);
                th2.IsBackground = true;
                th2.Start();
                )
                {
                    timer1.Stop();
                }
            }
        }
        void RandomColor()
        {
             Random r = new Random();
            , );
            , );
            Color c = new Color();
            switch (i)
            {
                :
                    c = Color.Blue;
                    break;
                :
                    c = Color.Purple;
                    break;
                :
                    c = Color.Brown;
                    break;
                :
                    c= Color.Pink;
                    break;
                :
                    c = Color.Red;
                    break;
                :
                    c = Color.Yellow;
                    break;
            }
            switch (i1)
            {
                :
                    label1.ForeColor = c;
                    break;
                :
                    label2.ForeColor = c;
                    break;
                :
                    label3.ForeColor = c;
                    break;
                :
                    label4.ForeColor = c;
                    break;
                :
                    label5.ForeColor = c;
                    break;
                :
                    label6.ForeColor = c;
                    break;
            }
        }
        void RandomLocation()
        {
            Random r = new Random();
            , );
            //int j = r.Next(0, 300);
            Point p = ,i);
            label1.Location = p;
            , );
            //int j1 = r.Next(0, 300);
            Point p1 = , i1);
            label2.Location = p1;
            , );
            //int j2 = r.Next(0, 300);
            Point p2 = ,i2);
            label3.Location = p2;
            , );
            //int j3 = r.Next(0, 300);
            Point p3 = ,i3);
            label4.Location = p3;
            , );
            //int j4 = r.Next(0, 300);
            Point p4 = ,i4);
            label5.Location = p4;
            , );
            //int j5 = r.Next(0, 300);
            Point p5 = ,i5);
            label6.Location = p5;
        }
    }
}

C#利用首尾時間計算中間時間差的更多相关文章

  1. 《Unity預計算即時GI》笔记:三、Clusters和总结

    Clusters 叢集,透過修改叢集(Clusters)也是一個降低Unity預計算流程所需要執行的工作數量的好方法.降低叢集數量也能提高執行時的效能. 當採用PRGI來計算場景光照時,Unity會簡 ...

  2. 《Unity預計算即時GI》笔记:二、光照图

    说明 这篇文章是对<Unity預計算即時GI>这个系列文章的笔记. 光照图 什么是光照图 光照图在第三章中有如下的定义,读起来很是费解. 一個光照圖(Chart)是表示一個光照貼圖的區域, ...

  3. 《Unity預計算即時GI》笔记:一、基本概念与一些设置

    说明 这篇文章是对<Unity預計算即時GI>这个系列文章的笔记. 基本概念 在Unity裡,可以用兩種不同的技術來計算全域光照GI或光源反射,就是烘焙全域光照(Baked GI)和預計算 ...

  4. ADC 計算時,階數的選擇

    reference : ADC 階數的計算

  5. 新版PHP 7效能實測:Drupal 7能快70%,碎形計算大勝Ruby和Python

    PHP 7才剛在12月3日正式釋出,網頁開發框架Zend公司立刻發表了一份PHP新舊版效能大車拼報告,除了PHP 7和PHP 5.6之外,也把HHVM 3.7版納入一起比較. Zend公司選擇了幾套知 ...

  6. Delphi APP 開發入門(三)簡易計算機

    Delphi APP 開發入門(三)簡易計算機 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數:68 ...

  7. 如何計算n個圓的聯集面積

    如何計算n個圓的聯集面積 前言 一般人第一次遇到這個問題,可能會想要想辦法用排容原理,找圓之間交疊的凸包之類的.... 然而我只要舉一個例子,你就會發現我們就算把凸包找出來了,我們也非常難知道找到的凸 ...

  8. java計算年齡的工具類

    整理一篇Java計算年齡的工具類,方便實用 public static int getAgeByBirth(String birthday) throws ParseException { // 格式 ...

  9. 透過 bc 計算 pi

    echo "scale=${num}; 4*a(1)" | bc -lq例如: echo "scale=5000; 4*a(1)" | bc -lq 4*a(1 ...

随机推荐

  1. AJAX 解决什么问题?如何使用AJAX?AJAX 有什么问题需要注意?项目中哪里用到了AJAX?

    ajax 解决的问题就是“无刷新更新页面”,用传统的HTML 表单方式进行页面的更新时,每次都要将请求提交到服务器,服务器返回后再重绘界面,这样界面就会经历:提交→变白→重新显示这样一个过程,用户体验 ...

  2. open还是codecs.open区别

    >>> fr = open('test.txt','a')>>> line1 = "我是一道光">>> fr.write(li ...

  3. Qunar入职前自学笔记

    Q1. 什么是html,html发展历程 hyperText markup language 超文本标记语言 HTML是用于描述网页文档的标记语言.现在我们常常习惯于用数字来描述HTML的版本(如:H ...

  4. shell练习题3

    需求如下: 请按照这样的日期格式(xxxx-xx-xx)每天生成一个文件,例如今天生成的文件为2018-10-19.log, 并把磁盘的使用情况入到这个文件,(不需要写cron,写脚本即可) 参考解答 ...

  5. [Kafka] [All about it]

    Overview 设计目标: 以O(1) 常数级时间复杂度的访问性能,提供消息持久化能力. 高吞吐率. 支持 kafka server 间的消息分区,及分布式消费,同时保证每个partition内部的 ...

  6. L362 When to Bring up Salary During the Job Interview Process

    Money is an awkward topic of conversation for many professionals—even more so when you’re busy tryin ...

  7. 基于ZYNQ的双核启动与通信问题解决

    1    处理器间的通信 为AMP 设计创建应用之前,您需要考虑应用如何进行通信(如有需要).最简单的方法是使用片上存储器.Zynq SoC 配备256KB 的片上SRAM,可从以下四个源地址进行访问 ...

  8. redis学习步骤

    Redis简介 redis全称REmote DIctionary Server,是一个由Salvatore Sanfilippo写的高性能key-value存储系统,其完全开源免费,遵守BSD协议.R ...

  9. Delphi非官方的补丁

    http://git.kngstr.com/KngStr/delphi-fixes 使用方法 方法一: 1. 拷贝需要的补丁文件到你的工程目录 2. 拷贝编译的时候缺少或错误的文件到你的工程目录 优缺 ...

  10. holer实现外网访问本地网站

    外网访问本地网站 本地搭建了网站,只能在局域网内访问,怎样从公网也能访问内网网站? 本文将介绍使用holer实现的具体步骤. 1. 准备工作 1.1 安装并启动网站服务端 默认搭建的网站服务端端口是8 ...