public ColumnGroupsCellArrangeInfo GetColumnData(
            GridViewColumn column)
        {
            if (this.systemColumns.ContainsKey(column))
            {
                ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = new ColumnGroupsCellArrangeInfo(column);
                groupsCellArrangeInfo.Bounds = this.systemColumns[column].Bounds;
                return(groupsCellArrangeInfo);
            }
            ColumnGroupLayoutNode node;
            ColumnGroupColumnData data;

            this.FindColumnNode(column, out node, out data);
            if (data == null && node != null)
            {
                ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = new ColumnGroupsCellArrangeInfo(column);
                groupsCellArrangeInfo.Group  = node.Parent.Group;
                groupsCellArrangeInfo.Bounds = node.Bounds;
                groupsCellArrangeInfo.Depth  = node.Level;
                return(groupsCellArrangeInfo);
            }
            if (data == null || node == null)
            {
                return((ColumnGroupsCellArrangeInfo)null);
            }
            ColumnGroupsCellArrangeInfo groupsCellArrangeInfo1 = new ColumnGroupsCellArrangeInfo(column);

            groupsCellArrangeInfo1.Group    = node.Parent.Group;
            groupsCellArrangeInfo1.Bounds   = node.ColumnData[column].Bounds;
            groupsCellArrangeInfo1.RowIndex = node.ColumnData[column].Row;
            groupsCellArrangeInfo1.Depth    = groupsCellArrangeInfo1.RowIndex + this.groupRowLevels + 1;
            groupsCellArrangeInfo1.Row      = groupsCellArrangeInfo1.Group.Rows == null || groupsCellArrangeInfo1.Group.Rows.Count <= groupsCellArrangeInfo1.RowIndex ? (GridViewColumnGroupRow)null : groupsCellArrangeInfo1.Group.Rows[groupsCellArrangeInfo1.RowIndex];
            return(groupsCellArrangeInfo1);
        }
 protected virtual Size GetRowSize(GridViewRowInfo row, ColumnGroupRowLayout rowLayout)
 {
     if (this.rowSize == Size.Empty)
     {
         int width1 = 0;
         int height = rowLayout.GetRowHeight(row) + this.GridView.TableElement.RowSpacing;
         foreach (GridViewColumn renderColumn in (IEnumerable <GridViewColumn>)rowLayout.RenderColumns)
         {
             if (!(renderColumn is GridViewRowHeaderColumn) && !(renderColumn is GridViewIndentColumn))
             {
                 ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData(renderColumn);
                 if (columnData != null)
                 {
                     int width2 = (int)columnData.Bounds.Width;
                     if ((double)width1 < (double)columnData.Bounds.X + (double)width2)
                     {
                         width1 = (int)columnData.Bounds.X + width2;
                     }
                 }
             }
         }
         this.rowSize = new Size(width1, height);
     }
     return(this.rowSize);
 }
Exemple #3
0
        public override SizeF GetElementSize(GridViewColumn item)
        {
            float width = (float)item.Width;

            if (item is GridViewRowHeaderColumn)
            {
                width = (float)this.rowView.RowHeaderColumnWidth;
            }
            else if (item is GridViewIndentColumn)
            {
                width = (float)this.rowView.GroupIndent;
            }
            if ((double)width < 0.0)
            {
                width = this.DefaultElementSize.Width;
            }
            if (item is GridViewGroupColumn)
            {
                ColumnGroupRowLayout rowLayout = this.rowView.ViewElement.RowLayout as ColumnGroupRowLayout;
                if (rowLayout != null)
                {
                    ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData(item);
                    if (columnData != null)
                    {
                        width = columnData.Bounds.Width;
                    }
                }
            }
            return(new SizeF(width, 0.0f));
        }
Exemple #4
0
        public float MeasureAutoSizeRow(RadElementCollection cells)
        {
            List <float> floatList = new List <float>();
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> columnsData = this.tree.GetColumnsData();

            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    if (!(gridCellElement.ColumnInfo is GridViewGroupColumn) || this.HasVisibleColumn(((GridViewGroupColumn)gridCellElement.ColumnInfo).Group))
                    {
                        while (floatList.Count <= groupsCellArrangeInfo.Depth)
                        {
                            floatList.Add(0.0f);
                        }
                        floatList[groupsCellArrangeInfo.Depth] = Math.Max(floatList[groupsCellArrangeInfo.Depth], gridCellElement.DesiredSize.Height);
                    }
                }
            }
            float num1 = 0.0f;

            foreach (float num2 in floatList)
            {
                num1 += num2;
            }
            return(num1);
        }
