资源简介
简单的c#程序实现满天星,美观大方,初学者,一看就懂了,主要用了panle控件。加上一些简单的数组知识,
代码片段和文件信息
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 Case03_4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int s_pinlen = 100; //时针
const int m_pinlen = 75; //分针
const int h_pinlen = 50; //秒针
private void myClock(int h int m int s)
{
Graphics myGraphics = pictureBox1.CreateGraphics(); //创建Graphics对象实例
myGraphics.Clear(Color.White); //设置背景色为白色
Pen myPen = new Pen(Color.Black 1); //设置画笔的颜色和宽度
myGraphics.DrawEllipse(myPen pictureBox1.ClientRectangle); //绘制椭圆
Point CPoint = new Point(pictureBox1.ClientRectangle.Width / 2 pictureBox1.ClientRectangle.Height / 2);
Point SPoint = new Point((int)(CPoint.X + (Math.Sin(6 * s * Math.PI / 180)) * s_pinlen) (int)(CPoint.Y - (Math.Cos(6 * s * Math.PI / 180)) * s_pinlen));
Point MPoint = new Point((int)(CPoint.X + (Math.Sin(6 * m * Math.PI / 180)) * m_pinlen) (int)(CPoint.Y - (Math.Cos(6 * m * Math.PI / 180)) * m_pinlen));
Point HPoint = new Point((int)(CPoint.X + (Math.Sin(((30 * h) + (m / 2)) * Math.PI / 180)) * h_pinlen) (int)(CPoint.Y - (Math.Cos(((30 * h) + (m / 2)) * Math.PI / 180)) * h_pinlen));
myGraphics.DrawLine(myPen CPoint SPoint); //绘制直线
myPen = new Pen(Color.Black 2);
myGraphics.DrawLine(myPen CPoint MPoint);
myPen = new Pen(Color.Black 4);
myGraphics.DrawLine(myPen CPoint HPoint);
}
private void Form1_Load(object sender EventArgs e)
{
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender EventArgs e)
{
int h = DateTime.Now.Hour;
int m = DateTime.Now.Minute;
int s = DateTime.Now.Second;
myClock(h m s);
this.Text = “现在的时间是:“ + h.ToString() + “:“ + m.ToString() + “:“ + s.ToString();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 914 2008-06-06 21:44 Case03_4\Case03_4.sln
文件 16384 2008-06-06 22:32 Case03_4\Case03_4.suo
目录 0 2015-07-11 14:56 Case03_4\Case03_4\
目录 0 2015-07-11 14:56 Case03_4\Case03_4\bin\
目录 0 2015-07-11 14:56 Case03_4\Case03_4\bin\Debug\
文件 12288 2008-06-06 22:02 Case03_4\Case03_4\bin\Debug\Case03_4.exe
文件 26112 2008-06-06 22:02 Case03_4\Case03_4\bin\Debug\Case03_4.pdb
文件 14328 2008-06-06 22:25 Case03_4\Case03_4\bin\Debug\Case03_4.vshost.exe
文件 490 2007-07-21 01:33 Case03_4\Case03_4\bin\Debug\Case03_4.vshost.exe.manifest
文件 3762 2008-06-06 21:59 Case03_4\Case03_4\Case03_4.csproj
文件 2406 2008-06-06 22:02 Case03_4\Case03_4\Form1.cs
文件 11687 2008-06-06 21:55 Case03_4\Case03_4\Form1.Designer.cs
文件 6008 2008-06-06 21:55 Case03_4\Case03_4\Form1.resx
目录 0 2015-07-11 14:56 Case03_4\Case03_4\obj\
目录 0 2015-07-11 14:56 Case03_4\Case03_4\obj\Debug\
文件 995 2008-06-06 22:25 Case03_4\Case03_4\obj\Debug\Case03_4.csproj.FileListAbsolute.txt
文件 847 2008-06-06 21:59 Case03_4\Case03_4\obj\Debug\Case03_4.csproj.GenerateResource.Cache
文件 12288 2008-06-06 22:02 Case03_4\Case03_4\obj\Debug\Case03_4.exe
文件 180 2008-06-06 22:00 Case03_4\Case03_4\obj\Debug\Case03_4.Form1.resources
文件 26112 2008-06-06 22:02 Case03_4\Case03_4\obj\Debug\Case03_4.pdb
文件 180 2008-06-06 22:00 Case03_4\Case03_4\obj\Debug\Case03_4.Properties.Resources.resources
目录 0 2008-06-06 21:44 Case03_4\Case03_4\obj\Debug\TempPE\
文件 489 2008-06-06 21:44 Case03_4\Case03_4\Program.cs
目录 0 2015-07-11 14:56 Case03_4\Case03_4\Properties\
文件 1372 2008-06-06 21:44 Case03_4\Case03_4\Properties\AssemblyInfo.cs
文件 2866 2008-06-06 21:44 Case03_4\Case03_4\Properties\Resources.Designer.cs
文件 5612 2008-06-06 21:44 Case03_4\Case03_4\Properties\Resources.resx
文件 1093 2008-06-06 21:44 Case03_4\Case03_4\Properties\Settings.Designer.cs
文件 249 2008-06-06 21:44 Case03_4\Case03_4\Properties\Settings.settings
- 上一篇:图像清晰度评价55642
- 下一篇:24路舵机控制板C#源码
评论
共有 条评论