Beispiel #1
0
        protected override DevExpress.XtraPrinting.IBrick CreateCellBrick(CellInfo cell, DevExpress.XtraTreeList.Nodes.TreeListNode node)
        {
            IVisualBrick brick = base.CreateCellBrick(cell, node) as IVisualBrick;

            int lastColumnIndex = treeList.Columns.Count - 1;
            int prevIndex       = lastColumnIndex - 1;

            if (node.GetDisplayText(lastColumnIndex) == node.GetDisplayText(prevIndex))
            {
                if (cell.Column.AbsoluteIndex == lastColumnIndex)
                {
                    brick.Sides = BorderSide.Right | BorderSide.Bottom | BorderSide.Top;
                    Rectangle rect = cell.EditorViewInfo.Bounds;
                    rect.X     -= prevCell.EditorViewInfo.Bounds.Width;
                    rect.Width += prevCell.EditorViewInfo.Bounds.Width;
                    rect.Inflate(1, 1);
                    cell.SetBounds(rect, new System.Windows.Forms.Padding(0));
                }

                else if (cell.Column.AbsoluteIndex == lastColumnIndex - 1)
                {
                    brick.Sides = BorderSide.Left | BorderSide.Bottom | BorderSide.Top;
                    (brick as TextBrick).HorzAlignment = DevExpress.Utils.HorzAlignment.Far;
                    prevCell = cell;
                }
            }
            return(brick);
        }
        protected override void CalcRowCellsInfo(RowInfo ri)
        {
            base.CalcRowCellsInfo(ri);
            if (!((MyTreeList)TreeList).OptionsView.AllowHorizontalMerge)
            {
                return;
            }

            if (TreeList.OptionsSelection.EnableAppearanceFocusedRow)
            {
                TreeList.OptionsSelection.EnableAppearanceFocusedRow = false;
            }

            for (int i = ri.Cells.Count - 1; i > 0; i--)
            {
                string prevDisplayText = GetCellDisplayText(ri, i - 1);
                string currDisplayText = GetCellDisplayText(ri, i);

                AllowMergeRowCellsEventArgs args = new AllowMergeRowCellsEventArgs(ri, i, i - 1);
                ((MyTreeList)TreeList).RaiseMergeRowCells(args);
                if (args.Merge == DevExpress.Utils.DefaultBoolean.False)
                {
                    continue;
                }

                if ((prevDisplayText == currDisplayText) || (args.Merge == DevExpress.Utils.DefaultBoolean.True))
                {
                    CellInfo prevCell = ri.Cells[i - 1];
                    CellInfo currCell = ri.Cells[i];

                    for (int j = ri.Lines.Count - 1; j >= 0; j--)
                    {
                        LineInfo lineInfo = ri.Lines[j];
                        if (lineInfo.Appearance != PaintAppearance.VertLine)
                        {
                            continue;
                        }

                        if (lineInfo.Bounds.X == prevCell.Bounds.X + prevCell.Bounds.Width)
                        {
                            ri.Lines.RemoveAt(j);
                            break;
                        }
                    }

                    Rectangle mergedBounds = new Rectangle(prevCell.Bounds.X, prevCell.Bounds.Y, currCell.Bounds.Right - prevCell.Bounds.X, prevCell.Bounds.Height);
                    prevCell.SetBounds(mergedBounds, new System.Windows.Forms.Padding(0));
                    mergedBounds.Inflate(-1, -1);
                    prevCell.CalcViewInfo(GInfo.Cache, Point.Empty);
                    prevCell.EditorViewInfo.Bounds = mergedBounds;

                    ri.Cells.RemoveRange(i - 1, 2);
                    ri.Cells.Insert(i - 1, prevCell);
                    base.UpdateCellInfo(prevCell, prevCell.RowInfo.Node);
                }
            }
        }