贝赛尔时钟

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Drawing;
using  System.Data;
using  System.Text;
using  System.Windows.Forms;
using  System.Drawing.Drawing2D;

namespace  testgrid
{
    
public partial class BazierClockControl : ClockControl
    
{
        
public BazierClockControl()
        
{
            InitializeComponent();
        }

        
protected override void DrawHourHand(Graphics g, Pen pen)
        
{
            
//base.DrawHourHand(g, pen);
            GraphicsState gs = g.Save();
            g.RotateTransform(360f 
* Time.Hour / 12 + 30f * Time.Minute / 60);
            g.DrawBeziers(pen, 
new Point[] new Point(0,-600),new Point(0,-300),new Point(200,-300),new Point(50,-200),
            
new Point(50,-200),new Point(50,0),new Point(50,0),new Point(50,75),
            
new Point(-50,75),new Point(-50,0),new Point(-50,0),new Point(-50,-200),
            
new Point(-50,-200),new Point(-200,-300),new Point(0,-300),new Point(0,-600)}
);
            g.Restore(gs);
        }

        
protected override void DrawMinuteHand(Graphics g, Pen pen)
        
{
            
//base.DrawMinuteHand(g, pen);
            GraphicsState gs = g.Save();
            g.RotateTransform(360f 
* Time.Minute / 60 + 6f * Time.Second / 60);
            g.DrawBeziers(pen, 
new Point[] new Point(0,-800),new Point(0,-750),new Point(0,-700),new Point(25,-600),
            
new Point(25,-600),new Point(25,0),new Point(25,0),new Point(25,50),
            
new Point(-25,50),new Point(-25,0),new Point(-25,0),new Point(-25,-600),
            
new Point(-25,-600),new Point(0,-700),new Point(0,-750),new Point(0,-800)}
);
            g.Restore(gs);
        }

    }

}

窗体代码
using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;

namespace  testgrid
{
    
public partial class BezierClock : Form
    
{
        BazierClockControl clkctl;
        
public BezierClock()
        
{
            InitializeComponent();
            clkctl 
= new BazierClockControl();
            clkctl.Parent 
= this;
            clkctl.Time 
= DateTime.Now;
            clkctl.Dock 
= DockStyle.Fill;
            clkctl.BackColor 
= Color.Black;
            clkctl.ForeColor 
= Color.White;
            Timer timer 
= new Timer();
            timer.Interval 
= 100;
            timer.Tick 
+= new EventHandler(timer_Tick);
            timer.Start();
        }


        
void timer_Tick(object sender, EventArgs e)
        
{
           
// throw new Exception("The method or operation is not implemented.");
            clkctl.Time = DateTime.Now;
        }

    }

}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值