Exemple #5
0
        public RectangleF GetCorrectedColumnBounds(
            GridViewRowInfo row,
            GridViewColumn column,
            bool rightToLeft,
            RectangleF clientRect)
        {
            ColumnGroupsCellArrangeInfo info = this.currentAutoSizeArrangeInfo == null || !this.currentAutoSizeArrangeInfo.ContainsKey(column) ? this.GetColumnData(column) : this.currentAutoSizeArrangeInfo[column];

            if (info == null)
            {
                return(RectangleF.Empty);
            }
            RectangleF bounds = info.Bounds;

            if (row == null || row is GridViewTableHeaderRowInfo || this.Owner.GridViewElement.AutoSizeRows)
            {
                float num1 = info.Bounds.X + info.Bounds.Width;
                float num2 = info.Bounds.Y + info.Bounds.Height;
                bounds = new RectangleF((float)(int)info.Bounds.X, (float)(int)info.Bounds.Y, (float)((int)num1 - (int)info.Bounds.X), (float)((int)num2 - (int)info.Bounds.Y));
            }
            else
            {
                float num1 = info.Bounds.Y - this.tree.GroupRowsTotalHeight;
                float num2 = info.Bounds.X + info.Bounds.Width;
                float num3 = num1 + info.Bounds.Height;
                if ((row is GridViewDataRowInfo || row is GridViewSummaryRowInfo) && row.Height != -1)
                {
                    num1 *= (float)row.Height / this.tree.ColumnRowsTotalHeight;
                    num3 *= (float)row.Height / this.tree.ColumnRowsTotalHeight;
                }
                bounds = new RectangleF((float)(int)info.Bounds.X, (float)(int)num1, (float)((int)num2 - (int)info.Bounds.X), (float)((int)num3 - (int)num1));
            }
            int x = (int)bounds.X;

            bounds.X     = column.PinPosition == PinnedColumnPosition.Right ? bounds.X + (float)this.Owner.CellSpacing : Math.Max(0.0f, bounds.X + (float)this.Owner.CellSpacing);
            bounds.Width = (float)((int)bounds.Width - ((int)bounds.X - x));
            if (row is GridViewTableHeaderRowInfo && this.ShouldStretchColumn(info))
            {
                bounds.Y      -= this.tree.GroupRowsTotalHeight;
                bounds.Height += this.tree.GroupRowsTotalHeight;
            }
            else if (row is GridViewDataRowInfo && info.RowIndex > 0 || !(row is GridViewDataRowInfo) && info.Depth > 1)
            {
                bounds.Y      += (float)this.Owner.CellSpacing;
                bounds.Height -= (float)this.Owner.CellSpacing;
            }
            if (column is GridViewRowHeaderColumn || column is GridViewIndentColumn)
            {
                bounds.Y      = 0.0f;
                bounds.Height = clientRect.Height;
            }
            if (rightToLeft)
            {
                bounds = LayoutUtils.RTLTranslateNonRelative(bounds, clientRect);
            }
            return(bounds);
        }
Exemple #6
0
        public override int GetColumnOffset(GridViewColumn column)
        {
            ColumnGroupsCellArrangeInfo columnData = this.GetColumnData(column);

            if (columnData == null)
            {
                return(0);
            }
            return((int)columnData.Bounds.X);
        }
        public Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> GetSystemColumnsData()
        {
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> dictionary = new Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo>();

            foreach (KeyValuePair <GridViewColumn, ColumnGroupColumnData> systemColumn in this.systemColumns)
            {
                ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = new ColumnGroupsCellArrangeInfo(systemColumn.Key);
                dictionary.Add(systemColumn.Key, groupsCellArrangeInfo);
            }
            return(dictionary);
        }
