| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 490 人关注过本帖
标题:怎样在下面的电子时钟中添加闹钟功能代码。
取消只看楼主 加入收藏
酱油王6878
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-9-26
收藏
 问题点数:0 回复次数:0 
怎样在下面的电子时钟中添加闹钟功能代码。
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Graphicsuse
{
    public partial class Form1 : Form
    {
        const int s_pinlen = 80;
        const int m_pinlen = 60;
        const int h_pinlen = 50;
        public Form1()
        {
            InitializeComponent();
            label3.Text = "12";
            label6.Text = "6";
            label4.Text = "3";
            label5.Text = "9";
            label7.Text = "10";
            label8.Text = "11";
            label9.Text = "1";
            label10.Text = "2";
            label13.Text = "4";
            label14.Text = "5";
            label11.Text = "8";
            label12.Text = "7";
           
        }
        public void myClock(int h, int m, int s)
        {
            Graphics myGraphics = pictureBox1.CreateGraphics();
            myGraphics.Clear(Color.White);
            Pen mypen = new Pen(Color.Red, 1);
            myGraphics.DrawEllipse(mypen, pictureBox1.ClientRectangle);
            Point CPoint = new Point(pictureBox1.ClientRectangle.Width / 2, pictureBox1.ClientRectangle.Height / 2);

            Point SPoint = new Point((int)(CPoint.X + (Math.Sin(6 * s * Math.PI / 180)) * s_pinlen), (int)(CPoint.Y - (Math.Cos(6 * s * Math.PI / 180)) * s_pinlen));

            Point MPoint = new Point((int)(CPoint.X + (Math.Sin(6 * m * Math.PI / 180)) * m_pinlen), (int)(CPoint.Y - (Math.Cos(6 * m * Math.PI / 180)) * m_pinlen));

            Point HPoint = new Point((int)(CPoint.X + (Math.Sin(((30 * h) + (m / 2)) * Math.PI / 180)) * h_pinlen), (int)(CPoint.Y - (Math.Cos(((30 * h) + (m / 2)) * Math.PI / 180)) * h_pinlen));

            myGraphics.DrawLine(mypen, CPoint, SPoint);
            mypen = new Pen(Color.Green, 2);
            myGraphics.DrawLine(mypen, CPoint, MPoint);
            mypen = new Pen(Color.Black, 4);
            myGraphics.DrawLine(mypen, CPoint, HPoint);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Timer timer = new Timer();
            timer.Tick += new EventHandler(timer1_Tick);
            timer.Enabled = true;
            timer.Interval = 100;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            int y = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int d = DateTime.Now.Day;
            int h = DateTime.Now.Hour;
            int m = DateTime.Now.Minute;
            int s = DateTime.Now.Second;
            myClock(h, m, s);
            label1.Text = y.ToString() + "年" + month.ToString() + "月" + d.ToString() + "日";
            if (s < 10)
            {
                textBox1.Text = h.ToString() + ":" + m.ToString() + ":"+"0" + s.ToString();
            }
            else
            {
                textBox1.Text = h.ToString() + ":" + m.ToString() + ":" + s.ToString();
            }
            string str = DateTime.Now.DayOfWeek.ToString();
            switch (str)
            {
                case "Monday":      str= "星期一";
                    break;
                case "Tuesday":     str= "星期二";
                    break;
                case "Wednesday":   str= "星期三";
                    break;
                case "Thursday":     str="星期四";
                    break;
                case "Friday":       str="星期五";
                    break;
                case "Saturday":     str="星期六";
                    break;
                case "Sunday":      str= "星期日";
                    break;
                default:            str = "error";
                    break;
            }
            label2.Text = str;
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        
    }
}
搜索更多相关主题的帖子: 电子 闹钟 public 
2012-10-29 15:00
快速回复:怎样在下面的电子时钟中添加闹钟功能代码。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050035 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved