• 大小: 114KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-27
  • 语言: C#
  • 标签: C#  时钟  

资源简介

一个用C#绘制的动态时钟自定义控件,可以自由由其他程序调用。

资源截图

代码片段和文件信息

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

namespace clock
{
    public partial class clock : UserControl
    {
        
        int i=DateTime.Now.Secondj=DateTime.Now.Minutek=DateTime.Now.Hour;
        Pen remove = new Pen(Color.Black 1);
        public clock()
        {
            InitializeComponent();
            remove.Color = pictureBox1.BackColor;
        }
        Pen psec = new Pen(Color.Black 1);
        Pen pmin = new Pen(Color.Black 2);
        Pen phour = new Pen(Color.Black 3);
        

        private void timer1_Tick(object sender EventArgs e)
        {
            Graphics g = this.pictureBox1.CreateGraphics();
            i = DateTime.Now.Second+30; j = DateTime.Now.Minute+30; k = DateTime.Now.Hour+12;
            //if (i == 31) g.DrawLine(remove 73 72 Convert.ToInt16(73 - 60 * Math.Sin(Math.PI * (59) / 60 * 2)) Convert.ToInt16(72 + 60 * Math.Cos(Math.PI * (59) / 60 * 2)));
                g.DrawLine(remove 73 72 Convert.ToInt16(73 - 60 * Math.Sin(Math.PI * (i - 1) / 60 * 2)) Convert.ToInt16(72 + 60 * Math.Cos(Math.PI * (i - 1) / 60 * 2)));
            //if (j == 30) g.DrawLine(remove 73 72 Convert.ToInt16(73 - 50 * Math.Sin(Math.PI * (59) / 60 * 2)) Convert.ToInt16(72 + 50 * Math.Cos(Math.PI * (59) / 60 * 2)));
                 g.DrawLine(remove 73 72 Convert.ToInt16(73 - 50 * Math.Sin(Math.PI * (j - 1) / 60 * 2)) Convert.ToInt16(72 + 50 * Math.Cos(Math.PI * (j - 1) / 60 * 2)));
            //if (k == 12) g.DrawLine(remove 73 72 Convert.ToInt16(73 - 40 * Math.Sin((j-30)%60*Math.PI/360+Math.PI * (23) / 24 * 2)) Convert.ToInt16(72 + 40 * Math.Cos((j-30)%60*Math.PI/360+Math.PI * (23) / 24 * 2)));
             g.DrawLine(remove 73 72 Convert.ToInt16(73 - 40 * Math.Sin((j-30)%60*Math.PI/360+Math.PI * (k - 1) / 24 * 2)) Convert.ToInt16(72 + 40 * Math.Cos((j-30)%60*Math.PI/360+Math.PI * (k - 1) / 24 * 2)));
          
            g.DrawLine(psec 73 72 Convert.ToInt16(73 - 60* Math.Sin(Math.PI*(i) / 60 * 2  ))Convert.ToInt16(72 + 60 * Math.Cos(Math.PI*(i) / 60 * 2  )));

            g.DrawLine(psec 73 72 Convert.ToInt16(73 - 50 * Math.Sin(Math.PI * (j) / 60 * 2)) Convert.ToInt16(72 + 50 * Math.Cos(Math.PI * (j) / 60 * 2)));

            g.DrawLine(phour 73 72 Convert.ToInt16(73 - 40 * Math.Sin((j-30)%60*Math.PI/360+Math.PI * (k) / 24 * 2)) Convert.ToInt16(72 + 40 * Math.Cos((j-30)%60*Math.PI/360+Math.PI * (k) / 24 * 2)));
            g.Dispose();
            
        }
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-11-25 15:08  clock\
     目录           0  2012-11-25 15:08  clock\Backup\
     目录           0  2012-11-25 15:08  clock\Backup\Backup\
     目录           0  2012-11-25 15:08  clock\Backup\Backup\clock\
     目录           0  2012-11-25 15:08  clock\Backup\Backup\clock\Properties\
     文件        1321  2012-10-24 17:41  clock\Backup\Backup\clock\Properties\AssemblyInfo.cs
     文件        2832  2012-10-27 21:44  clock\Backup\Backup\clock\Properties\Resources.Designer.cs
     文件        5817  2012-10-27 21:44  clock\Backup\Backup\clock\Properties\Resources.resx
     文件        9359  2012-10-28 00:45  clock\Backup\Backup\clock\UserControl1.Designer.cs
     文件        2682  2012-10-28 00:45  clock\Backup\Backup\clock\UserControl1.cs
     文件        6008  2012-10-28 00:45  clock\Backup\Backup\clock\UserControl1.resx
     文件        2909  2012-10-27 21:44  clock\Backup\Backup\clock\clock.csproj
     文件         904  2012-10-24 17:41  clock\Backup\Backup\clock.sln
     文件       12800  2012-10-27 23:41  clock\Backup\Backup\clock.v11.suo
     文件        5994  2012-11-06 00:53  clock\Backup\UpgradeLog.xml
     文件       24490  2012-11-06 00:53  clock\Backup\UpgradeLog.htm
     目录           0  2012-11-25 15:08  clock\Backup\_UpgradeReport_Files\
     文件        2229  2012-11-06 00:53  clock\Backup\_UpgradeReport_Files\UpgradeReport.css
     文件       22214  2012-07-26 20:25  clock\Backup\_UpgradeReport_Files\UpgradeReport.xslt
     文件         397  2012-11-06 00:53  clock\Backup\_UpgradeReport_Files\UpgradeReport_Error.png
     文件         338  2012-11-06 00:53  clock\Backup\_UpgradeReport_Files\UpgradeReport_Information.png
     文件         381  2012-11-06 00:53  clock\Backup\_UpgradeReport_Files\UpgradeReport_Success.png
     文件         292  2012-11-06 00:53  clock\Backup\_UpgradeReport_Files\UpgradeReport_Warning.png
     目录           0  2012-11-25 15:08  clock\Backup\clock\
     目录           0  2012-11-25 15:08  clock\Backup\clock\Properties\
     文件        1321  2012-10-24 17:41  clock\Backup\clock\Properties\AssemblyInfo.cs
     文件        2850  2012-11-06 00:53  clock\Backup\clock\Properties\Resources.Designer.cs
     文件        5817  2012-10-27 21:44  clock\Backup\clock\Properties\Resources.resx
     文件        9359  2012-10-28 00:45  clock\Backup\clock\UserControl1.Designer.cs
     文件        2682  2012-10-28 00:45  clock\Backup\clock\UserControl1.cs
     文件        6008  2012-10-28 00:45  clock\Backup\clock\UserControl1.resx
............此处省略66个文件信息

评论

共有 条评论