Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Move and delete Node in Diagram (Read 13278 times)
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Move and delete Node in Diagram
Feb 11th, 2008 at 5:27pm
Print Post  
Hi Stoyan,

I noticed that in the Demo projects, some nodes in the diagram can be moved and deleted. But some nodes can not be moved and deleted.
I tried to write a prototype similar to drag and drop nodes to the diagram. But all the nodes created can not be moved and deleted.

Would you please tell me what kind of properties do I need to set to move and delete created nodes?

Thanks a lot!
« Last Edit: Feb 11th, 2008 at 6:48pm by chris »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move and delete Node in Diagram
Reply #1 - Feb 12th, 2008 at 6:26am
Print Post  
Hi,

It should depend on the Locked and EnabledHandles properties whether the user is allowed to move a node. Could you post here the code you are using to create your nodes?

Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Move and delete Node in Diagram
Reply #2 - Feb 12th, 2008 at 1:08pm
Print Post  
I tried 2 ways.
1. Create a node with image + text
2. Just text
I think the Locked property is default to false.
Basically, I copy and paste the code from the demo project.

Thank you very much.


   void diagram_Drop(object sender, System.Windows.DragEventArgs e)
     {

        Point p = e.GetPosition(diagram);
        Point pt = diagram.ClientToDoc(p);

        if (e.Data.GetDataPresent(typeof(Image)))
        {
           Image i = (Image)e.Data.GetData(typeof(Image));
           ShapeNode b = diagram.Factory.CreateShapeNode(pt.X, pt.Y, 30, 30);
           b.Image = i.Source as BitmapSource;
           b.ResizeToFitImage();
           b.Transparent = true;
           ShapeNode bb = diagram.Factory.CreateShapeNode(
               pt.X - 10, pt.Y + b.Bounds.Height,
               b.Bounds.Width + 20, 5);
           bb.AttachTo(b, AttachToNode.BottomLeft);
           bb.Locked = false;
           bb.Transparent = true;
           bb.Text = "From image";
        }
        else if (e.Data.GetDataPresent(DataFormats.Text))
        {
           string s = (string)e.Data.GetData(DataFormats.Text);
           ShapeNode b = diagram.Factory.CreateShapeNode(pt.X, pt.Y, 30, 5);
           b.Text = s;
        }
    }
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Move and delete Node in Diagram
Reply #3 - Feb 12th, 2008 at 1:10pm
Print Post  
I tried to add
b.EnabledHandles = AdjustmentHandles.Move;
It still doesn't work.

Are there some properties in the Diagram to control move and delete?

Also, I can't delete the node with del key. There is no response when I select and delete it with del key.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move and delete Node in Diagram
Reply #4 - Feb 12th, 2008 at 1:52pm
Print Post  
Please try that with the latest build of the control:
https://mindfusion.org/_beta/MindFusion.Diagramming.Wpf.zip

Does it work any better?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Move and delete Node in Diagram
Reply #5 - Feb 12th, 2008 at 2:50pm
Print Post  
Hi Stoyan,

It still doesn't work.

The nodes can be moved.
I can't delete the node at the first time.
But I can delete it when I select press Del key the second time.
For the node with image and text, just the image is deleted. I can't delete the associated text.

I've send you the whole solution to support@mindfusion.eu.

Thank you very much!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move and delete Node in Diagram
Reply #6 - Feb 12th, 2008 at 4:03pm
Print Post  
Hi Chris,

HandlesStyle == DashFrame reserves a couple of millimeters near the node borders for drawing links, and the rest of the node interior can be used for moving nodes. This does not work in your case because the shapes are too narrow and their whole area is reserved for drawing links. Check if decreasing the HandlesSize value fixes that. If it doesn't, use another HandlesStyle or create larger nodes.

For Del to work, the Diagram control must have the keyboard focus. Every time you drag from the list, the focus goes to the list control, so you must click the diagram again to move the focus there (or use TAB).

After attaching the text node, set b.SubordinateGroup.AutoDeleteItems = true to have both nodes deleted when you press Del.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Move and delete Node in Diagram
Reply #7 - Feb 12th, 2008 at 4:48pm
Print Post  
Hi Stoyan,

Thank you very much!

After I changed the HandlesStyle == EasyMoce,
the move and delete operation work fine.

But I found another problem, every time I drag and drop, it creates 2 nodes. You can try the project I sent to you. ( I didn't see it before because I can't move the node.)

Thanks again!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move and delete Node in Diagram
Reply #8 - Feb 12th, 2008 at 5:45pm
Print Post  
Perhaps the event is raised for a second time if you do not set the DragEventArgs.Effects property?
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Move and delete Node in Diagram
Reply #9 - Feb 12th, 2008 at 8:30pm
Print Post  
Thanks.

There are 2 Drag Events raised.
After I set "e.Handled = true" in the DragEventHandler, it works.

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