Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Issues. (Read 5058 times)
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Issues.
Mar 24th, 2009 at 10:03am
Print Post  
Hi,

I need to incorporate two requirements in my application which are as follows :

1. The diagram should resize to fit all items in the diagram's visible area.

2. At the same time the diagram should always align to the top left corner of the client area (Client UI).

Any suggestions how can I incorporate these two requirement.

Thanks and Regards.
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues.
Reply #1 - Mar 24th, 2009 at 3:06pm
Print Post  
Hi,

Set these properties to align the diagram to the top and left of the ScrollViewer:

diagram.HorizontalAlignment = HorizontalAlignment.Left;
diagram.VerticalAlignment = VerticalAlignment.Top;

and call these methods to fit all items in the visible area:

diagram.ResizeToFitItems(10);
diagram.ZoomToFit();

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


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Issues.
Reply #2 - Mar 24th, 2009 at 3:56pm
Print Post  
Hi Stoyan,

With the previous requirements I also need  the diagram should always remain fit to the client area it should always fit exact on to the container on which its placed. Applying your suggestion from last post moves the complete diagram moves to the left of the containers area leaving lot of space which is not desired.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues.
Reply #3 - Mar 24th, 2009 at 6:41pm
Print Post  
After zooming, set the Bounds' Width and Height to the ScrollViewer's ActualWidth and ActualHeight converted to diagram coordinates using ClientToDoc.
  
Back to top
 
IP Logged
 
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Issues.
Reply #4 - Mar 25th, 2009 at 4:56am
Print Post  
Hi Stoyan,

Thanks for the vital help.

Definitely your suggestion has done the trick.

But there is another requirement the same requirement of the diagram to fit to the containers area and all the items should be fitted to the visible area is required but now at the initialization of the diagram. The same code would work surely but here I have included the following lines to show the nodes placed at negative coordinates :


Rect diagBounds = diagram.Bounds;
Rect rect = diagram.GetContentBounds(false, false);

diagBounds.Union(rect);
diagram.Bounds = diagBounds;

diagram.ScrollTo(rect.TopLeft);

The code used for the zoom to fit functionality is as follows :

private void btnZoomToFit_Click(object sender, RoutedEventArgs e)
{
diagram.HorizontalAlignment = HorizontalAlignment.Left;
diagram.VerticalAlignment = VerticalAlignment.Top;
diagram.ResizeToFitItems(10);
diagram.ZoomToFit();
Rect newBounds = diagram.ClientToDoc(
new Rect(0, 0, scrollViewer.ActualWidth, scrollViewer.ActualHeight));
diagram.Bounds = newBounds;
}

Any suggestions how can I resolve the issue and integrate both these codes together so that all the items on the diagram fit to the visible area of the diagram and the diagram itself fit to the client area.

Also few more issues :

1. When I say zoom to fit by click of a button the scrollbar should also disappear as there is no sense of it.

2. Also presently my diagram stretches  in the direction when I hold the left click of the mouse and drag the pointer which is not desired.

3. When the items on the diagram already fit into the diagram's visible area and I say zoom to fit then the diagram gets resized and items gets zoomed which is not desired. In this situation the diagram should remain as it was before.

Any suggestion how can I accomplish these.

Thanks and Regards,
Anant Shukla.
« Last Edit: Mar 25th, 2009 at 9:36am by Anant_Shukla »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues.
Reply #5 - Mar 25th, 2009 at 9:35am
Print Post  
Code
Select All
Rect diagBounds = diagram.Bounds;
Rect rect = diagram.GetContentBounds(false, false);
Size scrSize = new Size(scrollViewer.ActualWidth, scrollViewer.ActualHeight);

diagBounds.Union(rect);
diagram.Bounds = diagBounds;

diagram.ResizeToFitItems(0);
diagram.ZoomToFit();

Rect newRect = diagram.ClientToDoc(new Rect(new Point(0, 0), scrSize));

diagBounds = diagram.Bounds;
diagBounds.Union(newRect);
diagram.Bounds = diagBounds;
 



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


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Issues.
Reply #6 - Mar 25th, 2009 at 9:42am
Print Post  
Hi Stoyan,

The code from your last post is not working.

Also I have few more issues which are as follows :

1. When I say zoom to fit by click of a button the scrollbar should also disappear as there is no sense of it.

2. Also presently my diagram stretches  in the direction when I hold the left click of the mouse and drag the pointer which is not desired.

3. When the items on the diagram already fit into the diagram's visible area and I say zoom to fit then the diagram gets resized and items gets zoomed which is not desired. In this situation the diagram should remain as it was before.

Any suggestion how can I accomplish these.

Thanks and Regards,
Anant Shukla.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues.
Reply #7 - Mar 25th, 2009 at 3:12pm
Print Post  
It works for me and I won't spend more time on the hundreds of zoom requirements you have. We'll add some kind of fit-to-container property when we have a developer available for this.
  
Back to top
 
IP Logged
 
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Re: Issues.
Reply #8 - Mar 26th, 2009 at 4:41am
Print Post  
Hi Stoyan,

Surely such a property will help a lot.

But thanks for all the vital suggestions. It really helped a lot.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint