Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Need help on DelKeyAction and place a node on Diagram at specified location (Read 4429 times)
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Need help on DelKeyAction and place a node on Diagram at specified location
Aug 21st, 2013 at 4:22pm
Print Post  
I am doing similar thing as FlowCharter example.
I need help in two things:
1. I tried to use "delete" key on keyboard to delete a selected node. It works in the example, but doesn't work in mine. What I am missing? I tried the same thing as FlowChater for context menu delete, that works.

2. I tried to place nodes at certain coordinate on the diagram because I have comment box placed close to certain node, so I need ability to place node at exact location on diagram. I am reading those X, Y in from XML. I am trying to place on diagram by diagram.factory.createshapenode(point, size). This doesn't work. It only controls the bounds of the node. Which method controls the node location in the diagram?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #1 - Aug 21st, 2013 at 4:43pm
Print Post  
1. Have you set Focusable="False" for the parent ScrollViewer? Otherwise it acquires the keyboard focus and stops key events from reaching the diagram.

2. The point argument specifies the location of node's top-left corner, and this work fine in my test:

diagram.Factory.CreateShapeNode(new Point(50, 50), new Size(50, 50));

If you are getting wrong location, check if the point has been initialized correctly, and if you aren't moving the node later.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #2 - Aug 21st, 2013 at 7:31pm
Print Post  
Thank you, Stoyan!
1st one works!

2nd one, I tried things like:
double yloc =0;
for (var node in nodes)
{
yloc += 50;
Point pt = new Point(50, yloc);
var diagramnode = diagram.Factory.CreateShapeNode(pt, new Size(120, 40));
}

I thought the nodes should line up from top to bottom since y increases vertically, but what I got is a line from left to right horizontally. I switched x, y, I still got the same thing. For now, no link involved in. Any ideas what I did wrong?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #3 - Aug 21st, 2013 at 7:39pm
Print Post  
Your code creates nodes arranged in a vertical column for me. Check if something else doesn't move the nodes later; e.g. running layout algorithms will place the nodes in a horizontal line by default when there are no links between them.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #4 - Aug 21st, 2013 at 8:59pm
Print Post  
Thank you, Stoyan!
Now I understand what you mean by "Check if something else doesn't move the nodes later". I used LayerLayout.arrange(diagram).
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #5 - Aug 22nd, 2013 at 5:16pm
Print Post  
I have new issues with FlowLayout to arrange the nodes and links.

By using "FlowLayout" the nodes are placed correctly at specified location, but links do not look clean and neat. I compared with "FlowchartLayout" arrange way, the links are what I want, but the nodes are not placed at specified location. How can I borrow "FlowchartLayout" link rules to apply to "FlowLayout" so I can get the diagram with node at specified location and links are clean and neat? I don't know how to code this... please direct to me to the class and methods I need...

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #6 - Aug 22nd, 2013 at 5:54pm
Print Post  
You cannot reuse FlowchartLayout link arrangement for other layout classes, since it relies too much on links' and nodes' correspondence to source code constructs.

If you need to arrange only links after nodes have been arranged, try calling:

diagram.RouteAllLinks();

or:

new OrthogonalRouter().Arrange(diagram);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
esri_test
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 21st, 2013
Re: Need help on DelKeyAction and place a node on Diagram at specified location
Reply #7 - Aug 22nd, 2013 at 7:02pm
Print Post  
Thank you, Stoyan!

I used this one:
new OrthogonalRouter().Arrange(diagram);

it looks much better!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint