Set maximum size for GoBasicNode and GoButton

In my company, I developed an UI using GoDiagram. In the UI, there are many boxes connected with link. When the UI is resized, the boxes and links are resized accordingly.
The problem is when there are few boxes and UI is resized to a big size, the boxes become very large and looks bad.
In my solution, I want to put a maximum size limit on the boxes’ size to let the boxes not be so large. The boxes in the UI are some inheriting from GoBasicNode, and others from GoButton.
I tried many times but didn’t succeed finally. I’ll appreciate if anyone could give me some ideas on this!!!

When you say the “UI is resized”, are you talking about the GoView size? Are you using DocScale to change the size? or are you really changing the Size of the nodes?

Yes, there is an event handler for GoView resizing. And I will change DocScale accordingly in the handler. I couldn’t tell you the details, because I am at home now. I am in beijing, China. It’s 0:41 am here, and I must go to sleep.

I hope above information is enough for your investigation. The more information will be provide tommorrow when I come back to my company. Thanks in advance!Smile

Well, if you are changing DocScale and the nodes are getting too big, just limit the maximum for DocScale.

Extremely grateful for your help! The solution you provided is really straightforward and solve this issue.

Indeed, in my program, I operate the whole GoDocument as one object, scaling and displaying. Besides above scaling problem I also have a problem with displaying layout. I want the GoDocument is always in the center of the view.
I ever tried with the DocPosition property of GoView but failed. I think this problem is really common. Could you please show me some snap codes to achieve that?

Try this:

I tried the snap codes in the linked web page. After Ui is resized, the document is really centralized, however the result is different with different scaling.
If scale factor is less than 1.0, there will be a horizontal scroll bar at the bottom. At the beginning, the document is shifted to right a little. I must move the scroll bar left and finally the document is centralized.Besides,after scroll bar moving, the scroll bar disappears.
Before scrolling snapshot:

After scrolling snapshot:
If scale factor is equal to 1.0(I put 1.0 as the maximum value of scale factor as you suggested), the document is centralized correctly after Ui is resized.

The GoView is added into an user control. I use the user control’s resizing handler to do above behavior. The main code of the handler is pasted below:
RectangleF bounds = m_DFDView.Document.ComputeBounds();
m_DFDView.Document.TopLeft = bounds.Location;
m_DFDView.Document.Size = bounds.Size;
m_DFDView.DocPosition = m_DFDView.Document.TopLeft;

        //Rescale to let the whole width of the page as visible
        float hScale = (m_DFDView.DocExtentSize.Width + m_DFDView.DocPosition.X) * m_DFDView.DocScale / m_DFDView.DocumentSize.Width;
        if (hScale > 1.0f)
            hScale = 1.0f;
        m_DFDView.DocScale = hScale;


So my question is how to let the document’s top left is just located at the top left of the user control?

Have you done this anywhere?

goView1.SheetStyle = GoViewSheetStyle.Sheet; // allow scrolling beyond end of document bounds

I added above line code when the user control initializes components, and below are the related codes:
m_DFDView.AllowMove = false;
m_DFDView.AllowSelect = false;
m_DFDView.ArrowMoveLarge = 10F;
m_DFDView.ArrowMoveSmall = 1F;
m_DFDView.BackColor = System.Drawing.Color.White;
m_DFDView.Dock = System.Windows.Forms.DockStyle.Fill;
m_DFDView.Location = new System.Drawing.Point(0, 0);
m_DFDView.Name = “m_DFDView”;
m_DFDView.Size = new System.Drawing.Size(376, 387);
m_DFDView.Text = “Test”;
m_DFDView.SheetStyle = GoViewSheetStyle.Sheet;

Besides, I forget to tell you my GoDiagram library version is

Through debugging, I finally got the answer. The reason is that the function CenterDoc is scaling dependent indeed:
public virtual void CenterDoc()
RectangleF docb = this.Document.ComputeBounds();
Size viewsz = this.ClientSize;
this.DocPosition = new PointF(docb.X + docb.Width / 2 - viewsz.Width / 2,

I revised above codes to below and passed it the current scale factor of the GoView during running, then it works:
public virtual void CenterDoc(float scaleFactor)
RectangleF docb = this.Document.ComputeBounds();
Size viewsz = this.ClientSize;
this.DocPosition = new PointF(docb.X * scaleFactor+ docb.Width * scaleFactor / 2 - viewsz.Width / 2,

This is the end of all my problems. I really thank for your great and very useful help.

ok. 2.4 is a very old version, you may want to contact gosales to see about upgrading.

Yes, it’s really old. I think some guys in my team will decide whether to upgrade to a higher version. Anyway, thank you very much for your helps.