using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SFiresoft.Util
{
/// <summary>
/// 鼠标双击监测辅助类
/// </summary>
public class DoubleClickHelper
{
private System.Windows.Threading.DispatcherTimer _doubleClickTimer;
public static DoubleClickHelper _DoubleClickHelper = null;
public static DoubleClickHelper getInstance()
{
if (_DoubleClickHelper == null)
{
_DoubleClickHelper = new DoubleClickHelper();
}
return _DoubleClickHelper;
}
public object TargetObject { get; set; }
private DoubleClickHelper()
{
_doubleClickTimer = new System.Windows.Threading.DispatcherTimer();
_doubleClickTimer.Interval = new TimeSpan(0, 0, 0, 0, 300);
_doubleClickTimer.Tick += new EventHandler(DoubleClick_Timer); _doubleClickTimer.Stop();
}
void DoubleClick_Timer(object sender, EventArgs e)
{
_doubleClickTimer.Stop();
}
/// <summary>
/// 检测当前是否为双击事件
/// /// </summary>
/// <returns></returns>
public bool IsDoubleClick(object targetObject)
{
if (object.ReferenceEquals(targetObject, this.TargetObject))
{
if (_doubleClickTimer.IsEnabled)
{
_doubleClickTimer.Stop();
return true;
}
else
{
_doubleClickTimer.Start();
return false;
}
}
else
{
_doubleClickTimer.Start();
this.TargetObject = targetObject;
return false;
}
}
}
}
南京酷得软件