Exemple #8
0
        private bool ShouldStretchColumn(ColumnGroupsCellArrangeInfo info)
        {
            GridViewColumnGroup group = info.Group;

            if (group == null)
            {
                return(false);
            }
            GridViewColumnGroup rootColumnGroup = group?.RootColumnGroup;

            return((rootColumnGroup == null || !rootColumnGroup.ShowHeader) && (info.Row == null && group.Parent == rootColumnGroup || group == rootColumnGroup && group.Rows.IndexOf(info.Row) == 0));
        }
        public Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> GetColumnsData()
        {
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> dictionary1 = new Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo>();
            Dictionary <GridViewColumnGroup, GridViewColumn>         dictionary2 = new Dictionary <GridViewColumnGroup, GridViewColumn>();

            foreach (GridViewColumn renderColumn in (IEnumerable <GridViewColumn>) this.owner.RenderColumns)
            {
                if (renderColumn is GridViewGroupColumn)
                {
                    dictionary2.Add(((GridViewGroupColumn)renderColumn).Group, renderColumn);
                }
            }
            Queue <ColumnGroupLayoutNode> columnGroupLayoutNodeQueue = new Queue <ColumnGroupLayoutNode>();

            columnGroupLayoutNodeQueue.Enqueue(this.root);
            while (columnGroupLayoutNodeQueue.Count > 0)
            {
                ColumnGroupLayoutNode columnGroupLayoutNode = columnGroupLayoutNodeQueue.Dequeue();
                if (columnGroupLayoutNode != this.root)
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = new ColumnGroupsCellArrangeInfo(dictionary2[columnGroupLayoutNode.Group]);
                    groupsCellArrangeInfo.Group  = columnGroupLayoutNode.Parent.Group;
                    groupsCellArrangeInfo.Bounds = columnGroupLayoutNode.Bounds;
                    groupsCellArrangeInfo.Depth  = columnGroupLayoutNode.Level;
                    dictionary1.Add(dictionary2[columnGroupLayoutNode.Group], groupsCellArrangeInfo);
                }
                foreach (ColumnGroupLayoutNode child in columnGroupLayoutNode.Children)
                {
                    if (child.Rows != null)
                    {
                        foreach (KeyValuePair <GridViewColumn, ColumnGroupColumnData> keyValuePair in child.ColumnData)
                        {
                            ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = new ColumnGroupsCellArrangeInfo(keyValuePair.Key);
                            groupsCellArrangeInfo.Group    = columnGroupLayoutNode.Group;
                            groupsCellArrangeInfo.Bounds   = keyValuePair.Value.Bounds;
                            groupsCellArrangeInfo.RowIndex = keyValuePair.Value.Row;
                            groupsCellArrangeInfo.Depth    = groupsCellArrangeInfo.RowIndex + this.groupRowLevels + 1;
                            groupsCellArrangeInfo.Row      = groupsCellArrangeInfo.Group.Rows == null || groupsCellArrangeInfo.Group.Rows.Count <= groupsCellArrangeInfo.RowIndex ? (GridViewColumnGroupRow)null : groupsCellArrangeInfo.Group.Rows[groupsCellArrangeInfo.RowIndex];
                            dictionary1.Add(keyValuePair.Key, groupsCellArrangeInfo);
                        }
                    }
                    else
                    {
                        columnGroupLayoutNodeQueue.Enqueue(child);
                    }
                }
            }
            return(dictionary1);
        }
Exemple #10
0
        private void BestFitGroupColumn(
            GridViewGroupColumn column,
            bool bestFitChildColumns,
            BestFitColumnMode?mode)
        {
            GridTableHeaderRowElement headerRowElement = this.GetHeaderRowElement();
            IVirtualizedElementProvider <GridViewColumn> elementProvider = this.tableElement.ColumnScroller.ElementProvider;
            ColumnGroupRowLayout rowLayout = this.tableElement.ViewElement.RowLayout as ColumnGroupRowLayout;

            if (rowLayout == null || headerRowElement == null)
            {
                return;
            }
            GridColumnGroupCellElement element = elementProvider.GetElement((GridViewColumn)column, (object)headerRowElement) as GridColumnGroupCellElement;

            if (element == null || !element.CanBestFit(column.AutoSizeMode))
            {
                return;
            }
            float num = this.MeasureCell((GridRowElement)headerRowElement, (GridViewColumn)column, element);

            this.Detach(elementProvider, (GridCellElement)element);
            ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData((GridViewColumn)column);

            if ((double)columnData.Bounds.Width < (double)num)
            {
                rowLayout.StartColumnResize((GridViewColumn)column);
                rowLayout.ResizeColumn((int)((double)num - (double)columnData.Bounds.Width));
                rowLayout.InvalidateLayout();
                this.TableElement.ViewElement.InvalidateMeasure(true);
                this.TableElement.ViewElement.UpdateLayout();
                rowLayout.EndColumnResize();
            }
            if (!bestFitChildColumns)
            {
                return;
            }
            foreach (GridViewColumn dataColumn in this.GetDataColumns(column.Group))
            {
                this.BestFitColumnCore(dataColumn, mode.HasValue ? mode.Value : column.AutoSizeMode);
            }
        }
