windows-phone-8 – 如何检测两个同时触摸?
发布时间:2020-12-14 02:17:06 所属栏目:Windows 来源:网络整理
导读:在 Windows Phone 8中检测触摸利用System.Windows.Input.Touch.FrameReported事件,这是开发人员可用的最原始且最具响应性的触摸事件. 你会使用这样的事件: public MainPage(){ InitializeComponent(); // setup sounds Ellipse1.Tag = new Uri("Sounds/GVD_
在
Windows Phone 8中检测触摸利用System.Windows.Input.Touch.FrameReported事件,这是开发人员可用的最原始且最具响应性的触摸事件.
你会使用这样的事件: public MainPage() { InitializeComponent(); // setup sounds Ellipse1.Tag = new Uri("Sounds/GVD_snr1.wav",UriKind.Relative); Ellipse2.Tag = new Uri("Sounds/GVD_snr2.wav",UriKind.Relative); Ellipse3.Tag = new Uri("Sounds/GVD_snr3.wav",UriKind.Relative); Ellipse4.Tag = new Uri("Sounds/GVD_snr4.wav",UriKind.Relative); Ellipse5.Tag = new Uri("Sounds/GVD_snr5.wav",UriKind.Relative); Ellipse6.Tag = new Uri("Sounds/GVD_snr6.wav",UriKind.Relative); Ellipse7.Tag = new Uri("Sounds/Gong.wav",UriKind.Relative); // respond to touch(es) var _Ellipses = new[] { Ellipse1,Ellipse2,Ellipse3,Ellipse4,Ellipse5,Ellipse6,Ellipse7 }; System.Windows.Input.Touch.FrameReported += (s,e) => { var _Touches = from touch in e.GetTouchPoints(null) where touch.Action == System.Windows.Input.TouchAction.Down let ellipse = touch.TouchDevice.DirectlyOver as Ellipse where _Ellipses.Contains(ellipse) select ellipse; System.Diagnostics.Debug.WriteLine("{0} touch(es).",_Touches.Count()); foreach (var ellipse in _Touches) { var _Stream = Application.GetResourceStream(ellipse.Tag as Uri).Stream; var _SoundEffect = Microsoft.Xna.Framework.Audio.SoundEffect.FromStream(_Stream); Microsoft.Xna.Framework.FrameworkDispatcher.Update(); _SoundEffect.Play(); } }; } (用Lumia 920测试) 这就像一个魅力 – 只要一次只有一个触摸.当用户试图同时触摸两个或多个点(我的意思是完全相同的时间)时,事件根本不会被提升.当用户几乎同时尝试触摸两个或多个点时(仅相隔一秒),然后引发事件并报告两个点. 如何检测两个同时触摸? 如果你想看XAML,这里是XAML: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,12,0"> <Grid.Resources> <Style TargetType="Ellipse"> <Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="VerticalAlignment" Value="Top" /> </Style> </Grid.Resources> <Ellipse x:Name="Ellipse1" Fill="Blue" Height="177" Margin="17,17,0" Width="177"/> <Ellipse x:Name="Ellipse2" Fill="#FFFFA300" Height="223" Margin="212,25,0" Width="223"/> <Ellipse x:Name="Ellipse3" Fill="#FFFF00E8" Height="97" Margin="89,207,0" Width="97"/> <Ellipse x:Name="Ellipse4" Fill="#FF00C135" Height="162" Margin="186,249,0" Width="162"/> <Ellipse x:Name="Ellipse5" Fill="#FF00AEFF" Height="272" Margin="59,416,-81" Width="272"/> <Ellipse x:Name="Ellipse6" Fill="Red" Height="97" Margin="320,395,0" Width="97"/> <Ellipse x:Name="Ellipse7" Fill="#FFF3FF00" Height="133" Margin="10,304,0" Width="133"/> </Grid> 解决方法
添加此解决了问题:
var _Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(50) }; _Timer.Tick += (s,e) => { try { Microsoft.Xna.Framework.FrameworkDispatcher.Update(); } catch { } }; _Timer.Start(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- MPI与Microsoft WCF对比Microsoft TPL
- 在Windows 64x下的GCC中的printf和%llx
- 使用Perc 4 / Di和Windows SBS 2003在Dell PowerEdge上调整
- active-directory – Windows Small Business Server 2011中
- Windows Phone 7 – WP7上的宽瓦通知?
- windows-server-2008-r2 – 太多的网络传输会破坏Windows S
- Typora快捷键 shortcuts-windows
- NTFS“秘密”?
- 命令行 – 为什么Windows命令shell告诉我使用不同的命令然后
- Windows – ConnectEx要求套接字“最初绑定”,但是要什么?
推荐文章
站长推荐
- selenium-webdriver – 在Windows上设置Selenium
- [Qt] 文本文件读写, 摘自官方文档
- windows-server-2008-r2 – Windows任务计划程序
- 阻止程序删除Windows中的文件?
- 使用Microsoft.Extensions.Logging从静态成员进行
- .net-3.5 – .NET Framework 3.5不会安装在VISTA
- windows-phone-7 – 即使不可见,PerformanceProg
- Windows – 如何从命令提示符打开Visual Studio解
- metro app(.NET)中受控的非UI计时器
- Win7怎么用IIS发布网站系统 部署项目
热点阅读