Пример #1
0
        private void FindColumnNode(
            GridViewColumn column,
            out ColumnGroupLayoutNode node,
            out ColumnGroupColumnData data)
        {
            Queue <ColumnGroupLayoutNode> columnGroupLayoutNodeQueue = new Queue <ColumnGroupLayoutNode>();
            GridViewGroupColumn           gridViewGroupColumn        = column as GridViewGroupColumn;

            columnGroupLayoutNodeQueue.Enqueue(this.root);
            while (columnGroupLayoutNodeQueue.Count > 0)
            {
                foreach (ColumnGroupLayoutNode child in columnGroupLayoutNodeQueue.Dequeue().Children)
                {
                    if (gridViewGroupColumn != null && gridViewGroupColumn.Group == child.Group && child.Group != null)
                    {
                        node = child;
                        data = (ColumnGroupColumnData)null;
                        return;
                    }
                    if (child.ColumnData.ContainsKey(column))
                    {
                        node = child;
                        data = child.ColumnData[column];
                        return;
                    }
                    columnGroupLayoutNodeQueue.Enqueue(child);
                }
            }
            node = (ColumnGroupLayoutNode)null;
            data = (ColumnGroupColumnData)null;
        }
Пример #2
0
        private void SpanColumnsVertically(ColumnGroupLayoutNode current, float y)
        {
            if (current.Group != null)
            {
                current.Bounds.Y      = y;
                current.Bounds.Height = this.groupRowsHeights[current.Level];
                if (current.Children.Count == 1 && current.Children[0].Group == null)
                {
                    current.Bounds.Height = this.groupRowsTotalHeight - y;
                }
            }
            foreach (ColumnGroupLayoutNode child in current.Children)
            {
                this.SpanColumnsVertically(child, y + current.Bounds.Height);
            }
            if (current.Children.Count != 0 || current.Rows == null || current.Rows.Count <= 0)
            {
                return;
            }
            float num = 0.0f;

            for (int index = 0; index < current.Rows.Count; ++index)
            {
                foreach (string columnName in (Collection <string>)current.Rows[index].ColumnNames)
                {
                    GridViewColumn column = (GridViewColumn)this.template.Columns[columnName];
                    if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
                    {
                        ColumnGroupColumnData columnGroupColumnData = current.ColumnData[column];
                        columnGroupColumnData.Bounds.Y      = y + num;
                        columnGroupColumnData.Bounds.Height = index == current.Rows.Count - 1 ? this.columnRowsTotalHeight + this.groupRowsTotalHeight - columnGroupColumnData.Bounds.Y : this.columnRowsHeights[index];
                    }
                }
                num += this.columnRowsHeights[index];
            }
        }
