using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace 指针实验
{
public partial class Form1 : Form
{
Graphics g;
int x, y, x1, y1;//计算表盘时用
int xs, ys, xm, ym, xh, yh;//分别代表秒针分针时针位置
int xsl, ysl, xml, yml, xhl, yhl;//记录上一状态
int r = 40; // 半径
Point p;
//= new Point(100, 100);// 圆心位置
Pen penSecond, penSecondLast, penMinute, penMinuteLast, penHour, penHourLast;
Color colorBackground = Color.White;
bool click;
int mouse_x;
int mouse_y;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
g = this.CreateGraphics();
this.TopMost = true;
label1.Text = DateTime.Now.ToString();
p = new Point(this.Width / 2, this.Height / 2 + 2);
int second = DateTime.Now.Second;
int minute = DateTime.Now.Minute;
i

这是一个使用C#编写的指针时钟程序,通过Graphics类绘制秒针、分针和时针。代码中利用Math库计算角度并转换为坐标,动态更新指针位置,实现了实时显示时间的功能。同时,程序还包含鼠标拖动窗口位置的交互设计。
最低0.47元/天 解锁文章
368

被折叠的 条评论
为什么被折叠?



