Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ZoomToRect issue (Read 2873 times)
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
ZoomToRect issue
Aug 23rd, 2013 at 6:49pm
Print Post  
Hi Stoyan,

I met another issue in Zooming.
When I try to zoom the diagram view to a certain rectangle (union of some nodes bounds rectangle), the scrollbar will cover a portion of rectangle. It looks like the scrollbar area were not taken into account. I'm using the diagram 6.0.3.

See the screen shots and here's the code of "Zoom to Show All Nodes" button:

Code (C++)
Select All
        private void zoomToShowAllNodes_Click(object sender, EventArgs e)
        {
            RectangleF rect = new RectangleF(0, 0, 0, 0);
            foreach (DiagramNode item in diagram1.Nodes)
            {
                if (rect.IsEmpty)
                    rect = item.Bounds;
                else
                    rect = RectangleF.Union(rect, item.Bounds);
            }
            diagramView1.ZoomToRect(rect);
        } 



Thanks,

Kyle
  

ZoomToRect.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToRect issue
Reply #1 - Aug 24th, 2013 at 10:22am
Print Post  
Hi,

You can compensate for the scrollbars' area by multiplying ZoomFactor by the (view size - scrollbar) / (view size) ratio:

Code
Select All
diagramView.ZoomToRect(rect);
diagramView.ZoomFactor *= Math.Min(
	1 - (float)diagramView.VScrollBar.Width / diagramView.Width,
	1 - (float)diagramView.HScrollBar.Height / diagramView.Height); 



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


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: ZoomToRect issue
Reply #2 - Aug 28th, 2013 at 3:54pm
Print Post  
Thank you, it works perfect!
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: ZoomToRect issue
Reply #3 - Aug 31st, 2013 at 7:01am
Print Post  
If I may, I think that this should be taken into account automatically by the component. For the end user, the visible area is not the window including the scollbars, but only the area inside the scrollbars.

Similarly, it would be nicer if the horizontal scrollbar would extend to the far left and the vertical ruler would stop above the scrollbar.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZoomToRect issue
Reply #4 - Sep 3rd, 2013 at 8:33am
Print Post  
Quote:
Similarly, it would be nicer if the horizontal scrollbar would extend to the far left and the vertical ruler would stop above the scrollbar.


Currently the scrollbars are child controls of DiagramView, and DiagramView is a child of Ruler, so they cannot stick out from the view to align with the ruler scales. However you could implement that by moving the scrollbars from the view to the parent form. E.g. assuming the form contains only a Ruler that fills it, this should align the scrollbars to that ruler:

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	diagramView.Controls.Remove(diagramView.HScrollBar);
	this.Controls.Add(diagramView.HScrollBar);
	diagramView.HScrollBar.Dock = DockStyle.Bottom;

	diagramView.Controls.Remove(diagramView.VScrollBar);
	this.Controls.Add(diagramView.VScrollBar);
	diagramView.VScrollBar.Dock = DockStyle.Right;
} 



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