Mouse Click events

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Mouse Click events

Post by Khyati » 15 Feb 2011, 10:43

Hello,
I could set the registration key for professional version, which i provided yesterday. Thanks!

But still, mouse down / double click are not triggered for Cad Editor control.

What can be the reason?

What does it mean by "Visual Entity Creation" feature? that is only for professional version.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mouse Click events

Post by support » 15 Feb 2011, 11:35

Hello Khyati.
Please handle CADEditorControl.PictureBox events like MouseDown or DoubleClick. Visual entities creation means creating entities by mouse, using EntitiesCreator class. This method used when you press "Add new ..." button from toolbar of EditorControl application. Please see Editor demo source for more details. You can also find some info here: http://www.cadsofttools.com/forum/viewt ... =15&t=1900

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: Mouse Click events

Post by Khyati » 28 Mar 2011, 10:55

Thanks!

But, i can't understand how to trigger mouse down event either in picture box or in cadeditor control.
I wish Please use simple and detailed answers to understand. (which property, from where to enable etc.)

Because, there is not much explainatory documentation about various relation between different methods, class, properties etc.. however their description is available, but their interdependency is nowhere written.

Kindly explain properly.

-Khyati

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mouse Click events

Post by support » 30 Mar 2011, 17:53

Hello.
Events handling in CAD Import .NET concerned to .NET Framework classes functionality, so documentation doesn't necessary. Describe event handler for generated events like in demo applications:

Code: Select all

		private void InitializeComponent()
		{
			...	
			this.cadPictBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.cadPictBox_MouseDown);
			...	
		}
 		...
		private void cadPictBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{			
			//your code	
		}
you can call this.cadPictBox_MouseDown event handler from some own method also to simulate mouse click. Please use CADEditorControl.PictureBox events if CADEditorControl object in your application.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: Mouse Click events

Post by Khyati » 31 Mar 2011, 06:20

Thanks!

1)
Now mousedown event is working, but everytime, i edit code and if i go to my designer form, it shows following error:
"Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located"

I think, it is because picturebox of cadeditorcontrol is not located in toolbox.
How to solve this error?

2)
i draw line and point on every mouse click. but when i click the mouse, the drawn point and line are at different location than i pressed the mouse.
And also, when i do zoom-in, it gets more distorting.
What is reason behind that? Do i need to corelate windows and CAD picturebox coordinates? how?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mouse Click events

Post by support » 31 Mar 2011, 16:58

Hello.
PictureBox of CADEditorControl can't be added to toolbox. CADEditorControl component (fully) can be placed on form, not its picturebox separately. Possibly the "Events cannot be set..." issue related to VS, check MSDN library.
Mouse click returns screen coordinates. Are you recalculate it to drawing coordinates?

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: Mouse Click events

Post by Khyati » 01 Apr 2011, 07:26

Thanks!

I am not recalculating coordinates.

1) I want coordinates of mouse click, which later can be input to a line's start or end point.
Using e.X and e.Y directly, gives some unexpected result. It draws lines, but somewhere else. It comes into display when i do zoom-in.

2) how to set focus or display, whatever is being drawn by user's mouse-click?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mouse Click events

Post by support » 04 Apr 2011, 16:38

Hello Khyati.
Mouse click returns screen coordinates. Please recalculate it to drawing coordinates (CADImage coordinates). If I understood correctly you need center newly created entity? Please see the last post from the following topic:
http://www.cadsofttools.com/forum/viewt ... =15&t=2192

Sorry if I didn't understood correctly your request. In such case please specify the matter.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: Mouse Click events

Post by Khyati » 08 Apr 2011, 11:33

Thanks!

I tried with following code, but it doesn't give exact value of co-ordinates of the position, where my mouse clicks.
<<<<
method MainForm.CadEditorCtrl_PictureBox_MouseDown(sender: System.Object; e: System.Windows.Forms.MouseEventArgs);
var
i,j: Integer;
Pos_CAD : System.Drawing.Point; /// recalculated co-ordinates
Pos_Win : CADImport.DPoint; /// co-ordinates, got from mouseEventhandler
begin

entPt[cnt] := new CADImport.CADCircle(); /// draw a small circle

Pos_Win := new CADImport.DPoint(e.X, e.Y, 0);
Pos_CAD := new System.Drawing.Point;
Pos_CAD := cadEditorControl1.Image.GetPoint(Pos_Win);

entPt[cnt].Point := new CADImport.DPoint(Pos_CAD.X, Pos_CAD.Y, 0);

entPt[cnt].Radius := 100;
entPt[cnt].Color := Color.Aqua;

entPt[cnt].Loaded(cadEditorControl1.Image.Converter);
cadEditorControl1.Image.Converter.OnCreate(entPt[cnt]);
cadEditorControl1.Image.CurrentLayout.AddEntity(entPt[cnt]);

cadEditorControl1.Invalidate();

end;
>>>>

I want to draw a circle where user presses mouse click and display it, at the same time.
For that, i want mouse-click's co-ordinates, which are shown on status bar panel of cad editor control.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Mouse Click events

Post by support » 08 Apr 2011, 16:52

Hello Khyati.
CADImage.GetPoint transforms CAD (CADImage) coordinate to screen (picturebox) coordinate. Please read my answers:
http://www.cadsofttools.com/forum/viewt ... =15&t=2263

Please see cadPictBox_MouseMove method in Viewer demo as example of CADConst.GetRealPoint method using.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply