المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Passing Cursor Coordinates as Parameters



C# Programming
05-21-2013, 01:12 PM
Hi All,
I am trying to create a function that passes the cursor's starting and ending x,y coordinates as parameters. For instance I would like to set the cursor's starting x,y coordinate when the user clicks the left mouse button. Then as the user holds down the left mouse button and drags the cursor to a desired ********, the ending x,y coordinate is dynamically set and updated. The final ending coordinate is set when the left button is released. I am currently working with the following code:

private void Cursor_Coord(out Cursor C1, out Cursor C2) { // Set the Current cursor, move the cursor's Position, Cursor C1; Cursor C2; if(Mouse.LeftButton == MouseButtonState.Pressed) { C1 = new Cursor(Cursor.Current.Handle); C1.Position = new Point(Cursor.Position.X, Cursor.Position.Y); } if(Mouse.LeftButton == MouseButtonState.Released) { C2 = new Cursor(Cursor.Current.Handle); C2.Position = new Point(Cursor.Position.X, Cursor.Position.Y); } }
I am planning to send the changing cursor coordinates to the Drawline method to be used as the first and second point. The effect I have in mind is that the line is drawn as the mouse is in motion. The problem is it's not working. Any help will be greatly appreciated, thanks in advance.