Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Drag&Drop problem (Read 8264 times)
evgesh
YaBB Newbies
*
Offline


Stoneburner

Posts: 5
Joined: Jan 22nd, 2007
Drag&Drop problem
May 25th, 2007 at 6:19am
Print Post  
Hello Mindfusion,

I have a problem with the drag&drop function between two controls. One control contains a treeview, the other contains contains a flowchart. When a node of treeview is being dragged into the flowchart the cursor should change its look.

Here is the source code of itemdrag event handler of treeview control:

Code
Select All
void m_TreeView_ItemDrag(object sender, ItemDragEventArgs e)
{
	  m_TreeView.DoDragDrop(e.Item, DragDropEffects.Link | DragDropEffects.Copy);
}
 



Here is the source code of dragenter event handler of flowchart:

Code
Select All
void m_FlowChart_DragEnter(object sender, DragEventArgs e)
	  {
		e.Effect = DragDropEffects.Link;
	  }
 



I expect that the cursor changes to "link" icon. However, this does not happen. The cursor stays by "none" icon. Du you have an idea what is the reason for this problem?

Thanks!!!

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #1 - May 25th, 2007 at 8:05am
Print Post  
Hi,

Does drag-and-drop work fine, but the icon is not changed correctly? or drag-and-drop does not work at all?

Stoyan
  
Back to top
 
IP Logged
 
evgesh
YaBB Newbies
*
Offline


Stoneburner

Posts: 5
Joined: Jan 22nd, 2007
Re: Drag&Drop problem
Reply #2 - May 25th, 2007 at 8:27am
Print Post  
Hello Stoyan,

drag&drop does not work. When the cursor is manually set  as follows

Code
Select All
void m_FlowChart_DragOver(object sender, DragEventArgs e)
	  {
			e.Effect = DragDropEffects.Link;
			Cursor.Current = Cursors.Cross;
	   }
 



the cursor flickers very fast. You see the "cross" icon for very short time and than the "none" icon again. I t seems as if some component overwrites the "link" or "cross" icon again and again with "none" icon.
What do you think about this?

Eugen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #3 - May 25th, 2007 at 8:45am
Print Post  
Hello Eugen,

Have you set FlowChart.AllowDrop = true?

I have modified the Flowcharter example as follows:

Code
Select All
private void NodeList_OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
	DoDragDrop(new NodeDragItem(_nodeList.SelectedIndex),
		DragDropEffects.Link);
}

private void FlowChart_OnDragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
	if(e.Data.GetDataPresent(NodeDragItem._GetType()))
	{
		e.Effect = DragDropEffects.Link;
	}
	else
	{
		e.Effect = DragDropEffects.None;
	}
}
 



and can't see any problems with the drag-and-drop link cursor. Could you try that with your version of flowchart.net?

You should not set the Cursor from the DragOver handler yourself, because the DoDragDrop method will change it immediately after that to the drag-and-drop link cursor.

Stoyan
  
Back to top
 
IP Logged
 
evgesh
YaBB Newbies
*
Offline


Stoneburner

Posts: 5
Joined: Jan 22nd, 2007
Re: Drag&Drop problem
Reply #4 - May 29th, 2007 at 7:21am
Print Post  
Hello Stoyan,

thanks for your answer.

I have a guess. We use in our application the DevExpress library. The flowchart control is embedded in a "DockPanel" component of DevExpress. I suppose it can be the reason for our problem. Do you have some experience with DevExpress library and flowcharts? Can some DevExpress component abrogate the flowchart "AllowDrop" property?

Eugen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #5 - May 29th, 2007 at 8:36am
Print Post  
Hello Eugen,

We haven't used DevExpress. Could you edit the flowcharter example and add the DockPanel there to see if drag-and-drop will stop working?

