画布上的光标位置 [英] Cursor position on canvas

查看:91
本文介绍了画布上的光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作矢量图形编辑器(非常基本的编辑器)。开始试验并遇到问题 - 当光标超过某个形状时,我只能检索MouseEventArgs的Position属性。虽然这将使我的工作变得更容易,但是当我需要创建一个形状时,我将会移动形状,它根本不会有任何帮助 - 我希望形状的最后一点跟随光标直到用户完成。那么,如何在没有任何形状的情况下获得光标在画布上的位置?

I am making a vector graphics editor (pretty basic one). Started experimenting with things and encountered a problem - I can only retrieve Position property of MouseEventArgs when cursor is over some shape. While this will make my job much easier when I'll be moving shapes, it does not help at all when I need to create a shape - I want the last point of the shape follow the cursor until user has finished. So, how do I get cursor position on canvas without hitting any shape?

推荐答案

我不明白这个问题。 MouseMove事件应该为您提供表单上任何位置的X和Y位置。

I don't understand the question. The MouseMove event should give you the X and Y locations anywhere on the form.

      private void Form1_MouseMove(object sender, MouseEventArgs e)
      {
         label1.Text = e.X.ToString() + "  " + e.Y.ToString();
      }


这篇关于画布上的光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