private void timer1_Tick(object sender, EventArgs e)
{
this.Time = DateTime.Now;
Refresh();
}
#region draw clock
private void UserClock_Paint(object sender, PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen pn = new Pen(ForeColor);
SolidBrush br = new SolidBrush(ForeColor);
initCoordinates(dc);
DrawDots(dc, br);
DrawHourHand(dc, pn);
DrawSecondHand(dc, pn);
DrawMinuteHand(dc, pn);
}
public void initCoordinates(Graphics dc)
{
if (this.Width == 0 || this.Height == 0) return;
dc.TranslateTransform(this.Width / 2, this.Height / 2);
dc.ScaleTransform(this.Height / 250F, this.Width / 250F);
}
public void DrawDots(Graphics dc, Brush brush)
{
int iSize;
for (int i = 0; i <= 59; i++)
{
if (i % 5 == 0)
{
iSize = 15;
}
else
{
iSize = 5;
}
dc.FillEllipse(brush, -iSize / 2, -100 - iSize / 2, iSize, iSize);
dc.RotateTransform(6);
}
}
public virtual void DrawHourHand(Graphics grfx, Pen pn)
{
GraphicsState gs = grfx.Save();
grfx.RotateTransform(360.0F * Time.Hour / 12 + 30.0F * Time.Minute / 60);
grfx.DrawLine(pn, 0, 0, 0, -50);
grfx.Restore(gs);
}
public virtual void DrawMinuteHand(Graphics grfx, Pen pn)
{
GraphicsState gs = grfx.Save();
grfx.RotateTransform(360.0F * Time.Minute / 60 + 6.0F * Time.Second / 60);
grfx.DrawLine(pn, 0, 0, 0, -70);
grfx.Restore(gs);
}
public virtual void DrawSecondHand(Graphics grfx, Pen pn)
{
GraphicsState gs = grfx.Save();
grfx.RotateTransform(360.0F * Time.Second / 60);
grfx.DrawLine(pn, 0, 0, 0, -100);
grfx.Restore(gs);
}
#endregion
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有