NET的滑鼠手势? [英] Mouse swipe gesture for .net?

查看:64
本文介绍了NET的滑鼠手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何在获胜表格中进行鼠标滑动手势?我找到了一些例行程序,但没有找到类似移动世界的刷卡行为.

如果我想慢速滑动,我想要的东西会很慢,但是如果我轻拂它,它就会有它的动力.我会用它来更改面板内部的图片.

谁能指出我的文章或链接:D

谢谢:D

how do i do a mouse swipe gesture in win forms? i have found some routine but i have not found something that is like the mobile world swipe behavior.

what i wanted if i swipe slow the swiping transition will be slow, but if i flick it, it will have its momentum. i would use it to change a picture from inside a panel.

can anyone point me to an article or a link :D

thanks :D

推荐答案

尝试
.NET的鼠标手势 [ ^ ]
Try
Mouse Gestures for .NET[^]


首先,在页面/控件中添加一个属性,以跟踪用户已启动以开始滑动事件的Touch: br/>
First, add a property to your page/control that keeps track of the Touch that the user has initiated to start the swipe event:

protected TouchPoint TouchStart;


在要构建的页面或控件的代码中,添加以下处理程序:


In the codebehind of the Page or Control you''re building, add the following handlers:

public BasePage()
{
	this.TouchDown += new EventHandler<toucheventargs>(BasePage_TouchDown);
	this.TouchMove += new EventHandler<toucheventargs>(BasePage_TouchMove);            
}</toucheventargs></toucheventargs>


这些处理程序可帮助检测用户何时按下并将手指移到页面或控件上.

接下来,处理触发滑动的初始Touch事件:


These handlers help detect when a user has pressed down and moved his/her finger over your page or control.

Next, handle the initial Touch event that triggers the swipe:

void BasePage_TouchDown(object sender, TouchEventArgs e)
{
	TouchStart = e.GetTouchPoint(this);
}

最后,处理触摸的运动方面.如果运动超出某个阈值;然后我们将其视为滑动并执行我们要执行的任何代码(导航,动画等)

在这里,"AlreadySwiped"只是一个标志属性,因此如果滑动超过我们的阈值一次以上,我们就不会多次执行同一任务.完成刷卡后的代码,您有责任将其重置.另外,我使用200像素作为滑动阈值,但您可能需要更大或更小的值.您可能还需要考虑X的百分比,而不是实际像素.

Finally, handle the movement aspect of the touch. If the movement exceeds some threshold; then we consider it a swipe and execute whatever code we want to do (Navigation, animation, etc)

Here, ''AlreadySwiped'' is just a flag property so we don''t execute the same task multiple times if the swipe exceeds our threshold more than once. You are responsible for resetting it after you do your on-swiped code. Also, I used 200 pixels as the swipe threshold, but you may want a bigger/smaller value. You may also want to consider percentages of X here instead of actual pixels.

void BasePage_TouchMove(object sender, TouchEventArgs e)
{
	if (!AlreadySwiped)
	{                
		var Touch = e.GetTouchPoint(this);

                //right now a swipe is 200 pixels 

                //Swipe Left

                if (TouchStart != null && Touch.Position.X > (TouchStart.Position.X + 200))
                {
                    RunMyCustomCode();
                    AlreadySwiped = true;
                }

                //Swipe Right
                if (TouchStart != null && Touch.Position.X < (TouchStart.Position.X - 200))
                {
                     RunMyCustomCodeSwipeRight();
                    AlreadySwiped = true;
                }
            }

            e.Handled = true;
}


这应该很简单,但是如果您有任何疑问,请给我发消息.


This should be straightforward but send me a message if you have any questions.


这篇关于NET的滑鼠手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