A common feature of cad programs is a getpoint() function. The getpoint() function prompts the user to pick a point which is the return value of the function. I am trying to implement the very same thing and have failed.
The code below shows how far I have got with it. It behaves correctly except for one crucial point, it doesn't give the picked point as the return value of the calling function. I want to be able to write it as:
Point pt = GetPoint();
Any help would be appreciated.
Code:
public partial class Form1 : Form
{
Point pickPoint;
ManualResetEvent manualEvent;
public Form1()
{
InitializeComponent();
manualEvent = new ManualResetEvent(false);
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
pickPoint = Point.Empty;
}
void Form1_MouseDown(object sender, MouseEventArgs e)
{
pickPoint = e.Location;
manualEvent.Set();
}