Пример #3
0
 private void RebuildLayout(ColumnGroupLayoutNode node)
 {
     node.MinWidth = node.MaxWidth = node.Bounds.Width = node.OriginalWidth = 0.0f;
     foreach (ColumnGroupLayoutNode child in node.Children)
     {
         child.Level = node.Level + 1;
         this.RebuildLayout(child);
         node.MinWidth += child.MinWidth;
         if ((double)node.MaxWidth >= 0.0)
         {
             node.MaxWidth += child.MaxWidth;
         }
         if ((double)child.MaxWidth == 0.0)
         {
             node.MaxWidth = -1f;
         }
         node.Bounds.Width += child.Bounds.Width;
     }
     if ((double)node.MaxWidth == -1.0)
     {
         node.MaxWidth = 0.0f;
     }
     if (node.Rows != null && node.Children.Count == 0)
     {
         int num1 = 0;
         node.MaxWidth = (float)int.MaxValue;
         bool flag = false;
         foreach (GridViewColumnGroupRow row in (Collection <GridViewColumnGroupRow>)node.Rows)
         {
             int num2 = 0;
             int num3 = 0;
             int num4 = 0;
             foreach (string columnName in (Collection <string>)row.ColumnNames)
             {
                 GridViewColumn column = (GridViewColumn)this.template.Columns[columnName];
                 if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
                 {
                     flag  = true;
                     num2 += column.Width;
                     num3 += column.MinWidth;
                     if (num4 >= 0)
                     {
                         num4 += column.MaxWidth;
                     }
                     if (column.MaxWidth == 0)
                     {
                         num4 = -1;
                     }
                     ColumnGroupColumnData columnGroupColumnData = new ColumnGroupColumnData();
                     columnGroupColumnData.Row           = num1;
                     columnGroupColumnData.Bounds.Width  = (float)column.Width;
                     columnGroupColumnData.OriginalWidth = (float)column.Width;
                     columnGroupColumnData.MinWidth      = (float)column.MinWidth;
                     columnGroupColumnData.MaxWidth      = (float)column.MaxWidth;
                     columnGroupColumnData.ConstrainWidth();
                     node.ColumnData.Add(column, columnGroupColumnData);
                 }
             }
             node.Bounds.Width = Math.Max(node.Bounds.Width, (float)num2);
             node.MinWidth     = Math.Max(node.MinWidth, (float)num3);
             node.MaxWidth     = num4 != -1 ? Math.Min(node.MaxWidth, (float)num4) : node.MaxWidth;
             node.ConstrainWidth();
             ++num1;
         }
         node.MaxWidth = (double)node.MaxWidth == 2147483648.0 ? 0.0f : node.MaxWidth;
         if (!flag && this.owner.ShowEmptyGroups)
         {
             node.Bounds.Width = 50f;
         }
     }
     else
     {
         if (node.Children.Count == 0 && (node.Rows == null || node.Rows.Count == 0) && this.owner.ShowEmptyGroups)
         {
             node.Bounds.Width = 50f;
         }
         this.groupRowLevels = Math.Max(this.groupRowLevels, node.Level);
     }
     node.OriginalWidth = node.Bounds.Width;
 }
Пример #4
0
 public void ResizeColumn(int delta)
 {
     if (this.resizedColumn == null && this.resizedNode != null)
     {
         float constrainedWidth = this.resizedNode.GetConstrainedWidth(this.resizedNode.OriginalWidth + (float)delta);
         float num1             = this.resizedNode.Bounds.Width - constrainedWidth;
         float num2             = 0.0f;
         float num3             = 0.0f;
         float num4             = 0.0f;
         for (int index = this.resizedNode.Parent.Children.IndexOf(this.resizedNode) + 1; index < this.resizedNode.Parent.Children.Count; ++index)
         {
             num2 += this.resizedNode.Parent.Children[index].MinWidth;
             if ((double)num3 >= 0.0)
             {
                 num3 += this.resizedNode.Parent.Children[index].MaxWidth;
             }
             if ((double)this.resizedNode.Parent.Children[index].MaxWidth == 0.0)
             {
                 num3 = -1f;
             }
             num4 += this.resizedNode.Parent.Children[index].Bounds.Width;
         }
         if ((double)num4 + (double)num1 < (double)num2)
         {
             num1 = num2 - num4;
         }
         if ((double)num3 > 0.0 && (double)num4 + (double)num1 > (double)num3)
         {
             num1 = num3 - num4;
         }
         if (this.resizedNode.Parent == this.root && this.template.AutoSizeColumnsMode == GridViewAutoSizeColumnsMode.None)
         {
             this.resizedNode.Bounds.Width = constrainedWidth;
         }
         else
         {
             this.resizedNode.Bounds.Width = this.resizedNode.GetConstrainedWidth(this.resizedNode.Bounds.Width - num1);
         }
     }
     else
     {
         if (this.resizedColumn == null || this.resizedNode == null)
         {
             return;
         }
         ColumnGroupColumnData columnGroupColumnData = this.resizedNode.ColumnData[this.resizedColumn];
         float constrainedWidth1 = columnGroupColumnData.GetConstrainedWidth(columnGroupColumnData.OriginalWidth + (float)delta);
         float num1 = columnGroupColumnData.Bounds.Width - constrainedWidth1;
         float num2 = 0.0f;
         float num3 = 0.0f;
         float num4 = 0.0f;
         for (int index = this.resizedNode.Rows[columnGroupColumnData.Row].ColumnNames.IndexOf(this.resizedColumn.Name) + 1; index < this.resizedNode.Rows[columnGroupColumnData.Row].ColumnNames.Count; ++index)
         {
             GridViewColumn column = (GridViewColumn)this.template.Columns[this.resizedNode.Rows[columnGroupColumnData.Row].ColumnNames[index]];
             if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
             {
                 num2 += this.resizedNode.ColumnData[column].MinWidth;
                 if ((double)num3 >= 0.0)
                 {
                     num3 += this.resizedNode.ColumnData[column].MaxWidth;
                 }
                 if ((double)this.resizedNode.ColumnData[column].MaxWidth == 0.0)
                 {
                     num3 = -1f;
                 }
                 num4 += this.resizedNode.ColumnData[column].Bounds.Width;
             }
         }
         if ((double)num4 + (double)num1 < (double)num2)
         {
             num1 = num2 - num4;
         }
         if ((double)num3 > 0.0 && (double)num4 + (double)num1 > (double)num3)
         {
             num1 = num3 - num4;
         }
         float constrainedWidth2 = columnGroupColumnData.GetConstrainedWidth(columnGroupColumnData.Bounds.Width - num1);
         columnGroupColumnData.Bounds.Width = constrainedWidth2;
     }
 }
