Exemplo n.º 1
0
        /// <summary>
        /// executes placement on the table set columns width according to placement this method is based on
        /// On_Table_Placement from gui_table.cpp
        /// </summary>
        /// <param name="tablecontrol"></param>
        /// <param name="columns"></param>
        /// <param name="prevWidth">previous table width </param>
        /// <param name="dx">width change </param>
        /// <param name="newRect">new table rectangle </param>
        /// <param name="considerEditors"></param>
        /// <param name="maxColumnWithEditor"></param>
        /// <param name="tablePlacementStrategy"></param>
        public void executePlacement(TableControl tablecontrol, List <ILogicalColumn> columns, int prevWidth, int dx, Rectangle newRect, bool considerEditors, int maxColumnWithEditor, TablePlacementStrategy tablePlacementStrategy)
        {
            int logSize;
            int NCWidth  = tablecontrol.Width - tablecontrol.ClientRectangle.Width;
            int newWidth = newRect.Width - NCWidth;

            logSize    = getLogSize(columns);
            prevWidth -= NCWidth;

            // Leave space for vertical scrollbar if newWidth > logical size of columns.
            // This is needed post-2.5 because since then vertical scrollbar is shown dynamically (depending on whether no. of records > no. of rows)
            // If scrollbar isn't taken into account, then there can be situations where, after applying placement, columns will occupy entire
            // table width and then vertical scrollbar is displayed if few records are created. The problem is that in such
            // situations, even horizontal scrollbar is shown (because now vertical scrollbar is occupying some space from last column)
            // Since the whole purpose is to avoid showing horizontal scrollbar while showing vertical scrollbar, this should be done only if
            // horizontal scrollbar isn't visible
            if (!tablecontrol.IsHorizontalScrollBarVisible)
            {
                if (logSize < newWidth - SystemInformation.VerticalScrollBarWidth)
                {
                    newWidth -= SystemInformation.VerticalScrollBarWidth;
                }
                // Similarly, if logical size of columns > prevWidth, scrollbar width shouldn't be considered for placement
                if (logSize > prevWidth + SystemInformation.VerticalScrollBarWidth)
                {
                    prevWidth -= SystemInformation.VerticalScrollBarWidth;
                }
            }

            if (prevWidth < logSize)
            // scroll bar is present
            {
                if (logSize > newWidth)
                {
                    // scroll bar is still present after the resize
                    dx = 0;
                }
                // scrollbar will be removed after resize
                else
                {
                    if (dx > 0)
                    {
                        dx -= (logSize - prevWidth);
                    }
                }
            }

            if (dx >= 0)
            {
                SetTableControlBounds(tablecontrol, newRect);
            }

            // Handle Row Placement
            if (tablecontrol.HasRowPlacement)
            {
                tablecontrol.ComputeAndSetRowHeight();
            }

            if (dx != 0)
            {
                ExecutePlacement(tablecontrol, columns, dx, newRect, considerEditors, maxColumnWithEditor, tablePlacementStrategy);
            }

            if (dx < 0)
            {
                SetTableControlBounds(tablecontrol, newRect);
            }
        }