49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
namespace U8AppMain
|
|
{
|
|
public class MessageFilter : IMessageFilter
|
|
{
|
|
private Timer timer = new Timer();
|
|
private int _lastTick = Environment.TickCount;
|
|
|
|
public MessageFilter(int closeInterval = 60)
|
|
{
|
|
this._closeInterval = closeInterval * 1000;
|
|
this.timer.Interval = 10000;
|
|
this.timer.Tick += Timer_Tick;
|
|
this.timer.Start();
|
|
}
|
|
|
|
|
|
private int _closeInterval;
|
|
|
|
|
|
|
|
|
|
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
{
|
|
if (Environment.TickCount - _closeInterval > Environment.TickCount)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
}
|
|
|
|
public bool PreFilterMessage(ref Message m)
|
|
{
|
|
if (m.Msg == (int)WindowsMessages.WM_MOUSEMOVE || m.Msg == (int)WindowsMessages.WM_KEYUP)
|
|
{
|
|
this._lastTick = Environment.TickCount;
|
|
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|