//--------------------------(如转载,请保留版权信息)-------------------------//
// SevenSegmentDisplay.cs 2001 by Charles Petzold //
//------------------------改编:朱继山 a3news(AT)hotmail.com -----------//
using System;
using System.Drawing;
using System.Windows.Forms;
namespace BrawDraw.Com.PhotoFrame.Net.PublicFunctions.Clock
{
//字符绘制的算法
class SevenSegmentDisplay
{
Graphics grfx;
Brush _brush = Brushes.Black;
bool _isDrawShadow = true;
Color _shadowColor = Color.FromArgb(60, Color.White);
Brush _shadowBrush = null;
// Indicates what segments are illuminated for all 10 digits
public bool IsDrawShadow
{
get { return this._isDrawShadow; }
set { this._isDrawShadow = value; }
}
public SevenSegmentDisplay(Graphics grfx)
{
this.grfx = grfx;
// Initialize jagged Point array.
apt[0] = new Point[] {
new Point( 3, 2), new Point(39, 2),
new Point(31, 10), new Point(11, 10)
};
apt[1] = new Point[] {
new Point( 2, 3), new Point(10, 11),
new Point(10, 31), new Point( 2, 35)
};
apt[2] = new Point[] {
new Point(40, 3), new Point(40, 35),
new Point(32, 31), new Point(32, 11)
};
apt[3] = new Point[] {
new Point( 3, 36), new Point(11, 32),
new Point(31, 32), new Point(39, 36),
new Point(31, 40), new Point(11, 40)
};
apt[4] = new Point[] {
new Point( 2, 37), new Point(10, 41),
new Point(10, 61), new Point( 2, 69)
};
apt[5] = new Point[] {
new Point(40, 37), new Point(40, 69),
new Point(32, 61), new Point(32, 41)
};
apt[6] = new Point[] {
new Point(11, 62), new Point(31, 62),
new Point(39, 70), new Point( 3, 70)
};
}
public SizeF MeasureString(string str, Font font)
{
SizeF sizef = new SizeF(0, grfx.DpiX * font.SizeInPoints / 72);
//--------------------------(如转载,请保留版权信息)-------------------------//
// SevenSegmentClock.cs 朱继山 a3news(AT)hotmail.com -------//
// ----------------------------- http://www.brawdraw.com ----------------------//
// -------------------- 未经书面许可,请勿用于商业用途 ---------------------//
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Windows.Forms;
using BrawDraw.Com.PhotoFrame.Net.PublicFunctions;
using System.ComponentModel;
namespace BrawDraw.Com.PhotoFrame.Net.PublicFunctions.Clock
{
//这是控件的关键代码
public class SevenSegmentClock : UserControl
{
DateTime _dateTime;
//默认使用同时绘制日期和时间
SevenSegmentClockStyle _clockStyle = SevenSegmentClockStyle.DateAndTime;
Color _clockColor = Color.Black;
//是否绘制阴影(即残影),以摸拟真似的LED时钟
bool _isDrawShadow = true;