title author date CreateTime categories
UWP how to get the touch width
lindexi
2018-11-15 18:49:12 +0800
2018-11-06 09:25:23 +0800
UWP

The touch width can help us to make a gorgeous application. This article tells you how to get the touch width from the PointEvent in UWP.

Opening the VisualStudio and create an empty UWP application.

We should open the MainPage.xaml and add the background in the Grid to make the Grid can get the PointMove event.

    <Grid Background="Transparent">

    </Grid>

Then we can open the MainPage.xaml.cs to write the code to get the PointerMove event.

        public MainPage()
{
InitializeComponent(); Content.PointerMoved += MainPage_PointerMoved;
} private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{ }

We can use GetCurrentPoint to get the PointerPoint.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
}

And we can find the ContactRect in Properties. We can get the touch width from ContactRect.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
}

To get the touch width.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
Debug.WriteLine($"Touch rect width={rect.Width},height={rect.Height}");
}

We also can use ContactRectRaw in Properties.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
Debug.WriteLine($"Touch rect width={rect.Width},height={rect.Height}");
rect = point.Properties.ContactRectRaw;
Debug.WriteLine($"Touch raw rect width={rect.Width},height={rect.Height}");
}

Try to run the code and touch the application and you can watch the output windows that prints the touch width.

2018-11-15-UWP-how-to-get-the-touch-width的更多相关文章

  1. 2018.11.15 Nginx服务器的使用

    Nginx简单教程 1.什么是Nginx? Nginx(engine x)是一款轻量级的Web服务器.反向代理服务器及电子邮件(IMAP/POP3)代理服务器 什么是反向代理服务器? 反向代理方式是指 ...

  2. 2018.11.15 RF antenna impedance-matching

    We have studied the impedance-matching of RF transmission line between the antenna and the RX / TX m ...

  3. OI生涯回忆录 2018.11.12~2019.4.15

    上一篇:OI生涯回忆录 2017.9.10~2018.11.11 一次逆风而行的成功,是什么都无法代替的 ………… 历经艰难 我还在走着 一 NOIP之后,全机房开始了省选知识的自学. 动态DP,LC ...

  4. Sprint1(第二天11.15)

    Sprint1(第二天11.15) Sprint1第一阶段 1.类名:软件工程-第一阶段 2.时间:11.14-11.23 3.选题内容:web版-餐厅到店点餐系统 4.团队博客地址: http:// ...

  5. Tencent Cloud Developers Conference(2018.12.15)

    时间:2018.12.15地点:北京朝阳悠唐皇冠假日酒店

  6. China Intelligent Office Summit(2018.11.21)

    时间:2018.11.21地点:中关村软件园国际会议中心

  7. International Programming Retreat Day(2018.11.17)

    时间:2018.11.17地点:北京国华投资大厦

  8. Intel Artificial Intelligence Conference(2018.11.14)

    时间:2018.11.14地点:北京国贸大酒店

  9. Lean Data Innovation Sharing Salon(2018.09.15)

    时间:2018.09.15地点:北京国华投资大厦

  10. Notes of Daily Scrum Meeting(11.15)

    Notes of Daily Scrum Meeting(11.15) 今天周六我们的主要工作是把这周落下的一些工作补回来,这是写程序的最后阶段,准备进入测试阶段了,所以之前的工作 要补齐,今天大家的 ...

随机推荐

  1. ndn挖坑记(二)

    目录 如何使用ndnSIM运行自己的仿真实验 基本要点 开始动手 BUG记录 如何使用ndnSIM运行自己的仿真实验 基本要点 仿真场景可以在NS-3目录下的scratch/ or src/ndnSI ...

  2. [luogu]P2680 运输计划[二分答案][树上差分]

    [luogu]P2680 [NOIP2015]运输计划 题目背景 公元 2044 年,人类进入了宇宙纪元. 题目描述 L 国有 n 个星球,还有 n-1 条双向航道,每条航道建立在两个星球之间,这 n ...

  3. python 获取list某个元素下标

    index() 函数用于从列表中找出某个值第一个匹配项的索引位置. list.index(x, start, end) #start end 指示搜索的起始和结尾位置,缺省为整个数组 x-- 查找的对 ...

  4. 【PowerOJ1756&网络流24题】最长k可重区间集问题(费用流)

    题意: 思路: [问题分析] 最大权不相交路径问题,可以用最大费用最大流解决. [建模方法] 方法1 按左端点排序所有区间,把每个区间拆分看做两个顶点<i.a><i.b>,建立 ...

  5. inux 下zip包的压缩与解压

    linux zip 命令详解 功能说明:压缩文件. 语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串& ...

  6. [CSP-S模拟测试]:matrix(DP)

    题目描述 求出满足以下条件的$n\times m$的$01$矩阵个数:(1)第$i$行第$1~l_i$列恰好有$1$个$1$.(2)第$i$行第$r_i~m$列恰好有$1$个$1$.(3)每列至多有$ ...

  7. 测试常用linux命令1

    进程相关: 1,查看所有进程(包含历史进程): ps -ef 各个参数的含义依次是uid,pid,ppid,c(cpu利用率),stime(进程启动时间),tty,time,cmd 2,动态查看进程t ...

  8. Mybatis, 实现一对多

    我这里是拿商品做为例子 不多说直接上代码 Mapper.xml <?xml version="1.0" encoding="UTF-8"?> < ...

  9. C++ Boost库的编译及使用

    https://www.jianshu.com/p/de1fda741beb https://www.cnblogs.com/weizhixiang/p/5804778.html Windows编译 ...

  10. Broken pipe

    出现broken pipe 的一种情况是向socket写数据,但是对端已经关闭socket连接,此时会触发SIGPIPE信号,该信号可以捕获. signal(SIGPIPE, SIG_IGN);