src/Misc/EFTools/DesignXmlCore/Base/Shell/TreeGridDesignerTreeControl.cs
/// <summary>
///     Set the columns to be displayed by the tree control
/// </summary>
/// <param name="columns"></param>
Set the columns to be displayed by the tree control
Set the columns to be displayed by the tree control
internal void SetColumns(TreeGridDesignerColumnDescriptor[] columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }
            if (CurrentColumn >= columns.Length)
            {
                CurrentColumn = 0;
            }
            _currentColumns = columns;
            var percentages = new float[columns.Length];
            var calculatedPercentage = 1.0F;
            var calculatedColumns = columns.Length;
            for (var i = 0; i < columns.Length; i++)
            {
                var columnPercentage = columns[i].InitialPercentage;
                if (columnPercentage != TreeGridDesignerColumnDescriptor.CalculatePercentage)
                {
                    if (columnPercentage > calculatedPercentage)
                    {
                        percentages[i] = -1;
                        continue; 
                    }
                    calculatedPercentage -= columnPercentage;
                    calculatedColumns--;
                    percentages[i] = columnPercentage;
                }
                else
                {
                    percentages[i] = -1;
                }
            }
            var defaultPercentageIncr = calculatedColumns == 0 ? 0 : calculatedPercentage / calculatedColumns;
            var headers = new VirtualTreeColumnHeader[columns.Length];
            float percentage = 0;
            for (var i = 0; i < headers.Length - 1; ++i)
            {
                if (percentages[i] == -1)
                {
                    percentage += defaultPercentageIncr;
                }
                else
                {
                    percentage += percentages[i];
                }
                if (columns[i].ColumnIsCheckBox)
                {
                    headers[i] = new VirtualTreeColumnHeader(columns[i].Name, percentage, StateImageList.ImageSize.Width);
                }
                else
                {
                    headers[i] = new VirtualTreeColumnHeader(columns[i].Name, percentage);
                }
            }
            headers[headers.Length - 1] = new VirtualTreeColumnHeader(columns[headers.Length - 1].Name, 1f);
            SetColumnHeaders(headers, false);
        }
internal void SetColumns ( TreeGridDesignerColumnDescriptor [ ] columns ) { if ( columns == null ) { throw new ArgumentNullException ( " " ) ; } if ( CurrentColumn >= columns . Length ) { CurrentColumn = 0 ; } _currentColumns = columns ; var percentages = new float [ columns . Length ] ; var calculatedPercentage = 1.0F ; var calculatedColumns = columns . Length ; for ( var i = 0 ; i < columns . Length ; i ++ ) { var columnPercentage = columns [ i ] . InitialPercentage ; if ( columnPercentage != TreeGridDesignerColumnDescriptor . CalculatePercentage ) { if ( columnPercentage > calculatedPercentage ) { percentages [ i ] = - 1 ; continue ; } calculatedPercentage -= columnPercentage ; calculatedColumns -- ; percentages [ i ] = columnPercentage ; } else { percentages [ i ] = - 1 ; } } var defaultPercentageIncr = calculatedColumns == 0 ? 0 : calculatedPercentage / calculatedColumns ; var headers = new VirtualTreeColumnHeader [ columns . Length ] ; float percentage = 0 ; for ( var i = 0 ; i < headers . Length - 1 ; ++ i ) { if ( percentages [ i ] == - 1 ) { percentage += defaultPercentageIncr ; } else { percentage += percentages [ i ] ; } if ( columns [ i ] . ColumnIsCheckBox ) { headers [ i ] = new VirtualTreeColumnHeader ( columns [ i ] . Name , percentage , StateImageList . ImageSize . Width ) ; } else { headers [ i ] = new VirtualTreeColumnHeader ( columns [ i ] . Name , percentage ) ; } } headers [ headers . Length - 1 ] = new VirtualTreeColumnHeader ( columns [ headers . Length - 1 ] . Name , 1f ) ; SetColumnHeaders ( headers , false ) ; }
Set the columns to be displayed by the tree control
Set the columns to be displayed by the tree control
// the current column may now be out of range.   // reset to 0 if that is the case // do initial percentage calculations. // using the initial percentage specified by this column would cause all // percentages to sum to more than 1, so we discard it. // calculate percentage increment used for columns in which the percentage // is not specified explicitly // create headers
columns
TreeGridDesignerColumnDescriptor[]
None