| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 642 人关注过本帖
标题:[讨论]怎样用画圆的方式画出系统时间?
只看楼主 加入收藏
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
结帖率:100%
收藏
 问题点数:0 回复次数:3 
[讨论]怎样用画圆的方式画出系统时间?
怎样以我发的图片的那种方式显示系统时间???请各位大侠赐教!
图片附件: 游客没有浏览图片的权限,请 登录注册

[此贴子已经被作者于2006-8-24 11:19:20编辑过]

搜索更多相关主题的帖子: 系统 时间 讨论 
2006-08-24 08:07
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
搜索    玉兰时钟 C# 源代码
2006-08-24 10:12
mylover624
Rank: 1
来 自:乖乖的心中
等 级:新手上路
帖 子:868
专家分:0
注 册:2006-7-6
收藏
得分:0 
[CODE]

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

namespace WindowsDowing
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Clock : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;

private Point s = new Point(0,0);
private Point m = new Point(0,0);
private Point h = new Point(0,0);
private bool drop = false;
private System.Windows.Forms.Label label1;
private Point Ds = new Point(0,0);

public Clock()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Clock));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label1
//
this.label1.ForeColor = System.Drawing.Color.Blue;
this.label1.Location = new System.Drawing.Point(8, 136);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(184, 24);
this.label1.TabIndex = 0;
this.label1.Text = "http://xinxinyi.xinwen365.com/Info/Index.htm";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.Click += new System.EventHandler(this.label1_Click);
this.label1.MouseEnter += new System.EventHandler(this.label1_MouseEnter);
this.label1.MouseLeave += new System.EventHandler(this.label1_MouseLeave);
//
// Clock
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(202, 202);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(202, 202);
this.MinimumSize = new System.Drawing.Size(202, 202);
this.Name = "Clock";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
this.Load += new System.EventHandler(this.Form1_Load);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Clock());
}

private void timer1_Tick(object sender, System.EventArgs e)
{
int tmpX=0,tmpY=0;
//秒
int sa = this.GetAngle(System.DateTime.Now.Second);
tmpX = Convert.ToInt32(70*Math.Cos(this.GetArc(sa)));
tmpY = Convert.ToInt32(70*Math.Sin(this.GetArc(sa)));
s.X = 100+tmpX;
s.Y = 100+tmpY;
//分
sa = this.GetAngle(System.DateTime.Now.Minute);
tmpX = Convert.ToInt32(60*Math.Cos(this.GetArc(sa)));
tmpY = Convert.ToInt32(60*Math.Sin(this.GetArc(sa)));
m.X = 100+tmpX;
m.Y = 100+tmpY;
//時
double dbA = Math.Abs(System.DateTime.Now.Hour - 12 + (System.DateTime.Now.Minute/60.0))/12.0 * 60;
sa = this.GetAngle(Convert.ToInt32(dbA));
tmpX = Convert.ToInt32(50*Math.Cos(this.GetArc(sa)));
tmpY = Convert.ToInt32(50*Math.Sin(this.GetArc(sa)));
h.X = 100+tmpX;
h.Y = 100+tmpY;

if(this.label1.Tag.ToString()=="0")
this.label1.Text = System.DateTime.Now.ToString("HH:mm:ss");
this.Refresh();
}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Pen myPen = new Pen(Color.Red);
e.Graphics.DrawEllipse(myPen,s.X-1,s.Y-1,2,2);
e.Graphics.DrawEllipse(myPen,m.X-2,m.Y-2,3,3);
e.Graphics.DrawEllipse(myPen,h.X-2,h.Y-2,3,3);

myPen = new Pen(Color.Red);
e.Graphics.DrawEllipse(myPen,100-1,100-1,2,2);
myPen = new Pen(Color.Red);
e.Graphics.DrawEllipse(myPen,100-2,100-2,4,4);
myPen = new Pen(Color.AliceBlue);
e.Graphics.DrawEllipse(myPen,0,0,200,200);

myPen = new Pen(Color.GreenYellow,1);
e.Graphics.DrawLine(myPen,new Point(100,100),s);
myPen = new Pen(Color.GreenYellow,2);
e.Graphics.DrawLine(myPen,new Point(100,100),m);
myPen = new Pen(Color.GreenYellow,3);
e.Graphics.DrawLine(myPen,new Point(100,100),h);

e.Graphics.DrawString(System.DateTime.Now.ToString("hh:mm:ss"),new System.Drawing.Font("宋体",10),new SolidBrush(Color.Black),50,210);

}
private int GetAngle(int timeNum)
{
return 360 - Math.Abs((( timeNum < 15) ? timeNum - 15 : timeNum - 75 )) * 6;
}
private double GetArc(int angle)
{
return angle * 3.14159265 / 180;
}

private void Form1_Load(object sender, System.EventArgs e)
{
this.label1.Tag = "0";
timer1_Tick(this.timer1,null);
System.Drawing.Drawing2D.GraphicsPath myGrap = new System.Drawing.Drawing2D.GraphicsPath();
myGrap.AddEllipse(new Rectangle(0,0,200,198));

this.Region = new Region(myGrap);
this.TopMost = true;
}

private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.drop = false;
}


private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(this.drop)
{
this.Left = this.Left - this.Ds.X+e.X;
this.Top = this.Top - this.Ds.Y+e.Y;
}
}

private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyData == Keys.Escape)
this.Close();
}

private void label1_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("http://xinxinyi.xinwen365.com/Info/Index.htm");
}

private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.drop = true;
this.Ds.X=e.X;
this.Ds.Y=e.Y;
}

private void label1_MouseEnter(object sender, System.EventArgs e)
{

this.label1.Text = "http://xinxinyi.xinwen365.com/Info/Index.htm";
this.label1.Tag="1";
}

private void label1_MouseLeave(object sender, System.EventArgs e)
{
this.label1.Text=System.DateTime.Now.ToString("HH:mm:ss");
this.label1.Tag="0";
}
}
}

[/CODE]

一个天才顶不上十个笨蛋!
书山有路勤为径,学海无涯友相伴。
我的E-mail:mylover624@.cn
2006-08-24 11:07
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 
谢谢,这个是可以画出时钟,但是我说的用圆点可以实现吗?
你有没有看到我发的图片?
要按那上面的效果显示,帮帮忙,老大催得紧!

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2006-08-24 11:14
快速回复:[讨论]怎样用画圆的方式画出系统时间?
数据加载中...
 
   



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

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