C2021-004 logic to print shaded table cells

This commit is contained in:
John Jenko 2021-11-18 19:41:00 +00:00
parent 5118268906
commit 96fd567d92

View File

@ -120,6 +120,13 @@ namespace Volian.Print.Library
get { return _MyBorders; }
set { _MyBorders = value; }
}
// C2021-004 Table cell shading
private VlnGridCellShading _MyShading;
public VlnGridCellShading MyShading
{
get { return _MyShading; }
set { _MyShading = value; }
}
private iTextSharp.text.pdf.PdfContentByte _MyContentByte;
public iTextSharp.text.pdf.PdfContentByte MyContentByte
{
@ -403,6 +410,7 @@ public string Path
SetupCells();
foreach(vlnCell cell in this)
{
myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading
myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString());
GridLinePattern glp = cell.AboveLeftSide;
glp = cell.AboveRightSide;
@ -1114,6 +1122,10 @@ public string Path
get { return _HContent; }
set { _HContent = value; }
}
public VlnGridCellShading MyShading
{
get { return _MyTable.MyShading; }
}
#endregion
#region Line Pattern Diagram
/*
@ -1441,8 +1453,8 @@ public string Path
if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase6))// RHM20150525 - Table Scrunc
{
h = YAdjust_h + mult * MyTable.RowTop[r2 + 1] - y;
}
ShadingToPdf(myColumnText, left, top, x, w, y, h); // C2021-004 Table Cell Shading
BordersToPdf(myColumnText, left, top, x, w, y, h );
float hAdjust = VeritcalTextAlignment(h,_MyPageHelper.YMultiplier);
iTextSharp.text.pdf.ColumnText myColumnText1 = new iTextSharp.text.pdf.ColumnText(myColumnText.Canvas);
@ -1606,9 +1618,6 @@ public string Path
float yTop = top - y + YOffset;
float xRight = left + x + w + XOffset;
float yBottom = top - y - h + YOffset;
// PIP TESTING SHADING CELLS
//FillRectangle(cb, xLeft, xRight, yTop-2, yBottom, Color.GREEN, Color.MAGENTA);
// ZoomToCell(myColumnText, xLeft, yTop, xRight, yBottom);
// Draw Top Side for the first row
if (r1 == 0)
@ -1621,26 +1630,30 @@ public string Path
// Draw Right Side
DrawLineVertical(cb, "Right", xRight, yBottom, yTop, RightSide, RightOfBottomSide, BottomSide, BelowRightSide, TopSide, RightOfTopSide, AboveRightSide);
cb.RestoreState();
// PIP TESTING SHADING CELLS
//FillRectangle(cb, xLeft, xRight, yTop, yBottom, Color.GREEN, Color.MAGENTA);
}
// C2021-004 Set the cell background shading color
private void ShadingToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, float x, float w, float y, float h)
{
PdfContentByte cb = myColumnText.Canvas;
cb.SaveState();// Save state before shading
float xLeft = left + x + XOffset;
float yTop = top - y + YOffset;
float xRight = left + x + w + XOffset;
float yBottom = top - y - h + YOffset;
//Console.WriteLine("Color {0}", MyShading.TableShadingInfo[r1, c1]);
FillRectangle(cb, xLeft, xRight, yTop, yBottom, new Color(MyShading.GetColor(r1, c1)), new Color(MyShading.GetColor(r1, c1)));
cb.RestoreState();
}
// PIP TESTING SHADING CELLS
private void FillRectangle(PdfContentByte cb, float xLeft, float xRight, float yTop, float yBottom, Color FillColor, Color OutlineColor)
{
cb.SaveState();
//bool fill = FillColor != System.Drawing.Color.Transparent;
//bool stroke = OutlineWidth.Value != 0F && OutlineColor != System.Drawing.Color.Empty;
//if (fill)
cb.SetColorFill(FillColor);
//if (stroke)
//{
cb.SetLineWidth(.5f);//scale.M(OutlineWidth));
cb.SetColorStroke(OutlineColor);
//}
cb.RoundRectangle(xLeft, yBottom, xRight-xLeft, yTop-yBottom, .005F);
cb.Fill();//.FillStroke();
cb.SetColorFill(FillColor);
cb.SetLineWidth(.5f);
cb.SetColorStroke(OutlineColor);
cb.RoundRectangle(xLeft, yBottom, xRight-xLeft, yTop-yBottom, .005F);
cb.Fill();
cb.RestoreState();
}