Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) ZoomToFit + Text in ControlNodes (Read 4784 times)
mbuechler
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
ZoomToFit + Text in ControlNodes
May 14th, 2010 at 12:24pm
Print Post  
Hi...

I have some questions about Zooming the diagramview.

Info: On my diagram there are Only ControlsNodes and Links. So no other kind of Items.

1.) When I do the ZoomToFit function after the content of the diagram is loaded there is no change of size. I defined all Items in the top left corner and I thought with this function the Items should be zoomed in until is fills the whole drawing area of the diagram. What can I do?

2.) When I use the Zoom(float factor) function the zooming works. but text which is displayed on a control that is inside the controlnode was not zoomed in. What posibilities do I have to do a real Zoom in, so that the text is zoomed too?

Maybe it is usefull to know why I need this. The diagram is defined on a standard monitor, but displayed later on a larger Display and in fullscreen. When defining the diagram we do not know the resolution of the target display. so does someone know a good method to resize the diagram best?

thanks for all help.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToFit + Text in ControlNodes
Reply #1 - May 14th, 2010 at 1:16pm
Print Post  
Hi,

1. This works for me. Are you sure you are calling ZoomTofit on the same view that displays the diagram?

2. We don't know of any way to automatically scale a control's content in Windows Forms. If the controls you are using provide some kind of Zoom property, you can update it in response to the view's ZoomFactorChanged event, e.g.

Code
Select All
private void diagramView_ZoomFactorChanged(object sender, EventArgs e)
{
	foreach (DiagramNode node in diagram.Nodes)
	{
		ControlNode controlHost = node as ControlNode;
		if (controlHost != null)

			(controlHost.Control as MyControl).Zoom = diagramView.ZoomFactor;
	}
} 



Stoyan
  
Back to top
 
IP Logged
 
mbuechler
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
Re: ZoomToFit + Text in ControlNodes
Reply #2 - May 19th, 2010 at 7:10am
Print Post  
Hi.

1.) It seems, that the diagram is not in the full size as the underlying diagramView. Is there a function to size the diagram like the diagramView?

2.) Is there a possibility to use something like an anchoring. I mean this way you can use anchoring in the Designer of Visual Studio. Top, left,....

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToFit + Text in ControlNodes
Reply #3 - May 19th, 2010 at 7:28am
Print Post  
Hi,

1) Call ClientToDoc(view.ClientRectangle) while ZoomFactor == 100 to get the view size in MeasureUnit units, and then set the diagram's size to the minimum if its current size and the one found for the view.

2) Try using the AttachTo (node, GroupAnchorStyles) method. You can use a combination of GroupAnchor flags to anchor to several edges.

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


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
Re: ZoomToFit + Text in ControlNodes
Reply #4 - May 19th, 2010 at 7:44am
Print Post  
With the AttachTo method I only can anchor nodes to other nodes, right? What I need is to anchor Nodes to the underlying DiagramView. So that when the DiagramView is resized hte Nodes also change size (for example). Just like in Visual Studio.
Or did I misunderstood your proposal?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToFit + Text in ControlNodes
Reply #5 - May 19th, 2010 at 7:49am
Print Post  
Right. If you need to attach to the view edges, you can implement that by updating the bounds of these nodes in response to the ScrollChanged event. Again use ClientToDoc(ClientRectangle) to find the viewport position within the diagram.

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


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
Re: ZoomToFit + Text in ControlNodes
Reply #6 - May 19th, 2010 at 8:30am
Print Post  
I can't follow you. First I think I need the ResizeEvent. Because I want the nodes to resize/reposition when thie diagramView changed size.
Second what I do not understand is how I can use the clientToDoc MEthod. I think I have to do following:

diagramView1.ClientToDoc(form1.Bounds);

Right? But what do I have to do then?

Sorry about my ingorance Wink

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToFit + Text in ControlNodes
Reply #7 - May 19th, 2010 at 8:48am
Print Post  
Yes, you'll probably need to handle the Resize event too. For example this keeps a node at the lower-right corner of the view:

Code
Select All
private void UpdateAnchoredNodes()
{
	RectangleF v = diagramView.ClientToDoc(diagramView.ClientRectangle);
	RectangleF b = anchoredNode.Bounds;
	b.X = v.Right - b.Width;
	b.Y = v.Bottom - b.Height;
	anchoredNode.Bounds = b;
}

private void diagramView_Resize(object sender, EventArgs e)
{
	UpdateAnchoredNodes();
}

private void diagramView_ScrollChanged(object sender, System.EventArgs e)
{
	UpdateAnchoredNodes();
} 



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


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
Re: ZoomToFit + Text in ControlNodes
Reply #8 - May 19th, 2010 at 9:27am
Print Post  
Yes, thats exactly what I need. On this base I think I can implement this Anchoring Algorithm.

Thanks a lot.
  
Back to top
 
IP Logged
 
mbuechler
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 39
Joined: Oct 21st, 2009
Re: ZoomToFit + Text in ControlNodes
Reply #9 - May 20th, 2010 at 9:39am
Print Post  
Hi again.

I have another question about Sizing  Smiley

I recognized that the diagram is not the same Size as the underlying DiagramView(diagram is smaller). Is there a property where you can say, that the diagram should always fill the whole diagramview? But it should not be bigger than diagramView...

The diagramView is lying on a usercontrol with docktype = fill. So when resizing the control, the diagramView will be resized.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToFit + Text in ControlNodes
Reply #10 - May 20th, 2010 at 9:51am
Print Post  
Hi,

There isn't such property. You'll have to handle the view's Resize event, call ClientToDoc(view.ClientRectangle) while ZoomFactor == 100 to get the view size in MeasureUnit units, and then set the diagram's Bounds to the minimum if its current size and the one found for the view.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint