Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Not sure if this is a bug? (Read 2272 times)
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Not sure if this is a bug?
Feb 5th, 2008 at 9:34am
Print Post  
Hi guys, I have been working on something and ive isolated an issue that doesn't seem right to me... i might be doing something wrong but it seems pretty straight forward.

So here it is:

Code
Select All
ShapeNode shape = new ShapeNode();
ContainerNode container = new ContainerNode();
container.Margin = 1;

m_diagram.Nodes.Add(shape);
m_diagram.Nodes.Add(container);

container.Add(shape);

//ShapeNode shape2 = new ShapeNode();
//m_diagram.Nodes.Add(shape2);
//container.Add(shape2);
 



In the code above - when you move the shapenode inside the container - it resizes it like it should, but with a large margin (as if the margin property has not been taken into consideration).

But if you comment out that last bit - it does take the margin into account...

Is there something im not getting here?

Thanks for the help Smiley
Mat
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Not sure if this is a bug?
Reply #1 - Feb 5th, 2008 at 11:49am
Print Post  
Hi Mat,

The default is to only grow the container size when nodes are placed near its edge, but never to make it smaller. In addition, the container will never become smaller than its MinimumSize value. Add this to the initialization code and the container should conform to your Margin value:

container.AutoShrink = true;
container.MinimumSize = new SizeF(10, 10);

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


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Re: Not sure if this is a bug?
Reply #2 - Feb 6th, 2008 at 10:37am
Print Post  
Hi Stoyo, thanks for the reply bud, but thats not what I actually need. The containers can be resized by the user. It's not the minimum size either - its just that oddity of not taking the margin into account when there is only 1 node inside it. The problem is that when I drag my container in, it is setup to contain 1 shape by default - it then does the resize (which is too large). When you start adding containers within containers it starts getting very messy. Its fine when you add a second node though; because then when i move things they do not resize as much :/ Any ideas?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Not sure if this is a bug?
Reply #3 - Feb 6th, 2008 at 11:33am
Print Post  
Hi,

The container's code looks like this:

if (result.Width < minimumSize.Width)
     result.Width = minimumSize.Width;
if (result.Height < minimumSize.Height)
     result.Height = minimumSize.Height;

if (autoShrink)
     return result;
else
     return Rect.Union(result, GetBounds());

"result" contains the bounding rectangle of all child nodes. It seems your problem happens because of setting the container rectangle to the union of the old container rectangle and "result". I don't know if that's correct - our developer will check it. You can still avoid getting strange-looking results by setting smaller MinimumSize for the container, so that the statements in the "if" blocks are not executed. Everything seems to work fine if you add this to the initialization code, and the position set by the user is preserved too:

container.MinimumSize = shape.Bounds.Size;

I hope that helps.
Stoyan
  
Back to top
 
IP Logged
 
SavyCat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 38
Joined: Sep 4th, 2007
Re: Not sure if this is a bug?
Reply #4 - Feb 6th, 2008 at 3:42pm
Print Post  
Cool thanks Stoyo - i managed to get the behavior I needed. Thanks again bud Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Not sure if this is a bug?
Reply #5 - Feb 25th, 2008 at 8:55am
Print Post  
Hi,

This version should work fine even without changing the MinimumSize:
https://mindfusion.org/_beta/ctr_minsize.zip

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint