原文:#748 – 获得按下时对应位置点的大小(Getting the Size of a Contact Point during Raw Touch)

原文地址:https://wpf.2000things.com/2013/02/04/748-getting-the-size-of-a-contact-point-during-raw-touch/

在低级别的触屏Touch 事件中,我们可以获得手指与屏幕接触的位置的面积大小。获得这个信息可以通过TouchPoint.Bounds 属性(请注意,即使驱动层不支持,该属性也有值,可能会有为0的大小)。

下面是一个例子,在触摸的位置根据接触的大小画一个椭圆。

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
TouchEllipses = new Dictionary<int, Ellipse>();
} private Dictionary<int, Ellipse> TouchEllipses; private void Canvas_TouchDown(object sender, TouchEventArgs e)
{
canvMain.CaptureTouch(e.TouchDevice);
TouchPoint tp = e.GetTouchPoint(canvMain); Ellipse el = new Ellipse();
el.Stroke = Brushes.Black;
el.Fill = Brushes.Black; el.Width = tp.Bounds.Width > 0 ? tp.Bounds.Width : 50;
el.Height = tp.Bounds.Height > 0 ? tp.Bounds.Height : 50; Canvas.SetLeft(el, tp.Position.X - (el.Width / 2));
Canvas.SetTop(el, tp.Position.Y - (el.Height / 2)); canvMain.Children.Add(el);
TouchEllipses.Add(e.TouchDevice.Id, el); e.Handled = true;
} private void Canvas_TouchUp(object sender, TouchEventArgs e)
{
canvMain.Children.Remove(TouchEllipses[e.TouchDevice.Id]);
TouchEllipses.Remove(e.TouchDevice.Id); e.Handled = true;
}
}

#748 – 获得按下时对应位置点的大小(Getting the Size of a Contact Point during Raw Touch)的更多相关文章

  1. sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback

    sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback在sharepoint 2010中,如果当前页面的篇幅 ...

  2. element-ui select 下拉框位置错乱--解决

    element-ui select 下拉框位置错乱 由于使用 element-ui 的 select 组件时,下拉框的位置错乱了. 开始查找问题 通过各种问题查找,发现是 css 问题 css bod ...

  3. 动画的button(按下时缩小,松开时恢复)

    #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...

  4. 发布.net 4.0的站点到IIS7.5下时无法访问

    现象: 初始发布.net 4.0站点到IIS7.5下时,各种配置都完毕的情况下依旧无法访问.首页显示站点目录结构(注:开启目录结构访问后会显示这个错误,否则会提示开启),访问次级目录提示:Handle ...

  5. 页面跳转,A跳到B,B再返回A时自动定位到离开A时的位置

    <template> <div class="hello" @scroll="scrollLoad" id="myScrollBox ...

  6. XCode下在不同位置声明变量的用法(转)

    XCode下在不同位置声明变量的用法 方式一:直接在.h文件@interface中的大括号中声明. @interface Test : NSObject { NSString *str; // 私有变 ...

  7. keydown([[data],fn]) 当键盘或按钮被按下时,发生 keydown 事件。

    keydown([[data],fn]) 概述 当键盘或按钮被按下时,发生 keydown 事件. 注释:如果在文档元素上进行设置,则无论元素是否获得焦点,该事件都会发生.直线电机滑台 参数 fnFu ...

  8. MouseMoveEvent为了不太耗资源在默认状态下是要鼠标按下才能捕捉到。要想鼠标不按下时的移动也能捕捉到,需要setMouseTracking(true)

    最近用Qt软件界面,需要用到mouseMoveEvent,研究了下,发现些问题,分享一下. 在Qt中要捕捉鼠标移动事件需要重写MouseMoveEvent,但是MouseMoveEvent为了不太耗资 ...

  9. myecplise上将工程部署到应用下时,经常出现 An internal error occurred during: "Add Deployment". java.lang.NullPointEx

    myecplise上将工程部署到应用下时,经常出现 An internal error occurred during: "Add Deployment". java.lang.N ...

随机推荐

  1. 从源码角度实现一个自己的Promise

    原文链接:https://geniuspeng.github.io/2017/12/14/my-promise/ 关于Promise的概念以及意义就不在这里介绍了,最近看到了一些实现Promise的核 ...

  2. 【30.36%】【codeforces 740D】Alyona and a tree

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. ios开发之核心动画四:核心动画-Core Animation--CABasicAnimation基础核心动画

    #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutl ...

  4. java的对象锁和对象传递

    1.对象传递 在JAVA的參数传递中,有两种类型,第一种是基本类型传递,比如int,float,double等,这样的是值传递,第二种是对象传递,比方String或者自己定义的类,这样的是引用传递. ...

  5. 【76.57%】【codeforces 721A】One-dimensional Japanese Crossword

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. mysql mha高可用架构的安装

    MMM无法全然地保证数据的一致性,所以MMM适用于对数据的一致性要求不是非常高.可是又想最大程度的保证业务可用性的场景对于那些对数据一致性要求非常高的业务,非常不建议採用MMM的这样的高可用性架构.那 ...

  7. js进阶正则表达式10-分组-多行匹配-正则对象的属性(小括号作用:分组,将小括号里面的东西看成一个整体,因为量词只对前一个字符有效)(多行匹配:m)(属性使用:reg.global)

    js进阶正则表达式10-分组-多行匹配-正则对象的属性(小括号作用:分组,将小括号里面的东西看成一个整体,因为量词只对前一个字符有效)(多行匹配:m)(属性使用:reg.global) 一.总结 1. ...

  8. Android程序解析XML文件的方法及使用PULL解析XML案例

    一.一般解析XML文件的方法有SAX和DOM.PULL (1)DOM(JAXP Crimson解析器) DOM是用与平台和语言无关的方式表示XML文档的官方W3C标准.DOM是以层次结构组织的节点或信 ...

  9. Google Guava官方教程

    原文链接 译文链接 译者: 沈义扬,罗立树,何一昕,*武祖 * 校对:方腾飞 引言 Guava工程包含了若干被Google的 Java项目广泛依赖 的核心库,例如:集合 [collections] . ...

  10. js 进阶 10 js选择器大全

    js 进阶 10 js选择器大全 一.总结 一句话总结:和css选择器很像 二.JQuery选择器 原生javaScript中,只能使用getELementById().getElementByNam ...