码迷,mamicode.com
首页 > Windows程序 > 详细

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

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

标签:handle   dispatch   object   tick   window   oid   led   top   set   

//设置鼠标长时间无操作计时器
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:鼠标长时间无操作,窗口隐藏

标签:handle   dispatch   object   tick   window   oid   led   top   set   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!