做了图形时钟程序.
[color=Red]开发环境:SharpDevelop 3.0[/color][code]
using System;
using System.Drawing;
using System.Windows.Forms;
namespace test2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox_Paint(object sender, PaintEventArgs e)
{
pictureBox1.Refresh();
pset(e);
clock(Color.Khaki, 50, 4, DateTime.Now.Hour, 30, e);
clock(Color.Green, 70, 3, DateTime.Now.Minute, 6, e);
clock(Color.Red, 100, 1, DateTime.Now.Second, 6, e);
}
private void pset(PaintEventArgs e)
{
int c = 100;
int a = 0;
int b = 0;
int clockNum = 0;
string[] num = new string[] {"12","1","2","3","4","5","6","7","8","9","10","11" };
for (int i = 0; i < 360; i+=30)
{
a = (int)(c * Math.Cos(Math.PI * i / 180));
b = (int)(Math.Sin(Math.PI * i / 180) * c);
e.Graphics.DrawString(num[clockNum], this.Font, Brushes.Black, 200 + b - 9, 200 - a - 10);
e.Graphics.DrawString(num[clockNum], this.Font, Brushes.Blue, 200 + b - 12, 200 - a - 12);
clockNum++;
}
}
private void clock(Color color, int r, int width, int dt, int value, PaintEventArgs e)
{
Pen pen = new Pen(color, width);
int c = r;
int a = 0;
int b = 0;
a = (int)(c * Math.Cos(Math.PI * dt * value / 180));
b = (int)(c * Math.Sin(Math.PI * dt * value / 180));
e.Graphics.DrawLine(pen, new Point(200, 200), new Point(200 + b, 200 - a));
}
}
}
[/code]
[img]http://images.cnblogs.com/cnblogs_com/ioriliao/test1.jpg.jpg[/img][attach]37253[/attach]
[[it] 本帖最后由 ioriliao 于 2008-9-23 16:02 编辑 [/it]]
xiejinlong582@163.com 我已发到你邮箱了.我是用的环境vs2008 其实源码就这么几行了... 谢谢!!!
已经收到! buyaoliubai@126.com
非常感谢LZ,LZ辛苦了 redcar911@163.com
多谢楼主,学习1下 有源码吗,谢谢!!! 919728008@qq.com
不胜感激 很多朋友向我索要源码...其实源码就是那几行...既然...
我还是发上来吧... zsf5754@yahoo.com.cn
谢谢楼主 我已经发上这里来了。。。请楼上自行下载哦.... [em01] [tk05] 太好了又學習到了!
感謝樓主教學!
页:
[1]
