public void SetLED(int iInChannel, int iInColor)//1--16
{
System.Timers.Timer aTimer = new System.Timers.Timer(1000); //10分钟 600000
aTimer.Elapsed += new ElapsedEventHandler((s, e) => updatePictureImg(s, e, iInChannel,iInColor));
aTimer.Interval = 1000;
aTimer.Enabled = true;
aTimer.AutoReset = true;
}
//mingshine 图片闪烁
private void updatePictureImg(object source, ElapsedEventArgs e, int iInChannel, int iInColor)
{
try
{
int iIndex = iInChannel - 1;
PictureBox TempPictureBox = this.Controls[g_sPictureBox[iIndex]] as PictureBox;
Bitmap img = new Bitmap(TempPictureBox.Width, TempPictureBox.Height);
Graphics TempGra = Graphics.FromImage(img);
Brush TempBrush = new SolidBrush(Color.Yellow);
TempGra.FillEllipse(TempBrush, 0, 0, 20, 20);
//TempPictureBox.Image = img;
UIHelper.InvokeOnUIifRequired(this, delegate
{
TempPictureBox.Image = img;
});
TempPictureBox.Refresh();
}
catch { }
}
C# 定时器使用
于 2019-03-19 10:28:11 首次发布