/// <summary>
        /// 测试单元格
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private I3ReportCell TestCell(int pageIndex, int x, int y)
        {
            if (reportDatas == null || CellItemEventMode == ReportPrint.I3CellItemEventMode.None)
            {
                return(null);
            }

            I3ReportData reportData = reportDatas.GetReportDataByAreaIndex(pageIndex);
            int          row        = TestRow(pageIndex, x, y);
            int          col        = TestCol(pageIndex, x, y);

            if (row < 0 || col < 0)
            {
                return(null);
            }

            I3ReportCell cell = reportData[row][col];

            cell = cell.MergState == I3MergeState.Merged ? reportData.GetMergedStartedCell(row, col) : cell;
            switch (CellItemEventMode)
            {
            case I3CellItemEventMode.CellRect:
                return(cell);

            case I3CellItemEventMode.ContentRect:
                I3PrintArea     area        = reportDatas.PrintAreas.Dic[pageIndex];
                RectangleF      fullRect    = GetAreaPaperRect(area);
                RectangleF      dataRect    = GetAreaContentRect(area);
                RectangleF      rect        = I3ReportPrintController.CalCellDrawRect_Scale(reportDatas, cell, area, Scale, dataRect, null);
                II3CellRenderer renderer    = I3CellRendererBuilder.GetRenderer(cell);
                RectangleF      contentRect = renderer.DrawContent(this.CreateGraphics(), Scale, reportData, cell, rect, reportData.GetCellStyle(cell.StyleName), area, false);
                RectangleF      testRect    = new RectangleF(x, y, 1, 1);
                return(contentRect.IntersectsWith(testRect) ? cell : null);

            default:
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 将单元格输出到画布上
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        private static void DrawCell(Graphics g, RectangleF fullRect, RectangleF dataRect, RectangleF areaRect, float scale, I3ReportDatas reportDatas, I3ReportCell cell, I3PrintArea area, I3ReportCell mergedCell,
                                     bool drawBackground, bool drawBorder, bool drawContect)
        {
            #region 合并单元格中的格子处理
            if (cell != null && cell.MergState == I3MergeState.Merged)
            {
                //2017.04.26 为加快绘制速度,合并单元格不处理
                return;
                //I3ReportCell firstCell = reportData.GetMergedStartedCell(cell.Row, cell.Col);
                //if (firstCell != null)
                //{
                //    DrawCell(g, fullRect, dataRect, areaRect, scale, reportData, firstCell, area, cell, drawBackground, drawBorder, drawContect);
                //}
                //return;
            }
            #endregion

            #region 绘制区域、剪切区域
            RectangleF cellDrawRect = CalCellDrawRect_Scale(reportDatas, cell, area, scale, dataRect, mergedCell);
            if (cellDrawRect.IsEmpty)
            {
                return;
            }

            //2017.04.26 为加快绘制速度,不做单元格剪切区域计算,直接使用原始的剪切区域
            //I3ReportCell destCell = mergedCell == null ? cell : mergedCell;  //计算剪切区域使用真实单元格
            //RectangleF clipRect = CalCellClipRect_Scale(reportData, destCell, area, scale, dataRect, fullRect, areaRect);
            ////destCell.SetCellRect(graphicsKey, clipRect);
            //clipRect.Intersect(g.ClipBounds);
            //if (clipRect.IsEmpty)
            //{
            //    return;
            //}

            //g.SetClip(clipRect);
            #endregion

            #region 样式
            I3ReportCellStyle style = area.ReportData.GetCellStyle(cell.StyleName);
            if (style == null)
            {
                return;
            }
            #endregion

            II3CellRenderer renderer = I3CellRendererBuilder.GetRenderer(cell);
            RectangleF      oldClip  = g.ClipBounds;

            //背景
            if (drawBackground)
            {
                g.SetClip(oldClip);
                g.FillRectangle(Brushes.White, cellDrawRect);
                renderer.DrawBackground(g, scale, area.ReportData, cell, cellDrawRect, style);
            }

            //边框
            if (drawBorder)
            {
                RectangleF borderClipRect = oldClip;  //扩大避免边框画不全
                borderClipRect.Inflate(1, 1);
                g.SetClip(borderClipRect);
                renderer.DrawCellBorder(g, scale, area.ReportData, cell, cellDrawRect, style);
            }

            //内容
            if (drawContect)
            {
                g.SetClip(oldClip);
                renderer.DrawContent(g, scale, area.ReportData, cell, cellDrawRect, style, area, true);
            }
        }