WPF十字光标的热点是否在十字准线的中间?
我在 WPF 中使用高精度面向像素的图像程序时遇到了惊人的困难,并开始怀疑 Cursors.Cross 光标热点并不像您所期望的那样位于其中心。
我正在使用 放大镜 进行调试,放大倍数为 16 倍,鼠标设置为最低加速度。该代码基于 CodeProject 中的 DrawTools。
这与您在 Winforms 中获得的光标相同吗?如果是这样,我可以查看该光标的热点 - System.Windows.Input 中的 Cursor 类没有 HotSpot 属性。
更新
如果有人正在寻找解决方法,就我而言,我已经调用了一个委托来过滤点,以便我可以实现捕捉到网格的行为。将点偏移 1 来补偿是微不足道的。这比创建自定义光标要容易得多,并且具有的优点是,如果其外观发生变化,我仍然使用库存光标。
I'm having amazing difficulties with a high-precision pixel-oriented image program in WPF and starting to suspect that the Cursors.Cross
cursor hotspot is not at its centre, as you would expect.
I'm debugging using Magnifier at 16x and mouse set to the lowest acceleration. The code is based on DrawTools from CodeProject.
Is this the same cursor as you get in Winforms? If so, I can look at that cursor's hotspot - the Cursor class in System.Windows.Input doesn't have the HotSpot property.
UPDATE
In case anyone is looking for a workaround, in my case I already have a delegate being invoked to filter the points so I can implement snap-to-grid behaviour. It was trivial to offset the point by 1 to compensate. This was a lot easier than creating a custom cursor and has the advantage that I'm still using the stock cursor if its appearance should change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有一个经验性的答案:是的,热点被抵消了。
我修改了程序,可以通过按键触发图形模式,这样就不需要移动鼠标了。
使用与上面的快照相同的放大镜视图,只需按一个键来更改模式即可在箭头和十字之间切换光标。
当我切换时,它会绘制光标,以便黑线集中在正常箭头光标的左上角。
箭头光标热点位于它指向的像素(不是黑色像素),所以是的,十字光标热点不在十字准线的中心!
叹
I have an empirical answer that yes, the hotspot is offset.
I modified the program to be able to trigger graphics modes by pressing keys, so you don't need to move the mouse.
Using the same Magnifier view as the snapshot above, just pressing a key to change the mode toggles the cursor between arrow and cross.
When I switch it draws the cursor so the black lines centre on the top-left point of the normal arrow cursor.
The arrow cursor hotspot is at the pixel it points to (not a black pixel) so yes, the cross cursor hotspot is NOT at the centre of the crosshairs!
sigh