首页 > Windows开发 > 详细

WPF:鼠标长时间无操作,窗口隐藏

时间:2017-07-19 20:06:18      阅读:401      评论:0      收藏:0      [点我收藏+]

//设置鼠标长时间无操作计时器
private System.Timers.Timer MouseTimerTick = new System.Timers.Timer(10000);

private void Window_Activated(object sender, EventArgs e)
{
  this.Dispatcher.Invoke(new Action(() =>
  {
    //显示
  }));
  MouseTimerTick.Stop();
}

private void Window_Deactivated(object sender, EventArgs e)
{
  MouseTimerTick.Start();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
  MouseTimerTick.Elapsed += new System.Timers.ElapsedEventHandler(TimerTick);
  MouseTimerTick.AutoReset = true;
  MouseTimerTick.Enabled = true;
}
private void TimerTick(object source, System.Timers.ElapsedEventArgs e)
{
  this.Dispatcher.Invoke(new Action(() =>
  {
    //隐藏
  }));
}

WPF:鼠标长时间无操作,窗口隐藏

原文:http://www.cnblogs.com/candyzhmm/p/7207461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!