Пример #5
0
        private SizeF ArrangeGroupRow(
            GridViewColumnGroupRow row,
            ColumnGroupLayoutNode node,
            PointF location,
            float availableWidth)
        {
            float num1 = 0.0f;

            foreach (string columnName in (Collection <string>)row.ColumnNames)
            {
                GridViewColumn column = (GridViewColumn)this.template.Columns[columnName];
                if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
                {
                    ColumnGroupColumnData columnGroupColumnData = node.ColumnData[column];
                    num1 += columnGroupColumnData.OriginalWidth;
                }
            }
            float num2 = 0.0f;
            float num3 = (float)row.MinHeight;

            foreach (string columnName in (Collection <string>)row.ColumnNames)
            {
                GridViewColumn column = (GridViewColumn)this.template.Columns[columnName];
                if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
                {
                    ColumnGroupColumnData columnGroupColumnData = node.ColumnData[column];
                    if (this.resizedColumn != column)
                    {
                        columnGroupColumnData.Bounds.Width = columnGroupColumnData.GetConstrainedWidth(columnGroupColumnData.OriginalWidth * availableWidth / num1);
                    }
                    columnGroupColumnData.Bounds.Location = new PointF(location.X + num2, location.Y);
                    columnGroupColumnData.Bounds.Height   = (float)column.RowSpan;
                    num2           += columnGroupColumnData.Bounds.Width;
                    num3            = Math.Max(num3, columnGroupColumnData.Bounds.Height);
                    num1           -= columnGroupColumnData.OriginalWidth;
                    availableWidth -= columnGroupColumnData.Bounds.Width;
                    if (column is GridViewDataColumn)
                    {
                        this.SetColumnWidthInternal(column, (int)columnGroupColumnData.Bounds.Width);
                    }
                }
            }
            float width1 = 0.0f;

            foreach (string columnName in (Collection <string>)row.ColumnNames)
            {
                GridViewColumn column = (GridViewColumn)this.template.Columns[columnName];
                if (this.owner.ColumnIsVisible(column) || this.owner.IgnoreColumnVisibility)
                {
                    ColumnGroupColumnData columnGroupColumnData = node.ColumnData[column];
                    if (this.resizedColumn != column)
                    {
                        float width2 = columnGroupColumnData.Bounds.Width;
                        columnGroupColumnData.Bounds.Width = columnGroupColumnData.GetConstrainedWidth(columnGroupColumnData.Bounds.Width + availableWidth);
                        availableWidth -= columnGroupColumnData.Bounds.Width - width2;
                    }
                    columnGroupColumnData.Bounds.Location = new PointF(location.X + width1, location.Y);
                    width1 += columnGroupColumnData.Bounds.Width;
                    if (column is GridViewDataColumn)
                    {
                        column.SuspendPropertyNotifications();
                        this.SetColumnWidthInternal(column, (int)columnGroupColumnData.Bounds.Width);
                        column.ResumePropertyNotifications();
                    }
                }
            }
            return(new SizeF(width1, num3));
        }