zoukankan      html  css  js  c++  java
  • Silverlight DoubleClickHelper 双击事件模拟类 南京酷得软件

    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;
                }
                
            }
        }
    }

    南京酷得软件

    公司网站: http://www.codersoft.cn 专业开发: 气象软件、监狱网上购物系统、两法衔接平台
  • 相关阅读:
    mysql表分区
    .NET面试题
    .NET中CORS跨域访问WebApi
    一些VS2013的使用技巧(转载)
    java enum(枚举)使用详解 + 总结(转载)
    java枚举类型(转载)
    解析oracle的rownum,数据库查询结果返回行数设置
    使用jquery-qrcode生成二维码(转载)
    Spring 之注解事务 @Transactional(转载)
    spring @Transactional注解参数详解(转载)
  • 原文地址:https://www.cnblogs.com/sucsy/p/3099225.html
Copyright © 2011-2022 走看看