C# WM6 和鼠标移动事件
我玩的是 WM6 的小但希望不错的应用程序。 我注意到在屏幕上使用手写笔(充当鼠标)时没有触发 MouseUp 和 MouseDown。
这对我来说没关系,我的意思是没有它我也可以生活。 但还有一些事情发生了,我无法忍受改变。
当使用手写笔在屏幕上绘画并读取每个 MouseMove 事件的鼠标坐标时,我得到一些信息(例如 X 轴),例如:2,4,6,8,10,12 等(每隔一个) Y 轴也是如此。
换句话说,无论我移动手写笔有多慢,我都永远不会得到像 2、3、4、5、6 等这样的坐标。 使用这个坐标来绘画我没有得到漂亮的连续线,而是得到单独的点。
希望我已经说得足够清楚了。
附注 我忘记了一件事。 为了在屏幕上绘画,我使用图片框和附加到该图片框的位图。 在位图上绘画时,我无法在屏幕上看到效果,除非刷新 pictureBox 或执行类似 pictureBox.Image = bitmap;
的
操作,以便在不刷新整个 pictureBox 的情况下立即看到绘制的点?
[编辑]
List<Point> array = new List<Point>(); // in the header of the class
private void pictureBox_Screen_MouseMove(object sender, MouseEventArgs e) //event handler body
{
array.Add(new Point(e.X, e.Y));
}
如您所见,这是非常简单的例程。 我删除了所有不必要的噪音,以使其更加清晰。
I play with small but hopefuly nice app for WM6.
I have noticed that there is no MouseUp and MouseDown triggered when playing with stylus (acting as a mouse) on the screen.
That's ok for me, I mean I can live without it.
But there is something else happening that I cannot live with for a change.
When paint on the screen using stylus and read coordinates of the mouse every MouseMove event I get something (lets say for X axis) like: 2,4,6,8,10,12 etc. (every second one)
This same happens for Y axis.
In other words no matter how slow I move stylus I never get coordinates like 2,3,4,5,6 etc.
Using this coordinates to paint I don't get nice continuous line but rather separate dots.
Hopefully I have made myself clear enough.
ps. I forgot about one thing.
To paint on the screen I use pictureBox and bitmap attached to this pictureBox.
When paint on the bitmap I cannot see the evect on the screen unless I refresh the pictureBox or do something like pictureBox.Image = bitmap;
What should I do to see painted dots straight away without refreshing whole pictureBox?
[edit]
List<Point> array = new List<Point>(); // in the header of the class
private void pictureBox_Screen_MouseMove(object sender, MouseEventArgs e) //event handler body
{
array.Add(new Point(e.X, e.Y));
}
As you can see, it is very simple routine. I have deleted all unnecessary noise to make it more clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您唯一的问题是需要通过绘制鼠标移动中捕获的每个像素来画一条线,只需将这些点连接起来就可以了。 即使在“标准”应用程序中,如果用户快速移动鼠标,您也永远无法获得 MouseMove 中的每个点,因此您无法使用手写笔获得每个坐标这一事实应该不是问题。
If your only problem is that you need to draw a line by painting each pixel that you catch in mouse move, just connect the dots and you should be set. Even in a "standard" app you will never get each point in MouseMove if the user moves the mouse quickly, so the fact that you don't get every coordinate with the stylus should not be a problem.