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

简介: 原文:#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 事件中,我们可以获得手指与屏幕接触的位置的面积大小。
原文: #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;
    }
}


目录
相关文章
|
6月前
dev combobox edit 怎么设置让选项清空
dev combobox edit 怎么设置让选项清空
|
Ubuntu
Ubuntu 1604报错cannot create temp file for here-document: No space left on device,拓展sda容量解决之
Ubuntu 1604报错cannot create temp file for here-document: No space left on device,拓展sda容量解决之
281 0
页面中的位置:client、page、screen、offset、以及元素视图位置的区别和方法
页面中的位置:client、page、screen、offset、以及元素视图位置的区别和方法
|
数据库
MOVE
MOVE
90 0
error: x264_bit_depth undeclared (first use in this function) did you mean x264_picture_t
error: x264_bit_depth undeclared (first use in this function) did you mean x264_picture_t
162 0
SAP WM初阶Storage Type上的SUM Indicator参数修改
SAP WM初阶Storage Type上的SUM Indicator参数修改
SAP WM初阶Storage Type上的SUM Indicator参数修改
SAP WM 为Storage Type 004激活SUM报错 - Storage types without pick-point stor.type require partial pallet
SAP WM 为Storage Type 004激活SUM报错 - Storage types without pick-point stor.type require partial pallet
SAP WM 为Storage Type 004激活SUM报错 - Storage types without pick-point stor.type require partial pallet
|
Oracle 关系型数据库 测试技术
[20171204]guaranteed restore point.txt
[20171204]guaranteed restore point.txt --//昨天帮别人升级再次遇到关于相关问题,实际上主要问题在于升级文档没有完成后取消restore point的设置.
1277 0