Exemple #11
0
        public virtual bool IsColumnVisible(GridViewColumn column, RectangleF viewRect)
        {
            ColumnGroupsCellArrangeInfo columnData = this.GetColumnData(column);

            if (columnData == null)
            {
                return(false);
            }
            RectangleF bounds = columnData.Bounds;

            if ((double)bounds.Left >= (double)viewRect.Left && (double)bounds.Left <= (double)viewRect.Right || (double)bounds.Right >= (double)viewRect.Left && (double)bounds.Right <= (double)viewRect.Right)
            {
                return(true);
            }
            if ((double)bounds.Left < (double)viewRect.Left)
            {
                return((double)bounds.Right > (double)viewRect.Right);
            }
            return(false);
        }
Exemple #12
0
        public override SizeF MeasurePinnedColumns(PinnedColumnTraverser dataProvider)
        {
            SizeF sizeF = new SizeF(0.0f, this.desiredSize.Height);
            float val1  = float.MaxValue;

            foreach (GridViewColumn column in (ItemsTraverser <GridViewColumn>)dataProvider)
            {
                ColumnGroupsCellArrangeInfo columnData = this.GetColumnData(column);
                if (columnData != null)
                {
                    sizeF.Width = Math.Max(sizeF.Width, (float)(int)columnData.Bounds.Right);
                    val1        = Math.Min(val1, columnData.Bounds.X);
                }
            }
            if ((double)val1 != 3.40282346638529E+38)
            {
                sizeF.Width -= val1;
            }
            if (dataProvider.PinPosition == PinnedColumnPosition.Right)
            {
                sizeF.Width -= (float)this.Owner.CellSpacing;
            }
            return(sizeF);
        }
