ToolKit/ucTimeClock.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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

namespace TQ.ToolKit
{
    /// <summary>
    /// 时钟
    /// </summary>
    public partial class ucTimeClock : UserControl
    {
        #region 概念说明
        /* 参考:http://www.cnblogs.com/yelanggu/p/6224587.html
         * 1、自定义控件与用户控件区别
         *      WinForm中,用户控件(User Control):继承自 UserControl,主要用于开发 Container 控件,Container控件可以添加其他Controls控件
         *      自定义控件(Custom Control):继承自 Control,主要用于开发windows控件的最基本的类,比如 Text,Button 控件
         * 2、要开发自己的控件的几种方法[1]
         *      复合控件(Composite Controls):将现有的各种控件组合起来,形成一个新的控件,来满足用户的需求。
         *      扩展控件(Extended Controls):就是在现有的控件基础上,派生出一个新的控件,增加新的功能,或者修改原有功能,来满足用户需求。
         *      自定义控件(Custom Controls):就是直接从System.Windows.Forms.Control类派生,也就是说完全由自己来设计、实现一个全新的控件,这是最灵活、最强大的方法,但是,对开发者的要求也是最高的。要实现一个自定义控件,必须为Control类的的OnPaint事件编写代码,在OnPaint事件中实现自定义控件的绘制工作。同时,还可以重写Control类的WndProc方法,来处理底层的Windows消息。所以说,要实现一个自定义控件,对开发者的要求较高,要求开发者必须了解GDI+和Windows API的知识。
         */
        #endregion

        #region fields
        DateTime Time = default(DateTime);
        bool b = true;
        #endregion

        public ucTimeClock()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Time = DateTime.Now;
            Refresh();//每秒刷新界面
        }

        #region draw clock
        /// <summary>
        /// 绘制钟表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserClock_Paint(object sender, PaintEventArgs e)
        {
            //获取绘画图面
            Graphics grfx = e.Graphics;
            //创建绘制线条的画笔:使用显示界面的前景色作为线条颜色
            Pen pn = new Pen(ForeColor);
            //创建填充刷,用于颜色填充
            SolidBrush br = new SolidBrush(ForeColor);
后面还有 89 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。