/// <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); } }