Exemple #13
0
        protected virtual void BestFitColumnsCore(BestFitColumnMode?mode)
        {
            BestFitColumnMode?nullable = mode;

            if ((nullable.GetValueOrDefault() != BestFitColumnMode.None ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
            {
                return;
            }
            List <GridViewDataColumn> columns     = new List <GridViewDataColumn>((IEnumerable <GridViewDataColumn>) this.tableElement.ViewTemplate.Columns);
            ColumnGroupRowLayout      groupLayout = this.TableElement.ViewElement.RowLayout as ColumnGroupRowLayout;

            if (groupLayout != null)
            {
                columns.Sort((Comparison <GridViewDataColumn>)((A, B) =>
                {
                    ColumnGroupsCellArrangeInfo columnData1 = groupLayout.GetColumnData((GridViewColumn)A);
                    ColumnGroupsCellArrangeInfo columnData2 = groupLayout.GetColumnData((GridViewColumn)B);
                    if (columnData1 == columnData2)
                    {
                        return(0);
                    }
                    if (columnData1 == null)
                    {
                        return(-1);
                    }
                    if (columnData2 == null)
                    {
                        return(1);
                    }
                    int num1 = columnData1.Group.Rows.IndexOf(columnData1.Row);
                    int num2 = columnData2.Group.Rows.IndexOf(columnData2.Row);
                    if (columnData1.Group != columnData2.Group)
                    {
                        return(columnData1.Bounds.X.CompareTo(columnData2.Bounds.X));
                    }
                    if (num1 != num2)
                    {
                        return(num1.CompareTo(num2));
                    }
                    return(columnData1.Bounds.X.CompareTo(columnData2.Bounds.X));
                }));
            }
            float[] numArray = new float[this.tableElement.ViewTemplate.ColumnCount];
            int     index1   = -1;

            if (mode.HasValue && mode.Value == BestFitColumnMode.AllCells)
            {
                numArray = this.CalculateColumnWidths(columns);
            }
            else
            {
                foreach (GridViewColumn column in columns)
                {
                    if (!(column is GridViewGroupColumn))
                    {
                        ++index1;
                        BestFitColumnMode mode1 = mode.HasValue ? mode.Value : column.AutoSizeMode;
                        if (column.IsVisible && mode1 != BestFitColumnMode.None)
                        {
                            float columnWidth = this.CalculateColumnWidth(column, mode1);
                            float val1        = numArray[index1];
                            numArray[index1] = Math.Max(val1, columnWidth);
                        }
                    }
                }
            }
            for (int index2 = 0; index2 < numArray.Length; ++index2)
            {
                GridViewColumn column = (GridViewColumn)columns[index2];
                if (column != null && column.IsVisible && column.AutoSizeMode != BestFitColumnMode.None && ((!column.IsGrouped || column.OwnerTemplate.ShowGroupedColumns) && column.CanStretch))
                {
                    this.SetColumnWidth(column, numArray[index2]);
                }
            }
            if (this.tableElement.ViewTemplate.AutoSizeColumnsMode == GridViewAutoSizeColumnsMode.Fill)
            {
                return;
            }
            this.BestFitGroupColumns(mode);
        }
Exemple #14
0
        public void BeginAutoSizeRowArrange(RadElementCollection cells)
        {
            List <float> floatList1 = new List <float>();
            int          val1_1     = 0;
            int          val1_2     = 0;
            Dictionary <GridViewColumn, ColumnGroupsCellArrangeInfo> columnsData = this.tree.GetColumnsData();

            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    if (gridCellElement.ColumnInfo is GridViewGroupColumn)
                    {
                        if (this.HasVisibleColumn(((GridViewGroupColumn)gridCellElement.ColumnInfo).Group))
                        {
                            val1_1 = Math.Max(val1_1, groupsCellArrangeInfo.Depth);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        val1_2 = Math.Max(val1_2, groupsCellArrangeInfo.Depth);
                    }
                    while (floatList1.Count <= groupsCellArrangeInfo.Depth)
                    {
                        floatList1.Add(0.0f);
                    }
                    floatList1[groupsCellArrangeInfo.Depth] = Math.Max(floatList1[groupsCellArrangeInfo.Depth], gridCellElement.DesiredSize.Height);
                }
            }
            if (floatList1.Count == 0)
            {
                return;
            }
            List <float> floatList2 = new List <float>();

            floatList2.Add(floatList1[0]);
            for (int index = 1; index < floatList1.Count; ++index)
            {
                floatList2.Add(floatList2[index - 1] + floatList1[index]);
            }
            foreach (RadElement cell in cells)
            {
                GridCellElement gridCellElement = cell as GridCellElement;
                if (gridCellElement != null && columnsData.ContainsKey(gridCellElement.ColumnInfo))
                {
                    ColumnGroupsCellArrangeInfo groupsCellArrangeInfo = columnsData[gridCellElement.ColumnInfo];
                    groupsCellArrangeInfo.Bounds.Height = floatList1[groupsCellArrangeInfo.Depth];
                    groupsCellArrangeInfo.Bounds.Y      = floatList2[groupsCellArrangeInfo.Depth - 1];
                    if (gridCellElement.ColumnInfo is GridViewGroupColumn)
                    {
                        if (((GridViewGroupColumn)gridCellElement.ColumnInfo).Group.Groups.Count == 0)
                        {
                            groupsCellArrangeInfo.Bounds.Height = floatList2[val1_1] - floatList2[groupsCellArrangeInfo.Depth - 1];
                        }
                    }
                    else if (groupsCellArrangeInfo.RowIndex == groupsCellArrangeInfo.Group.Rows.Count - 1)
                    {
                        groupsCellArrangeInfo.Bounds.Height = floatList2[val1_2] - floatList2[groupsCellArrangeInfo.Depth - 1];
                    }
                }
            }
            foreach (KeyValuePair <GridViewColumn, ColumnGroupsCellArrangeInfo> keyValuePair in this.tree.GetSystemColumnsData())
            {
                keyValuePair.Value.Bounds.Height = floatList2[floatList2.Count - 1];
                columnsData.Add(keyValuePair.Key, keyValuePair.Value);
            }
            this.currentAutoSizeArrangeInfo = columnsData;
        }