void TimerOnTick(object obj, EventArgs ea)
{
DateTime dtNow = DateTime.Now;
dtNow = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, dtNow.Minute, dtNow.Second);
if (dtNow != _dateTime)
{
_dateTime = dtNow;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
m_Bitmap = DrawClock();
Graphics gg = e.Graphics;
gg.CompositingQuality = CompositingQuality.HighQuality;
gg.DrawImageUnscaled(m_Bitmap, 0, 0);
//g.Dispose();
}
public Bitmap DrawClock()
{
return this.DrawClock(this.ClientRectangle);
}
private void SevenSegmentClock_Resize(object sender, System.EventArgs e)
{
Init();
this.Refresh();
}
private void InitializeComponent()
{
//
// SevenSegmentClock
//
this.Name = "SevenSegmentClock";
this.Size = new System.Drawing.Size(448, 64);
this.Resize += new System.EventHandler(this.SevenSegmentClock_Resize);
}
int _clockStringWidth;
int _clockStringHeight;
public int ClockStringWidth
{
get
{
return _clockStringWidth;
}
}
public int ClockStringHeight
{
get
{
return _clockStringHeight;
}
}
//绘制时钟
public Bitmap DrawClock(Rectangle destRect)
{
m_Bitmap = new Bitmap(destRect.Width, destRect.Height);
//m_Bitmap = new Bitmap(destRect.X + this.Width, destRect.Y + this.Height);
Graphics grfx = Graphics.FromImage(m_Bitmap);
//设置绘图面板的绘制质量等
grfx.CompositingQuality = CompositingQuality.HighQuality;
grfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
grfx.SmoothingMode = SmoothingMode.HighQuality;
SevenSegmentDisplay ssd = new SevenSegmentDisplay(grfx);
ssd.IsDrawShadow = this._isDrawShadow;
GraphicsState gs = grfx.Save();
grfx.TranslateTransform(destRect.X, destRect.Y);
string strTime = string.Empty;
if(this._clockStyle == Seve
| 对此文章发表了评论 |

