资源简介

使用C#编写的控件,从PictureBox继承,可以设置显示时-分-秒、时-分-秒-毫秒、分-秒...等多种计时方式,还可设置时钟底色、数字前景色、数字消退色等,计时接口简单易用。

资源截图

代码片段和文件信息

using System;
using System.ComponentModel;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.Timers;

using SKY._DigitalScreen;

namespace SKY
{
    namespace _DigitalClock
    {
        public enum Clockstyle
        {
            MilliSecond//毫秒
            Second//秒
            Minute//分钟
            Hour//小时

            Second_MilliSecond//秒-毫秒
            Minute_Second//分钟-秒
            Hour_Minute//小时-分钟

            Minute_Second_MilliSecond//分钟-秒-毫秒
            Hour_Minute_Second//小时-分钟-秒

            Hour_Minute_Second_MilliSecond//小时-分钟-秒-毫秒
        };

        public class DigitalClock : PictureBox
        {
            //constructor
            public DigitalClock(Clockstyle aKind)
            {
                SizeMode = PictureBoxSizeMode.StretchImage;

                Numbers = new int[4];
                for (int i = 0; i < Numbers.Length; i++)
                {
                    Numbers[i] = 0;
                }
                DigitalScr = new DigitalScreen();
                MainTimer = new System.Timers.Timer();

                MainTimer.AutoReset = true;
                MainTimer.Interval = 1;
                MainTimer.Synchronizingobject = this;

                IsActiononclick = false;
                IsCountDown = false;

                Click += new EventHandler(onclickClock);
                MainTimer.Elapsed += new ElapsedEventHandler(OnTick);

                Kind = aKind;

                Image = DrawNumber();
            }
            //destructor
            ~DigitalClock()
            {
            }

            Bitmap DrawNumber()
            {
                string style = ““;
                switch (Kind)
                {
                    case Clockstyle.Hour: style = “1000“; break;
                    case Clockstyle.Hour_Minute: style = “1100“; break;
                    case Clockstyle.Hour_Minute_Second: style = “1110“; break;
                    case Clockstyle.Hour_Minute_Second_MilliSecond: style = “1111“; break;

                    case Clockstyle.Minute: style = “0100“; break;
                    case Clockstyle.Minute_Second: style = “0110“; break;
                    case Clockstyle.Minute_Second_MilliSecond: style = “0111“; break;

                    case Clockstyle.Second: style = “0010“; break;
                    case Clockstyle.Second_MilliSecond: style = “0011“; break;

                    case Clockstyle.MilliSecond: style = “0001“; break;
                }

                ValidDigit = 0;
                for (int i = 0 max = style.Length; i < max; i++)
                {
                    if (style[i] == ‘1‘)
                        ValidDigit++;
                }

                DigitalScr.m_BackColor = ClockBackColor;
                DigitalScr.m_FadeColor = ClockFadeColor;
                DigitalScr.m_ForeColor = Cloc

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      10349  2008-12-23 21:21  数字式电子时钟控件\DigitalClock.cs

     文件      19198  2008-12-23 21:31  数字式电子时钟控件\DigitalScreen.cs

     目录          0  2008-12-24 13:26  数字式电子时钟控件

----------- ---------  ---------- -----  ----

                29547                    3


评论

共有 条评论