C# Windows Surface Pro上的StylusEvent
我正在为Windows Surface Pro开发一个应用程序。我需要把笔压在屏幕上,然后我想办法 在解决了由于事件引起的一些问题(StylusDown、StylusUp和其他手写笔事件从未引发,但仅限于鼠标事件)后,我进入了一个解决方案 我将向您展示代码(摘自一些microsoft指南) 基本上是原始事件的过滤器C# Windows Surface Pro上的StylusEvent,c#,wpf,pixelsense,C#,Wpf,Pixelsense,我正在为Windows Surface Pro开发一个应用程序。我需要把笔压在屏幕上,然后我想办法 在解决了由于事件引起的一些问题(StylusDown、StylusUp和其他手写笔事件从未引发,但仅限于鼠标事件)后,我进入了一个解决方案 我将向您展示代码(摘自一些microsoft指南) 基本上是原始事件的过滤器 class MyFilterPlugin : StylusPlugIn { protected override void OnStylusDown(RawStylusInp
class MyFilterPlugin : StylusPlugIn
{
protected override void OnStylusDown(RawStylusInput rawStylusInput)
{
// Call the base class before modifying the data.
base.OnStylusDown(rawStylusInput);
Console.WriteLine("Here");
// Restrict the stylus input.
Filter(rawStylusInput);
}
private void Filter(RawStylusInput rawStylusInput)
{
// Get the StylusPoints that have come in.
StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();
// Modify the (X,Y) data to move the points
// inside the acceptable input area, if necessary.
for (int i = 0; i < stylusPoints.Count; i++)
{
Console.WriteLine("p: " + stylusPoints[i].PressureFactor);
StylusPoint sp = stylusPoints[i];
if (sp.X < 50) sp.X = 50;
if (sp.X > 250) sp.X = 250;
if (sp.Y < 50) sp.Y = 50;
if (sp.Y > 250) sp.Y = 250;
stylusPoints[i] = sp;
}
// Copy the modified StylusPoints back to the RawStylusInput.
rawStylusInput.SetStylusPoints(stylusPoints);
}
然而,当我运行这个程序时,我总是得到0.5作为PressureFactor(默认值),并且检查得越深,我仍然可以看到手写笔的环境设置不正确(例如,他的Id为0)
有没有正确收集StylusEvent的方法?
要点是:我需要收集屏幕上笔的压力(多少压力)
非常感谢
一些信息:我正在win 7 Pc上使用VisualStudio 2012 Ultimate进行开发。我将应用程序部署在带有windows 8.1的Surface Pro中。我安装并配置了Surface SDK 2.0和Surface运行时。为了完成,我已经解决了这个问题 触控笔事件(不知道如何)与Surface SDK冲突。一旦我从项目中删除了SDK引用,所有工作都顺利进行,我解决了问题。 现在我可以正确地收集每次触笔和移动笔时的压力 我发布这篇文章只是为了社区信息
StylusPlugIns.Add(new MyFilterPlugin());