Another customer of ours had a problem with a dock panel component (maybe it was DevExpress' one, but I am not sure), that tried to save the FlowChart.RotateCursor using the Cursor.ToString method. That results in exception because Cursor.ToString works only for the .NET predefined cursor type. If a similar situation happens here before the initialization code reaches the AllowDrop = true statement, that might cause a problem. Just to check that assumption, try setting the RotateCursor to one of the .NET' predefined cursors.

Stoyan
  
Back to top
 
IP Logged
 
evgesh
YaBB Newbies
*
Offline


Stoneburner

Posts: 5
Joined: Jan 22nd, 2007
Re: Drag&Drop problem
Reply #6 - May 29th, 2007 at 12:14pm
Print Post  
Hello Stoyan,

I think I found the reason for this problem. If the "Document" property of ShapeToolBar is not set the drag&drop works fine. As soon as the property is set flowchart allows drag&drop only from set ShapeToolBar, but not from another control like TreeView et al. Can you corroborate this hypothesis?
Can the "Document" property be reset several times?

Eugen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #7 - May 29th, 2007 at 12:45pm
Print Post  
Hi Eugen,

Perhaps you are right; currently the ShapeToolbar code that handles drag-and-drop looks like this

private void OnDocumentDragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
     if (e.Data.GetDataPresent(typeof(ShapeTemplate)))
           e.Effect = DragDropEffects.Copy;
     //else
           //e.Effect = DragDropEffects.None;
}

so it seems older versions of the code set the drop-effect to none. You should still be able to work-around that by attaching your drag-and-drop event handlers after the ShapeToolbar.Document is set.

Stoyan
  
Back to top
 
IP Logged
 
evgesh
YaBB Newbies
*
Offline


Stoneburner

Posts: 5
Joined: Jan 22nd, 2007
Re: Drag&Drop problem
Reply #8 - May 29th, 2007 at 1:38pm
Print Post  
Ok, Stoyan, that was the reason! It works now!

Thank you very much for help!
  
Back to top
 
IP Logged
 
mjweyland
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Apr 2nd, 2007
Re: Drag&Drop problem
Reply #9 - Jun 19th, 2007 at 1:30pm
Print Post  
I too am having a peculiar issue with drag and drop with respect to DevExpress and dragging from a gridview.

Once an item is dragged over from the gridview it copies and puts a new instance of that object in the grid workspace.  however if no other item is clicked prior to moving that object the drag drop process repeats and the system creates a new instance of the just copied object. 

Any help is greatly appreciated.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #10 - Jun 19th, 2007 at 3:53pm
Print Post  
Do you call DoDragDrop yourself from the gridview MouseDown event handler, or is there some built-in feature that automatically starts drag-and-drop?

Stoyan
  
Back to top
 
IP Logged
 
mjweyland
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Apr 2nd, 2007
Re: Drag&Drop problem
Reply #11 - Jun 19th, 2007 at 4:11pm
Print Post  
On the mouse down event I call the DoDragDrop event myself. 

DoDragDrop(New NodeDragItem(_n.Copy), DragDropEffects.Copy)

where _n is my node object that inherits from flowchartnode.

  
Back to top
 
IP Logged
 
mjweyland
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Apr 2nd, 2007
Re: Drag&Drop problem
Reply #12 - Jun 19th, 2007 at 4:39pm
Print Post  
then on the drop event on teh flowchart:

Code
Select All
	  If e.Data.GetDataPresent(NodeDragItem._GetType()) Then
		e.Effect = DragDropEffects.Copy
	  Else
		e.Effect = DragDropEffects.None
	  End If
 



  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drag&Drop problem
Reply #13 - Jun 20th, 2007 at 5:57am
Print Post  
So is the problem that _n always refers to the last selected item, and not the one from which dragging has started?

Stoyan
  
Back to top
 
IP Logged
 
mjweyland
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Apr 2nd, 2007
Re: Drag&Drop problem
Reply #14 - Jun 20th, 2007 at 11:53am
Print Post  
on the Initial DoDragDrop _n refers to an object that does not yet live on the flowchart area and is not a selected item as of yet (with respect to the flowchart space). 

On the Drop aspect of the process:  The copied node is drawn on the workflow space, then becomes the selected node on a flowchart. 

If that node is then moved the drag drop process starts over again and the new node is replicated on the workflow space.

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint