示例#1
0
        protected override bool AfterPrintOnPage(IList <int> indices, RectangleF brickBounds, RectangleF clipRect, Page page, int pageIndex, int pageCount, Action <Brick, RectangleF> callback)
        {
            if (!IsHeaderBrick)
            {
                RecordPrintCache headerCache = parentBrick.PrintCache.HeaderCache;
                VisualBrick      headerBrick = headerCache.Brick;

                RectangleF headerBrickBounds = page.GetBrickBounds(headerBrick);
                RectangleF brickRect         = page.GetBrickBounds(this);

                RecordPrintCache currentCache = parentBrick.PrintCache.GetCacheByBrick(this);
                int cacheIndex = parentBrick.PrintCache.RecordsCache.IndexOf(currentCache);

                float delta = brickRect.Top - headerBrickBounds.Bottom;

                RecordPrintCache prevCache      = null;
                float            prevNodeHeight = 1;
                if (cacheIndex > 0)
                {
                    prevCache      = parentBrick.PrintCache.RecordsCache[cacheIndex - 1] as RecordPrintCache;
                    prevNodeHeight = prevCache.Brick.Rect.Height;
                }

                if (delta >= 0 && delta < prevNodeHeight)
                {
                    this.AddCellPosition(XRDataCellPosition.FirstOnPage);

                    if (prevCache != null)
                    {
                        ((DataRecordBrick)prevCache.Brick).AddCellPosition(XRDataCellPosition.LastOnPage);
                    }
                }
            }
            return(base.AfterPrintOnPage(indices, brickBounds, clipRect, page, pageIndex, pageCount, callback));
        }
        protected override void CreateBricksForRecord(XRDataRecord record, PanelBrick parentBrick, bool isHeader, ref float actualHeight)
        {
            PrintRecordEventArgs args = new PrintRecordEventArgs(record);

            if (!isHeader)
            {
                Grid.OnPrintRecord(args);
            }

            if (!args.Cancel)
            {
                GridRecordBrick recordBrick = new GridRecordBrick(Grid, (DataContainerBrick)parentBrick, isHeader);
                recordBrick.Style     = XRControlStyle.Default.Clone() as XRControlStyle;
                recordBrick.Separable = false;

                RecordPrintCache cache = new RecordPrintCache(recordBrick);

                List <VisualBrick>   childBricks    = new List <VisualBrick>();
                List <XRFieldHeader> visibleHeaders = Grid.VisibleHeaders;

                for (int i = 0; i < visibleHeaders.Count; i++)
                {
                    VisualBrick valueBrick = CreateCellBrick(Grid, parentBrick, record, i, isHeader);
                    childBricks.Add(valueBrick);
                }

                CorrectBrickBounds(recordBrick, childBricks, 0, actualHeight);
                float recordHeight = recordBrick.Rect.Height;

                VisualBrickHelper.SetBrickBounds(recordBrick, recordBrick.Rect, Grid.Dpi);

                parentBrick.Bricks.Add(recordBrick);

                actualHeight += recordHeight;

                if (!IsDesignMode)
                {
                    if (isHeader)
                    {
                        ((DataContainerBrick)parentBrick).PrintCache.HeaderCache = cache;
                    }
                    else
                    {
                        ((DataContainerBrick)parentBrick).PrintCache.RecordsCache.Add(cache);
                    }
                }
            }
        }