以特定频率闪烁图像
本文关键字:闪烁 图像 频率 | 更新日期: 2023-09-27 18:07:33
我试图显示一个特定频率的图像(使其闪烁)。
我已经在图片框中添加了图像,但我不知道如何使其闪光,有什么想法吗?
添加计时器并将您的图片框可见性设置为相反的每个tick?未测试代码:
public static void Main()
{
var timer = new System.Timers.Timer()
{
Elapsed += new ElapsedEventHandler(OnTimedEvent),
Interval = 5000,
Enabled = true
}
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
//your timer is executing
myImageBox.Visible = !myImageBox.Visible
}
你也可以试试这个:
public static void Main()
{
System.Windows.Forms.Timer timer; //Declared in your 'Form.Designer.cs'
timer.Interval = 1000; //Equals the 1 second
timer.Start(); //Always use 'Timer.Stop', when you need stoping the Timer
timer.Enabled = true;
}
private void timer_Tick(object sender, EventArgs e)
{
pictureBox.Visible = !pictureBox.Visible;
}
请注意,这个答案不适用于windows应用程序,它适用于Web。如果你正在使用c#和ASP。JQUERY的toggleClass()会对你有用的。不要去服务器端。
setInterval(
function(){
$('#imgId').toggleClass('on');
},500
);