Exemplo n.º 1
0
        virtual protected void UpdateBounds()
        {
            float ax, ay, aw, ah;

            if (_children.Count > 0)
            {
                ax = int.MaxValue;
                ay = int.MaxValue;
                float ar = int.MinValue, ab = int.MinValue;
                float tmp;

                int cnt = _children.Count;
                for (int i = 0; i < cnt; ++i)
                {
                    GObject child = _children[i];
                    child.EnsureSizeCorrect();
                }

                for (int i = 0; i < cnt; ++i)
                {
                    GObject child = _children[i];
                    tmp = child.x;
                    if (tmp < ax)
                    {
                        ax = tmp;
                    }
                    tmp = child.y;
                    if (tmp < ay)
                    {
                        ay = tmp;
                    }
                    tmp = child.x + child.actualWidth;
                    if (tmp > ar)
                    {
                        ar = tmp;
                    }
                    tmp = child.y + child.actualHeight;
                    if (tmp > ab)
                    {
                        ab = tmp;
                    }
                }
                aw = ar - ax;
                ah = ab - ay;
            }
            else
            {
                ax = 0;
                ay = 0;
                aw = 0;
                ah = 0;
            }

            SetBounds(ax, ay, aw, ah);
        }