写一个简单的小时钟

Jophoenix 2010-11-17 03:01:58
小弟初学c#,作业是写个小时钟,我想把form窗体弄成圆形然后在里边添加个表盘的背景图片,另外如果用Invalidate();方法的话,表盘就会不停的闪,有没有可以代替的方法实现同样的功能?求助!
...全文
89 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
HaveOneDream 2010-11-17
  • 打赏
  • 举报
回复
用GDI+画图
双缓冲可解决闪烁
Jophoenix 2010-11-17
  • 打赏
  • 举报
回复
对了 这是我form里的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 时钟
{
public partial class Form1 : Form
{
Pointer[] pts;
public Form1()
{
InitializeComponent();
int widthSize = this.ClientSize.Width / 2;
int heightSize = this.ClientSize.Height / 2;
pts = new Pointer[3];
Point start = new Point(widthSize, heightSize);
pts[0] = new SecondPointer(widthSize,new Pen(Color.Red, 1.5f),start);
pts[1] = new HourPointer(widthSize*0.6, new Pen(Color.Black, 3.0f), start);
pts[2] = new MinutePoniter((widthSize*0.75), new Pen(Color.Blue, 2.0f), start);
}
private void timer1_Tick(object sender, EventArgs e)
{
foreach (Pointer pt in pts )
{
pt.Move();
}
this.Invalidate();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
foreach(Pointer pt in pts )
{
pt.show(e.Graphics);
}
}

private void load(object sender, EventArgs e)
{

}
}
}

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