Habanero.Faces.Base.GridLayoutManager.RefreshControlPositions C# (CSharp) Method

RefreshControlPositions() protected method

Updates the positions and settings of the controls in the interface
protected RefreshControlPositions ( ) : void
return void
        protected override void RefreshControlPositions()
        {
            if (ManagedControl == null) return;
            try
            {
                ManagedControl.SuspendLayout();
                _currentPos = new Point(BorderSize, BorderSize);
                int lastColSpan = 0;
                for (int i = 0; i < _controls.Count; i++)
                {
                    int currentRow = i/ColumnCount;
                    int currentCol = i%ColumnCount;
                    IControlHabanero ctl = this._controls[i];

                    if ((i > 0) && (currentCol == 0))
                    {
                        _currentPos.X = BorderSize;
                        _currentPos.Y += this._controls[i - 1].Height + VerticalGapSize;
                    }
                    int width = 0;
                    ControlInfo ctlInfo = (ControlInfo) _controlInfoTable[ctl];
                    for (int columnNumber = currentCol;
                         columnNumber < Math.Min(this.ColumnCount, currentCol + ctlInfo.ColumnSpan);
                         columnNumber++)
                    {
                        if (IsFixedColumn(columnNumber))
                        {
                            width += _columnWidths[columnNumber];
                        }
                        else
                        {
                            width += CalcColumnWidth();
                        }
                    }
                    width += (this.HorizontalGapSize*(ctlInfo.ColumnSpan - 1));

                    int height = 0;

                    for (int rows = currentRow; rows < Math.Min(RowCount, currentRow + ctlInfo.RowSpan); rows++)
                    {
                        if (IsFixedRow(currentRow))
                        {
                            height += _rowHeights[currentRow];
                        }
                        else
                        {
                            height += CalcRowHeight();
                        }
                    }

                    height += (VerticalGapSize * (ctlInfo.RowSpan - 1));
                    //height += GapSize;

                    //ctl.Left = _currentPos.X;
                    //ctl.Top = _currentPos.Y;
                    //ctl.Width = width;
                    //ctl.Height = height;
                    ctl.Location = new Point(_currentPos.X, _currentPos.Y);
                    ctl.Size = new Size(width, height);

                    int posIncrement = 0;
                    if (lastColSpan > 1)
                    {
                        //if (IsFixedColumn(currentCol)) posIncrement = _columnWidths[currentCol];
                        lastColSpan--;
                    }
                    else
                    {
                        posIncrement = ctl.Width + HorizontalGapSize;
                        lastColSpan = ctlInfo.ColumnSpan;
                    }
                    _currentPos.X += posIncrement;
                }
            }
            finally
            {
                ManagedControl.ResumeLayout(true);
            }
        }