• 时间控件


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

    下面的这段代码是利用时间控件让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();
                }
            }
  • 相关阅读:
    一个2核1G内存的服务器能做什么
    产品能力是一种底层能力
    利用容器逃逸实现远程登录k8s集群节点
    边缘计算k8s集群SuperEdge初体验
    LeetCode
    RSA加密
    RSA加密
    LeetCode
    LeetCode
    双端队列
  • 原文地址:https://www.cnblogs.com/xianyin05/p/1455986.html
Copyright © 2020-2023  润新知