Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
mzhao  
#1 Posted : Wednesday, March 30, 2011 11:56:05 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello,

This may be out of the scope of discussion topics of Graphic Mill.

But any suggestion is appreciated:

What is the best approach to adding Drag and Drop Capabilities to the objects derived from VObject?

We have tried to make VObject derived from Window.Form.Control but dropover or dragdrop event is not fired even though we wire the DragEventHandler in the object contructor.

Alex Kon  
#2 Posted : Wednesday, March 30, 2011 10:45:19 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

VObjects are drawn directly to control's surface, they don't exist as separate entities in WinForms hierarchy. Therefore separate VObject cannot handle drag-n-drop events.

Instead, you should handle drag-n-drop events of the MultiLayerViewer control and map screen coordinates to canvas points. After that you can iterate through VObjects and determine which one, for example, received "drop" event using HitTest() method.

mzhao  
#3 Posted : Thursday, March 31, 2011 6:01:09 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello, Alex,

Appreciate the suggestions.

Try to fully understand your suggested approach:

1. Yes, we have dragover and dragdrop event fired for MultilayerViewer. You mean that we should fire a VObject dragover event and dragdrop event by our own coding ( such as calling methods of OnDragOver or OnDragDrop of VObject) within dragover and dragdrop event of MultilayerVewer if that VObject instance test true for its HitTest Method. Or there is no implementation of OnDragOver or OnDragDrop event for VObject at all.

2. We notice that HitTest is called only when the mouse is clicked but not when the mouse is over. The actual situation is that HitTest should be called and test true when the mouse is over the VObject instance ?

mzhao  
#4 Posted : Thursday, March 31, 2011 6:43:31 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello, Alex,

Well, it seems that it can achieve what we want by simply iterating through VObjects to test HitTest within dragover and dragdrop event method of multiviewer without evoking dragover and dragdrop event for VObject.

But it would be nice if you can further elaborate the discussion of item 1 in our previous reply.

Also, it would be nicer if you can talk about some approaches to implement dragover and dragdrop event for VObject without having VObject derived from Window.Form.Control

Thank you.

Alex Kon  
#5 Posted : Monday, April 4, 2011 5:18:57 AM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello mzhao,

Yes, you got me right - you should use VObject.HitTest() in your handlers for DragOver and DragDrop events to provide behavior you need. For example, you may return true when some TextVObject is under mouse cursor in DragOver handler and change its Text property in DragDrop handler.

VObject is not (and shouldn't be) derived from Windows.Form.Control, because it has completely different semantics and is not expected to work like such control.

So, I didn't quite understand your first item in the first your replay. Of course, you can add some methods for drag-n-drop support in VObjects if you want. But it is just question of design of your application, but not a common pattern. Sometimes it maybe easier to implement all this logic in MultilayerViewer's drag-n-drop events.

Maybe you could bring some example for your task, so we can discuss it more specifically?

mzhao  
#6 Posted : Monday, April 4, 2011 11:06:56 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello, Alex,

Appreciate that you spent some time on this discussion.

Following are what we see how to approach this:

1. Agree with you that VObject should not be derived from Window.Form.Control.

2. To have dragdrop capablility be added to VObject, VObject should implement : a. IDragTarget Interface, b. Events associated each method of IDragTarget Interface.

3. There are two possible ways to fire those events

a. in the same events of MultiLayerViewer using VObject.HitTest to identify the right VObject instance to fire the related event:

something like this:

MultiLayerViewer1_DragDrop (object sender, DragEventArg e)

{

Point newPoint = MultiLayerViewer1.PointToClient(new Point((int)e.X, (int)E.Y));

PointF PosicaoNoCanvas = MultiLayerViewer1.ControlToWorkspace(newPoint, Aurigma.GraphicsMill.Unit.Point);

foreach (VObject vo in MultiLayerViewer1.CurrentLayer.VObjects)

{

if(vo.HitTest (PosicaoNoCanvas, 0.0F))

{

vo.OnDragDrop(e);

}

}

}

b. If we want to implement IDragTarget Interface of VObject completely within VObject, is this possible? Then, we need to talk about how to receive the dragdrop data, how create DragEventArg, when and where and how to evoke the event

We are very interested in your input to this second possible way: item b in above.

Alex Kon  
#7 Posted : Monday, April 4, 2011 8:53:55 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello mzhao,

I cannot see how this can be implemented.

Maybe I'm wrong, but here is my thoughts: all drag-n-drop events now are received by MultiLayerViewer. You need to pass that information to VObject. Therefore somewhere in your code you will have to have the same loop you wrote in the previous message. Why not have it in MultiLayerViewer's event handler?

I don't know, maybe there is a possibility to intercept mouse events on the Application level, separate drag-n-drop events from all others and pass them to VObjects directly... But I see no advantages of such approach. Could point me where I'm wrong?

mzhao  
#8 Posted : Tuesday, April 5, 2011 6:33:44 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
thank you.
Alex Kon  
#9 Posted : Tuesday, April 5, 2011 9:22:02 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
You are welcome! Feel free to post a message here in case of any other questions.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.