using
System
.
Collections
.
Generic
;
using
System
.
ComponentModel
;
using
System
.
Data
;
using
System
.
Drawing
;
using
System
.
Linq
;
using
System
.
Text
;
using
System
.
Threading
.
Tasks
;
using
System
.
Drawing
.
Drawing2D
;
using
System
.
Windows
.
Forms
;
namespace
_7_1
public
partial
class
Form1
:
Form
int
s_p
=
140
,
m_p
=
110
,
h_p
=
80
;
public
Form1
(
)
InitializeComponent
(
)
;
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
this
.
Text
=
"模拟时钟"
;
void
mycolock
(
)
Graphics
graphics
=
pictureBox1
.
CreateGraphics
(
)
;
graphics
.
Clear
(
Color
.
White
)
;
Pen
mypen
=
new
Pen
(
Color
.
Black
,
2
)
;
graphics
.
DrawEllipse
(
mypen
,
pictureBox1
.
ClientRectangle
)
;
int
h
=
DateTime
.
Now
.
Hour
;
int
m
=
DateTime
.
Now
.
Minute
;
int
s
=
DateTime
.
Now
.
Second
;
Point
C
=
new
Point
(
pictureBox1
.
ClientRectangle
.
Width
/
2
,
pictureBox1
.
Height
/
2
)
;
Point
S
=
new
Point
(
(
int
)
(
C
.
X
+
(
Math
.
Sin
(
6
*
s
*
Math
.
PI
/
180
)
)
*
s_p
)
,
(
int
)
(
C
.
Y
-
(
Math
.
Cos
(
6
*
s
*
Math
.
PI
/
180
)
)
*
s_p
)
)
;
Point
M
=
new
Point
(
(
int
)
(
C
.
X
+
(
Math
.
Sin
(
6
*
m
*
Math
.
PI
/
180
)
)
*
m_p
)
,
(
int
)
(
C
.
Y
-
(
Math
.
Cos
(
6
*
m
*
Math
.
PI
/
180
)
)
*
m_p
)
)
;
Point
H
=
new
Point
(
(
int
)
(
C
.
X
+
(
Math
.
Sin
(
(
(
30
*
h
)
+
m
/
2
)
*
Math
.
PI
/
180
)
)
*
h_p
)
,
(
int
)
(
C
.
Y
-
(
Math
.
Cos
(
(
30
*
h
+
(
m
/
2
)
)
*
Math
.
PI
/
180
)
)
*
h_p
)
)
;
graphics
.
DrawLine
(
mypen
,
C
,
S
)
;
mypen
=
new
Pen
(
Color
.
Black
,
3
)
;
graphics
.
DrawLine
(
mypen
,
C
,
M
)
;
mypen
=
new
Pen
(
Color
.
Black
,
4
)
;
graphics
.
DrawLine
(
mypen
,
C
,
H
)
;
GraphicsState
state
=
graphics
.
Save
(
)
;
state
=
graphics
.
Save
(
)
;
int
dialRadius
=
Math
.
Min
(
C
.
X
,
C
.
Y
)
;
Font
hourFont
=
new
Font
(
"Arial"
,
10
,
FontStyle
.
Bold
)
;
Brush
brush
=
new
SolidBrush
(
Color
.
Black
)
;
for
(
int
i
=
0
;
i
<
60
;
i
++
)
string
dian
=
"."
;
if
(
i
%
5
==
0
)
dian
=
""
;
Point
point
=
new
Point
(
-
6
,
-
6
)
;
double
dd
=
Math
.
PI
/
180
*
i
*
(
360
/
60
)
;
float
x
=
point
.
X
+
(
float
)
(
(
dialRadius
-
12
)
*
Math
.
Cos
(
dd
)
)
;
float
y
=
point
.
Y
+
(
float
)
(
(
dialRadius
-
12
)
*
Math
.
Sin
(
dd
)
)
;
graphics
.
DrawString
(
dian
,
hourFont
,
brush
,
x
+
175
,
y
+
160
)
;
graphics
.
Restore
(
state
)
;
state
=
graphics
.
Save
(
)
;
for
(
int
i
=
0
;
i
<
12
;
i
++
)
Point
point
=
new
Point
(
-
6
,
-
6
)
;
double
dd
=
Math
.
PI
/
180
*
i
*
(
360
/
12
)
;
float
x
=
point
.
X
+
(
float
)
(
(
dialRadius
-
12
)
*
Math
.
Cos
(
dd
)
)
;
float
y
=
point
.
Y
+
(
float
)
(
(
dialRadius
-
12
)
*
Math
.
Sin
(
dd
)
)
;
int
j
=
i
+
3
;
if
(
j
>
12
)
j
=
j
-
12
;
graphics
.
DrawString
(
j
.
ToString
(
)
,
hourFont
,
brush
,
x
+
175
,
y
+
160
)
;
graphics
.
Restore
(
state
)
;
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
this
.
toolStripStatusLabel1
.
Text
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd hh:mm:ss"
)
;
mycolock
(
)
;
一、在STM32中,有五个
时钟
源,为HSI、HSE、LSI、LSE、PLL。①HSI是高速内部
时钟
,RC振荡器,频率为8MHz。②HSE是高速外部
时钟
,可接石英/陶瓷谐振器,或者接外部
时钟
源,频率范围为4MHz~16MHz。③LSI是低速内部
时钟
,RC振荡器,频率为40kHz。④LSE是低速外部
时钟
,接频率为32.768kHz的石英晶体。⑤PLL为锁相环倍频输出,其
时钟
输入源可选择为HS...
用
C#
写的闹钟应用程序。个人特色:1、可以这么所说,别人有的功能,我有!别人没有的功能,我也有!2、代码详细,基本上每一条稍微重要点的代码都有注释这行代码是干嘛的,所以你可以看到好多好多注释,详细的不能再详细!源代码下载地址:http://download.csdn.net/download/luochao5862426/10124237里面包含,可导入的项目文件、该程序的PPT展示以及录制的视频...
int iHour = DateTime.Now.Hour;
int iMin = DateTime.Now.Minute;
int iSec = DateTime.Now.Second;
// Format the current time into a string...
sTime = (iHour < 10) ? "0" + iHour.ToString() : iHour.ToString();
sTime += ":" + ( (iMin < 10) ? "0" + iMin.ToString() : iMin.ToString() );
sTime += ":" + ( (iSec < 10) ? "0" + iSec.ToString() : iSec.ToString() );
return sTime;
VisualStudio2008创建
画一个
时钟
不一定要用到三角函数,今天在网上发现了一个极好的方法,避免了三角函数计算的误差,比较靠谱。
具体是通过依次旋转坐标轴,使坐标轴的Y轴分别和时针、分针、
秒针
在一条直线上,这样DrawLine的两端都在Y轴上了。
效果图如下:
代码如下:
using System;
using System.Collections.Generic;
using System.Componen
现在使用的还是XP的系统,每次看到数字显示的
时钟
总是不直观,于是做了一个仿Win7效果的桌面
时钟
,表盘使用的是图片,美工好的朋友可以自己换一个表盘背景。
代码只有一百多行(主要是画表针),适合新接触GDI+的朋友练手用,可固定在桌面,由于程序画的是圆型的表盘,弄一个关闭按钮不好看,所以要用alt+F4关闭,常驻内存14M(连续使用一星期测得)。
这个和我之前传过的一个日历是一套的,我是这么用的。也可以把它做成一个自定义控件,放在程序中使用。
c#
时钟
In this tutorial we are going to use a bit of graphics class to design a
C#
analog clock. We have also used a timer to continuously move our clock’s pointer.
2.
动态
时钟
首先我们就需要一个时间线程来对齐进行
动态
管理。在窗体的加载事件中添加时间线程,时间间隔设置为1秒执行一次,并且将触发事件添加给Elapsed,线程的声明放在事件之外。
System.Timers.Timer Time = new System.Timers.Timer();
private void Form1_Load(object sender, EventArgs e)
用
C#
写的闹钟应用程序。到处都是注释,一看就懂!
核心代码和效果展示见我的博客:http://blog.csdn.net/luochao5862426/article/details/78570141
个人特色:
1、可以这么所说,别人有的,我有!别人没有的,我也有。集百家之长,选我就对了,嘿嘿。
2、代码详细,基本上每一条稍微重要点的代码都有注释这行代码是干嘛的,所以你可以看到好多好多注释,详细的不能再详细!
3、里面包含,可直接导入的项目文件、该程序的PPT展示以及录制的视频展示。
4、模块清晰,注释详细,低耦合,高内聚。
主页面介绍:分三个部分
一、
动态
时钟
部分,像石英钟一样时、分、
秒针
不停转动。
二、定点闹钟部分,简单点就是可以定闹钟。
三、闹钟备忘录部分,显而易见,为了添加提示功能。
本人设计了两种可选模式:
1、懒人模式(可多次延时响铃,下面主要讲述这个模式)
2、生存模式(本次考验失败后则下次的闹钟提前几分钟响铃。由于时间有限本人没去实现这个功能)
主要功能介绍:
一、
时钟
(石英钟)
1、使用
C#
的GDI+画出石英钟时、分、
秒针
不停转动的效果并加上了指针的尾巴。
1、定闹钟时添加备注。
2、自选(默认铃声或本地铃声)试听铃声。所以机智的你可以当一个MP3用了。
3、设定多个闹钟。重点是,你可以设置不同类型(今天、每天、自定义星期、指定日期)的闹钟。
4、设定不同的响铃方式。包括:只响一次、不断响铃、静音响铃。
5、定时关机。定闹钟的时候选择了定时关机这个选项,那么,在闹钟到点后的一定时间内(我设置的3秒)会自动关机。
6、开机自启动。这个可以自己设定,很多人不需要。
7、响铃抖屏。闹钟到点后会抖动一小段时间(我设置的3秒)的屏幕,并同步跳到你打开的所有窗口的最顶层窗体。
8、系统托盘。可以隐藏到系统托盘。
三、备忘录
{备忘录组成:时段+时间+备注+尾巴(可删除,知识为了查看有哪些操作)}
1、移除所定的闹钟。
2、把闹钟备忘录保存至本地。
3、从本地导入至闹钟备忘录。所以你可以在本地修改备忘录咯,包括时间和内容。
4、修改闹钟备忘录内容。在程序界面修改备忘录。
5、查找备忘录内容。在程序界面查找备忘录内容。
6、显示倒计时。你在定闹钟的时候要是选了倒计时这个选项,则你可以在备忘录里面选中,显示倒计时。