Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Diagram Arrange (Read 4682 times)
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Diagram Arrange
Jan 15th, 2009 at 5:27pm
Print Post  
Hi
For long time i am playing with this tool.

I am placing my nodes in Horizontal order, instead of using layout and linking them with bezier links.

I am positioning the node at the middle of the diagramView
Diagram.MeasureUnit = Millimeter
float posY = diagramView.Bounds.Height / 2;

because if I use PosY=0 then some part of diagram goes out of upper bound of DiagramView
then I do

diagramView.ZoomToFit();

but when I have only one node on my view its looks very Big i mean accupies whole screen.

Somehow this functionality screwd up, also when i do Zoom.
Is there any auto arrage for created diagram
like there is for Layout.

If I dont use ZoomToFit then it Diagrams are very small, for one node it just shows one dot on the screen.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Arrange
Reply #1 - Jan 16th, 2009 at 9:24am
Print Post  
Hi,

DiagramView.Bounds is derived from Control and is measured in pixels. You could call DiagramView.ClientToDoc(DiagramView.ClientRectangle) to find the visible area of the view in diagram coordinates. This will let you center the nodes correctly, without having to resort to ZoomToFit.

Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: Diagram Arrange
Reply #2 - Jan 16th, 2009 at 5:39pm
Print Post  
that help me a little to avoid unecessary zoomed nodes.

but i want to get rid of this scroll bar.
i mean even i have only one node the view doent get rearraged according what we have in diagram.

I need to scroll down to see those nodes structure

I know because i am calculating the Y position of the node at the hight/2 as posted in previous post.

is there any way to show the diagram properly without scrolling if it can fits in the screen,
and after zooming if it is going out of screen want to show scroll bar.

and if initially diagram is not fitting then show the scrollbar.

Please provide sample code
thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Arrange
Reply #3 - Jan 18th, 2009 at 10:04am
Print Post  
This works for me:

Code
Select All
diagramView.ZoomToFit();

RectangleF newBounds = diagramView.ClientToDoc(diagramView.ClientRectangle);
newBounds.Width -= 1;
newBounds.Height -= 1;
diagram.Bounds = newBounds;
 



Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: Diagram Arrange
Reply #4 - Jan 20th, 2009 at 8:36pm
Print Post  
somehow it worked when i set the diagram.Size properly so it should not show scrollbar in designView of the form.

but I really need some dynamic position, as if there are more link and if i set Y=diagram.Bound.hight/2 then upper part of my diagram goes out of bound.
In this result if you observed
1. link are out of upper bound
2. Vertical scroll is missing
What i expect is diagram should be shown propely on upper left side of the view.

like Layout.Arrage does


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Arrange
Reply #5 - Jan 21st, 2009 at 5:50am
Print Post  
Find the topmost Y position of your links and add it to Diagram.Bounds:

Code
Select All
RectangleF r1 = diag.Bounds;
RectangleF r2 = diag.Bounds;
r1.Y = linksTopmostY;
diag.Bounds = RectangleF.Union(r1, r2);
 



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


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: Diagram Arrange
Reply #6 - Jan 21st, 2009 at 2:53pm
Print Post  
BezierLinks have 4 points to define its corve.

Is it fine if I use point[1] or point[2] as top most y-cordinate?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Arrange
Reply #7 - Jan 21st, 2009 at 3:03pm
Print Post  
They won't give you exactly the topmost point of the curve, but should be good enough approximation. To get the exact point, apply the Cubic Bézier curves formula here for t = 0.5:
http://en.wikipedia.org/wiki/B%C3%A9zier_curve
where the Pi points correspond to what you have in ControlPoints.

Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: Diagram Arrange
Reply #8 - Jan 22nd, 2009 at 5:47pm
Print Post  
Now I am doing this,
Code
Select All
diagram.ClearAll();
float posY = diagram.Bounds.Height / 2;
posX=0;
 ShapeNode baseNode = diagram.Factory.CreateShapeNode(posX, posY, 30, 20);
//loop for all nodes
//drawing Baizer links
 if (diagram.Bounds.Width > diagramView.ClientRectangle.Width)



  diagramView.ZoomToFit();


    else



  diagramView.ClientToDoc(diagramView.ClientRectangle); 



working fine, except if there are many nodes, the problem i am facing is:
I have one more tab besides this DiagramView
so when i first time launch the this two tab view switch the DiagramView tab it shows me half picture most of the part goes out of upper bound (ref. 1st Image), but when i switch back to another tab and back to DiagramView, the daigram is perfect (ref.2nd Image).



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram Arrange
Reply #9 - Jan 23rd, 2009 at 6:26am
Print Post  
Try to set the view's ScrollX and ScrollY properties to the diagram's Bounds top-left corner after you change Bounds.
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: Diagram Arrange
Reply #10 - Jan 23rd, 2009 at 2:29pm
Print Post  
Yes, so far it is working fine.
thanks alot.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint