在WinCE操作系统中,用于读取电池的状态。
调用方法:
//主窗口电池
Battery battery = new Battery();
Battery.State SLast = Battery.State.Normal;
//主界面时钟,用户查看电池状态
private void timer2_Tick(object sender, EventArgs e)
{
((Timer)sender).Enabled = false;
Battery.SystemIdleTimerReset();
SLast = battery.Status;
Rectangle Rect = battery.BatteryState;
if (battery.Status != SLast)
{
Invalidate();
}
((Timer)sender).Enabled = true;
}
//主窗口画画图事件
private void FrmMain_Paint(object sender, PaintEventArgs e)
{
//画出电池形状
Graphics g = e.Graphics;
g.DrawImage(pictureBox1.Image, 0, 0);
Brush brush = new SolidBrush(this.ForeColor);
g.DrawString(PubVar.CurrVer, this.Font, brush, 228, 68);
// Screen.PrimaryScreen.WorkingArea.Width - g.MeasureString(PubVar.CurrVer, this.Font).Width - 10, 68);
Rectangle Rect = battery.BatteryState;
//g.DrawString(battery.BatteryPercent.ToString(), this.Font, brush, battery.Left, battery.Top);
//正常使用电池状态
if (battery.Status == Battery.State.Normal)
{
g.DrawPolygon(new Pen(this.ForeColor), battery.BatteryStateRect);
g.FillRectangle(brush, battery.BatteryState);
}
else//充电 电量不足
{
g.DrawString(battery.Text, this.Font, brush, battery.Left, battery.Top);
}
}
猜您喜欢
推荐内容
开源项目推荐 更多
热门活动
热门器件
用户搜过
随便看看
热门下载
热门标签
评论