惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
WordPress大学
WordPress大学
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
N
News | PayPal Newsroom
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
美团技术团队
J
Java Code Geeks
I
Intezer
The Cloudflare Blog
SecWiki News
SecWiki News
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
D
DataBreaches.Net
S
Security Affairs
Help Net Security
Help Net Security
S
Securelist
F
Full Disclosure
C
Check Point Blog
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园_首页
G
Google Developers Blog
Google Online Security Blog
Google Online Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog

博客园 - Leepy

AI应用平台搭建之旅(上) - 框架篇(附:AICon大会阿里国际Agent应用平台分享) 阿里巴巴LangEngine开源了!支撑亿级网关规模的高可用Java原生AI应用开发框架 在mac上安装Go语言初体验 iOS学习系列 - 标签Tag列表的实现 iOS学习系列 - UITableView下拉更新/上提加载的实现 iOS学习系列 - MonoTouch绑定原生Obj-C静态库的实现 iOS学习系列 - 在iOS客户端实现google oauth2登录以及在asp.net服务端上form认证 iOS学习系列 - 利用ASIHTTPRequest实现异步队列 iOS学习系列 - 扩展机制category与associative Wind.js在移动跨平台框架PhoneGap中的异步体验 Mono for Andriod学习与实践(1)— 初体验 阿里技术嘉年华官网上线啦! Silverlight实现对Sql Server Profiler的SQL实时监控 利用Mono.Cecil动态修改程序集来破解商业组件(仅用于研究学习) 利用Nginx+Mono+Fastcgi代替IIS对Asp.Net进行反向代理 Thrift初探:简单实现C#通讯服务程序 对于.Net中C#指针的研究 各大主流.Net的IOC框架性能测试比较 依赖注入框架Autofac的简单使用
Silverlight 4以下版本模拟鼠标双击事件
Leepy · 2012-03-16 · via 博客园 - Leepy

在Silverlight 5的新特性中已经包含了鼠标双击的事件,看以下的代码

<Grid x:Name="LayoutRoot" Background="White">
        <Ellipse Height="103" HorizontalAlignment="Left" Fill="Green" Margin="117,56,0,0"
                 Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top"
                 Width="158" MouseLeftButtonDown="ellipse1_MouseLeftButtonDown"  
                 MouseRightButtonDown="ellipse2_MouseRightButtonDown" />
    </Grid>

在事件实现中:

private void ellipse1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //判断鼠标在系统设置的双击间隔时间之内被点击了两次则弹出窗口显示
            if (e.ClickCount == 2)
            {
                MessageBox.Show("鼠标左键点击"+e.ClickCount.ToString());
            }
        }

而在Silverlight4以下版本均不包含ClickCount的属性,那么只能自己实现,于是,实现了一个模拟鼠标双击的功能:

    

public class MouseTool
    {
        //双击事件定时器
        private DispatcherTimer _timer;
        //是否单击过一次
        private bool _isFirst;

        public MouseTool()
        {
            this._timer = new DispatcherTimer();
            this._timer.Interval = new TimeSpan(0000400);
            this._timer.Tick += new EventHandler(this._timer_Tick);
        }

        /// <summary>
        
/// 判断是否双击
        
/// </summary>
        
/// <returns></returns>
        public bool IsDoubleClick()
        {
            if (!this._isFirst)
            {
                this._isFirst = true;
                this._timer.Start();
                return false;
            }
            else
                return true;
        }

        //间隔时间
        void _timer_Tick(object sender, EventArgs e)
        {
            this._isFirst = false;
            this._timer.Stop();
        }
    }

在事件调用中如下:

private MouseTool _mouseTool = new MouseTool();

public void GridSplitter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this._mouseTool.IsDoubleClick())
            {
//...

就是这么简单!