Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Stretch diagram (Read 3180 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Stretch diagram
Jul 20th, 2010 at 8:30am
Print Post  
Hello. I have the problem with stretch. I have the user control with Diagram object. And all alignment properties are Stretch. But when I ZoomOut diagram it doesn't stay stretched. I looks like it's alignment properies are Center, Center. I can't understand why? Can I send you the sample project for take and advice or I need to post code their. Initializing of the user control are in the xaml and in the code. That's why it may be too large...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Stretch diagram
Reply #1 - Jul 20th, 2010 at 10:21am
Print Post  
Hi,

The diagram never stretches automatically to fill its container if that's what you are asking. It is always as big as its Bounds value multiplied by the zoom level. You can handle the container's SizeChanged event and set larger diagram.Bounds value from the handler to enlarge the diagram area if necessary.

Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Stretch diagram
Reply #2 - Jul 20th, 2010 at 10:32am
Print Post  
Yes. For this purpose I use the following code:
Code
Select All
	  private void OnRuler_SizeChanged(object sender, SizeChangedEventArgs e)
	  {
		if (m_Diagram.Bounds.Width < e.NewSize.Width)
		{
		    Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
			  e.NewSize.Width, m_Diagram.Bounds.Height);
		    m_Diagram.Bounds = newBounds;
		}
	  }
 


But I have the ZoomIn and ZoomOut buttons on the toolbar. And when I press ZoomOut the diagram area decreases but the ruler size is constant... An I need to fill all area by the diagram
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Stretch diagram
Reply #3 - Jul 20th, 2010 at 10:55am
Print Post  
Move this code to a separate method and call the method from both container.SizeChanged and Diagram.ZoomFactorChanged handlers. Additionally, multiply the width and height by 100 / ZoomFactor.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Stretch diagram
Reply #4 - Jul 20th, 2010 at 11:11am
Print Post  
But Diagram.ZoomFactorChanged doens't have the NewSize property in the event arguments...
I wrote the following:
Code
Select All
	  private void OnDiagram_ZoomFactorChanged(object sender, EventArgs e)
	  {
		Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
		    m_Diagram.Bounds.Width * 100 / m_Diagram.ZoomFactor,
		    m_Diagram.Bounds.Height * 100 / m_Diagram.ZoomFactor);
		m_Diagram.Bounds = newBounds;
	  }
 


In the first look it works
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Stretch diagram
Reply #5 - Jul 20th, 2010 at 12:34pm
Print Post  
You could use the container's ActualWidth and ActualHeight properties to get its size when not in OnSizeChanged.
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Stretch diagram
Reply #6 - Jul 20th, 2010 at 12:44pm
Print Post  
Is it correct?
Code
Select All
	  private void OnDiagram_ZoomFactorChanged(object sender, EventArgs e)
	  {
		   Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
		    m_Ruler.ActualWidth * 100 / m_Diagram.ZoomFactor,
		    m_Ruler.ActualHeight * 100 / m_Diagram.ZoomFactor);
		m_Diagram.Bounds = newBounds;
#if false
		Rect newBounds = new Rect(m_Diagram.Bounds.X, m_Diagram.Bounds.Y,
		    m_Diagram.Bounds.Width * 100 / m_Diagram.ZoomFactor,
		    m_Diagram.Bounds.Height * 100 / m_Diagram.ZoomFactor);
		m_Diagram.Bounds = newBounds;
#endif
	  }
 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Stretch diagram
Reply #7 - Jul 21st, 2010 at 1:54pm
Print Post  
It looks ok. You might also make it Math.Min(current width, new width) and same for height, so that the diagram does not get smaller then its initial size when zooming in. Otherwise some nodes might remain out of the current viewport and you would not be able to scroll to them.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint