窗体设计代码:[Form1.Designer.cs]
namespace
Game_One
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
partial class Form1
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if (disposing && (components != null))
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
components.Dispose();
}
base.Dispose(disposing);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/7ff8d92cded7e0ce15e7ca1acc870052.gif)
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.ClockPanel = new System.Windows.Forms.Panel();
this.PicBox = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.TimeBox = new System.Windows.Forms.TextBox();
this.CheckBtn = new System.Windows.Forms.Button();
this.AnswerBtn = new System.Windows.Forms.Button();
this.NameLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.PicBox)).BeginInit();
this.SuspendLayout();
//
// ClockPanel
//
this.ClockPanel.BackColor = System.Drawing.Color.Transparent;
this.ClockPanel.ForeColor = System.Drawing.Color.Transparent;
this.ClockPanel.Location = new System.Drawing.Point(12, 95);
this.ClockPanel.Name = "ClockPanel";
this.ClockPanel.Size = new System.Drawing.Size(498, 498);
this.ClockPanel.TabIndex = 0;
//
// PicBox
//
this.PicBox.BackColor = System.Drawing.Color.Transparent;
this.PicBox.Location = new System.Drawing.Point(516, 95);
this.PicBox.Name = "PicBox";
this.PicBox.Size = new System.Drawing.Size(488, 498);
this.PicBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.PicBox.TabIndex = 1;
this.PicBox.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("隶书", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.ForeColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(327, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(404, 48);
this.label1.TabIndex = 2;
this.label1.Text = "你能认出他们吗?";
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("新宋体", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(140, 647);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(194, 27);
this.label2.TabIndex = 3;
this.label2.Text = "他/她的时间:";
//
// TimeBox
//
this.TimeBox.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.TimeBox.Location = new System.Drawing.Point(317, 647);
this.TimeBox.Name = "TimeBox";
this.TimeBox.Size = new System.Drawing.Size(123, 26);
this.TimeBox.TabIndex = 1;
this.TimeBox.TextChanged += new System.EventHandler(this.TimeBox_TextChanged);
//
// CheckBtn
//
this.CheckBtn.Font = new System.Drawing.Font("宋体", 14F);
this.CheckBtn.Location = new System.Drawing.Point(466, 648);
this.CheckBtn.Name = "CheckBtn";
this.CheckBtn.Size = new System.Drawing.Size(96, 27);
this.CheckBtn.TabIndex = 2;
this.CheckBtn.Text = "确 定";
this.CheckBtn.UseVisualStyleBackColor = true;
this.CheckBtn.Click += new System.EventHandler(this.CheckBtn_Click);
//
// AnswerBtn
//
this.AnswerBtn.Font = new System.Drawing.Font("宋体", 14F);
this.AnswerBtn.Location = new System.Drawing.Point(587, 648);
this.AnswerBtn.Name = "AnswerBtn";
this.AnswerBtn.Size = new System.Drawing.Size(96, 27);
this.AnswerBtn.TabIndex = 3;
this.AnswerBtn.Text = "答 案";
this.AnswerBtn.UseVisualStyleBackColor = true;
this.AnswerBtn.Click += new System.EventHandler(this.AnswerBtn_Click);
//
// NameLabel
//
this.NameLabel.AutoSize = true;
this.NameLabel.BackColor = System.Drawing.Color.Transparent;
this.NameLabel.Font = new System.Drawing.Font("新宋体", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.NameLabel.ForeColor = System.Drawing.Color.Transparent;
this.NameLabel.Location = new System.Drawing.Point(746, 645);
this.NameLabel.Name = "NameLabel";
this.NameLabel.Size = new System.Drawing.Size(124, 27);
this.NameLabel.TabIndex = 4;
this.NameLabel.Text = "姓名答案";
this.NameLabel.Visible = false;
//
// Form1
//
this.AcceptButton = this.CheckBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(1016, 734);
this.Controls.Add(this.NameLabel);
this.Controls.Add(this.AnswerBtn);
this.Controls.Add(this.CheckBtn);
this.Controls.Add(this.TimeBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.PicBox);
this.Controls.Add(this.ClockPanel);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "热线(北京)通信技术有限公司";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
((System.ComponentModel.ISupportInitialize)(this.PicBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
#endregion
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private System.Windows.Forms.Panel ClockPanel;
private System.Windows.Forms.PictureBox PicBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox TimeBox;
private System.Windows.Forms.Button CheckBtn;
private System.Windows.Forms.Button AnswerBtn;
private System.Windows.Forms.Label NameLabel;
}
}
程序资源文件就不贴了,就是一张图片
程序实现代码:[Form1.cs]
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
System.Configuration;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
namespace
Game_One
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
public partial class Form1 : Form
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
private DateTime DT = new DateTime();
private Image ImgBak = Image.FromFile(ConfigurationManager.AppSettings["BackGroundImage"].ToString());
System.IO.MemoryStream MEM = new System.IO.MemoryStream();
bool Saved = false;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
public Form1()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
InitializeComponent();
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
if (!Saved)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
ImgBak.Save(MEM, System.Drawing.Imaging.ImageFormat.Jpeg);
Saved = true;
}
TimeBox.Focus();
PicBox.Visible = false;
}
private void AnswerBtn_Click(object sender, EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
NameLabel.Text = ConfigurationManager.AppSettings[PicIndex.ToString()].ToString();
NameLabel.Visible = true;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void DrawClock(Graphics g, Rectangle Rect)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
//g.Clear(Color.Empty);
Point L = ClockPanel.Location;
Point A_1 = new Point(0-L.X, 0-L.Y);
Point A_2 = new Point(A_1.X + ClockPanel.Width, A_1.Y);
Point A_3 = new Point(A_1.X, A_1.Y + ClockPanel.Height);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] A = new Point[] ...{ A_1, A_2, A_3 };
Point B_1 = new Point(0, 0);
Point B_2 = new Point(ClockPanel.Width, 0);
Point B_3 = new Point(0, ClockPanel.Height);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] B = new Point[] ...{B_1,B_2,B_3 };
Rectangle NewRect = new Rectangle(L.X, L.Y, ClockPanel.Width, ClockPanel.Height);
g.DrawImage(ImgBak, B, NewRect, GraphicsUnit.Pixel);
//绘制圆周
Pen RedPen = new Pen(Color.Red, 3);
g.DrawEllipse(RedPen, 7, 7, 480, 480);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
Point Center = new Point(247, 247);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//绘制钟点
Pen PPen_Ora = new Pen(Color.Blue, 4);
Pen PPen_Special = new Pen(Color.Red, 5);
int SidePoint_X;
int SidePoint_Y;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
int MovePoint_X;
int MovePoint_Y;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
for (int i = 1; i <= 60; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
SidePoint_X = 247 + (int)(Math.Sin(Math.PI / 180 * i * 6) * 240);
SidePoint_Y = 247 + (int)(Math.Cos(Math.PI / 180 * i * 6) * 240);
if (i % 5 == 0)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
MovePoint_X = 247 + (int)(Math.Sin(Math.PI / 180 * i * 6) * 220);
MovePoint_Y = 247 + (int)(Math.Cos(Math.PI / 180 * i * 6) * 220);
Point MovePoint = new Point(MovePoint_X, MovePoint_Y);
Point SidePoint = new Point(SidePoint_X, SidePoint_Y);
g.DrawLine(PPen_Special, MovePoint, SidePoint);
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
MovePoint_X = 247 + (int)(Math.Sin(Math.PI / 180 * i * 6) * 235);
MovePoint_Y = 247 + (int)(Math.Cos(Math.PI / 180 * i * 6) * 235);
Point MovePoint = new Point(MovePoint_X, MovePoint_Y);
Point SidePoint = new Point(SidePoint_X, SidePoint_Y);
g.DrawLine(PPen_Ora, MovePoint, SidePoint);
}
}
int HourPoint = DT.Hour;
int MinutePoint = DT.Minute;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//三角形顶点
int HourEnd_X = 247 + (int)(Math.Sin(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5)) * 180);
int HourEnd_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5)) * 180);
Point hourEnd = new Point(HourEnd_X, HourEnd_Y);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//三角形右节点
int HourRight_X = 247 + (int)(Math.Sin(Math.PI / 180 * (90 + HourPoint * 30 + MinutePoint * 0.5)) * 12);
int HourRight_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (90 + HourPoint * 30 + MinutePoint * 0.5)) * 12);
Point RightSide = new Point(HourRight_X, HourRight_Y);
//三角形左节点
int HourLeft_X = 247 + (int)(Math.Sin(Math.PI / 180 * (270 + HourPoint * 30 + MinutePoint * 0.5)) * 12);
int HourLeft_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (270 + HourPoint * 30 + MinutePoint * 0.5)) * 12);
Point LeftSide = new Point(HourLeft_X, HourLeft_Y);
//用画刷填充区域
SolidBrush HourBrush = new SolidBrush(Color.Gray);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] HourA = new Point[] ...{ RightSide, LeftSide, hourEnd };
g.FillPolygon(HourBrush, HourA);
//箭头中节点
int HHeadMiddle_X = 247 + (int)(Math.Sin(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5)) * 135);
int HHeadMiddle_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5)) * 135);
Point HHeadMiddle = new Point(HHeadMiddle_X, HHeadMiddle_Y);
//箭头左节点
int HHeadLeft_X = 247 + (int)(Math.Sin(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5 - 2)) * 150);
int HHeadLeft_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5 - 2)) * 150);
Point HHeadLeft = new Point(HHeadLeft_X, HHeadLeft_Y);
//箭头右节点
int HHeadRight_X = 247 + (int)(Math.Sin(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5 + 2)) * 150);
int HHeadRight_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (HourPoint * 30 + MinutePoint * 0.5 + 2)) * 150);
Point HHeadRight = new Point(HHeadRight_X, HHeadRight_Y);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] HourHead = new Point[] ...{ HHeadLeft, HHeadMiddle, HHeadRight, hourEnd, };
g.FillPolygon(HourBrush, HourHead);
//绘制分针
int MinuteEnd_X = 247 + (int)(Math.Sin(Math.PI / 180 * MinutePoint * 6) * 230);
int MinuteEnd_Y = 247 - (int)(Math.Cos(Math.PI / 180 * MinutePoint * 6) * 230);
Point MinuteEnd = new Point(MinuteEnd_X, MinuteEnd_Y);
//三角形右节点
int MinuteRight_X = 247 + (int)(Math.Sin(Math.PI / 180 * (90 + MinutePoint * 6)) * 9);
int MinuteRight_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (90 + MinutePoint * 6)) * 9);
Point MinuteRightSide = new Point(MinuteRight_X, MinuteRight_Y);
//三角形左节点
int MinuteLeft_X = 247 + (int)(Math.Sin(Math.PI / 180 * (270 + MinutePoint * 6)) * 9);
int MinuteLeft_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (270 + MinutePoint * 6)) * 9);
Point MinuteLeftSide = new Point(MinuteLeft_X, MinuteLeft_Y);
//用画刷填充区域
SolidBrush MinuteBrush = new SolidBrush(Color.Green);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] MinuteA = new Point[] ...{ MinuteRightSide, MinuteLeftSide, MinuteEnd };
g.FillPolygon(MinuteBrush, MinuteA);
//箭头左节点
int MHeadLeft_X = 247 + (int)(Math.Sin(Math.PI / 180 * (MinutePoint * 6 - 2)) * 190);
int MHeadLeft_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (MinutePoint * 6 - 2)) * 190);
Point MHeadLeft = new Point(MHeadLeft_X, MHeadLeft_Y);
//箭头右节点
int MHeadRight_X = 247 + (int)(Math.Sin(Math.PI / 180 * (MinutePoint * 6 + 2)) * 190);
int MHeadRight_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (MinutePoint * 6 + 2)) * 190);
Point MHeadRight = new Point(MHeadRight_X, MHeadRight_Y);
//箭头中节点
int MHeadMiddle_X = 247 + (int)(Math.Sin(Math.PI / 180 * (MinutePoint * 6)) * 180);
int MHeadMiddle_Y = 247 - (int)(Math.Cos(Math.PI / 180 * (MinutePoint * 6)) * 180);
Point MHeadMiddle = new Point(MHeadMiddle_X, MHeadMiddle_Y);
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
Point[] MinuteHead = new Point[] ...{ MHeadLeft, MHeadMiddle, MHeadRight, MinuteEnd };
g.FillPolygon(MinuteBrush, MinuteHead);
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
//绘制轴心
Pen CPen = new Pen(Color.Red, 14);
g.DrawEllipse(CPen, 240, 240, 14, 14);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void Form1_Paint(object sender, PaintEventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
paintClock(this.ClientRectangle);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private static int PicIndex = 0;
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void CheckBtn_Click(object sender, EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
try
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
DT = Convert.ToDateTime(TimeBox.Text.Trim() + ":00");
this.OnPaint(new PaintEventArgs(this.CreateGraphics(),this.ClientRectangle));
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
if (DT.Hour >= 12)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
PicIndex = (DT.Hour - 12) * 3 + DT.Minute / 20 + 1;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
PicIndex = DT.Hour * 3 + DT.Minute / 20 + 1;
}
PicBox.ImageLocation = ConfigurationManager.AppSettings["ManPic"].ToString() + PicIndex.ToString() + ".jpg";
PicBox.Visible = true;
PicBox.Show();
}
catch
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
internal void paintClock(Rectangle rect)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if (!this.IsDisposed && this.Visible)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
BufferedGraphicsContext myContext = BufferedGraphicsManager.Current;
BufferedGraphics buffer = myContext.Allocate(ClockPanel.CreateGraphics(), rect);
if (buffer.Graphics != null)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
buffer.Graphics.Clear(this.BackColor);
this.DrawClock(buffer.Graphics, this.ClientRectangle);
}
buffer.Render();
buffer.Dispose();
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
private void TimeBox_TextChanged(object sender, EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
NameLabel.Visible = false;
PicBox.ImageLocation = "";
PicBox.Visible = false;
}
}
}
主要实现思路:程序每刷新一次,就重新绘制一次表盘,同时显示时间对应的图片(图片预设36张)
绘制表盘的时候,Panel的背景需要被Cache 一次,
然后再在Panel上重新绘制,这样可以避免重新绘制整个
Form的背景带来的消耗