zoukankan      html  css  js  c++  java
  • 时间控件

    一个是利用时间控件实现图片的动画的效果,还有一个是考试答题的计时器供你参考

    下面的这段代码是利用时间控件让pictureBOX控件中的图片实现动画效果

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

    namespace MySchool
    {
        public partial class AboutForm : Form
        {
            int index = 0;
            public AboutForm()
            {
                InitializeComponent();
            }

            private void tmrTime_Tick(object sender, EventArgs e)
            {
               
                if (index < ilAbout.Images.Count - 1)
                {
                    index++;
                }
                else
                {
                    index = 0;
                }
                picAbout.Image = ilAbout.Images[index];
            }

    private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
    }

    下面的代码是考试计时器
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace MySchool
    {
        public partial class AnswerCardForm : Form
        {
            public AnswerCardForm()
            {
                InitializeComponent();
            }

            // 计时器的 Tick 事件
            private void tmrCostTime_Tick(object sender, EventArgs e)
            {
                int minute;   // 当前的分钟
                int second;   // 秒

                // 如果还剩有答题时间,就显示剩余的时间
                if (QuizHelper.remainSeconds > 0)
                {
                    minute = QuizHelper.remainSeconds / 60;
                    second = QuizHelper.remainSeconds % 60;
                    lblTimer.Text = string.Format("{0:00}:{1:00}", minute, second);  // 补充知识点
                    QuizHelper.remainSeconds--;
                }
                // 否则,停止计时,提示交卷
                else
                {
                    tmrCostTime.Stop();
                    MessageBox.Show("时间到了,该交卷了!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    QuizResultForm quizResultForm = new QuizResultForm();
                    quizResultForm.Show();
                    this.Close();
                }
            }
  • 相关阅读:
    SQL注入: with rollup特性
    【转】kali配置--修改IP和DNS
    【转】getopt模块,实现获取命令行参数
    socket编程: TypeError: must be bytes or buffer, not str
    Ansible进阶之企业级应用
    Ansible之Playbook详解
    Ansible之常用模块介绍
    JAVA企业级应用Tomcat实战
    ubuntu网络、包管理、工作内容小结
    shell细节决定高度
  • 原文地址:https://www.cnblogs.com/xianyin05/p/1455986.html
Copyright © 2011-2022 走看看