B2022-028: Insert image into grid & print

This commit is contained in:
Kathy Ruffing 2022-03-23 13:33:10 +00:00
parent f2357c754f
commit f684f7e65c
2 changed files with 14 additions and 10 deletions

View File

@ -1237,6 +1237,9 @@ namespace Volian.Controls.Library
void _tableCellEditor_HeightChanged(object sender, EventArgs args) void _tableCellEditor_HeightChanged(object sender, EventArgs args)
{ {
// B2022-028: images in table cells - don't come into this code if it is an image in a table cell:
if (_tableCellEditor is StepRTB && (_tableCellEditor as StepRTB).ImageWidth > 0) return;
if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return; if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return;
int curHeight = GetCellHeight(Row, Col);//(Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height; int curHeight = GetCellHeight(Row, Col);//(Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height;
CellRange cr = GetMergedRange(Row, Col); CellRange cr = GetMergedRange(Row, Col);
@ -1268,10 +1271,6 @@ namespace Volian.Controls.Library
AdjustGridControlSize(); AdjustGridControlSize();
} }
} }
if (_tableCellEditor is StepRTB && (_tableCellEditor as StepRTB).ImageWidth > 0)
{
Width = Cols[0].Width = (_tableCellEditor as StepRTB).ImageWidth;
}
} }
void VlnFlexGrid_KeyUp(object sender, KeyEventArgs e) void VlnFlexGrid_KeyUp(object sender, KeyEventArgs e)
{ {
@ -1395,7 +1394,7 @@ namespace Volian.Controls.Library
case TextAlignEnum.GeneralCenter: case TextAlignEnum.GeneralCenter:
case TextAlignEnum.LeftCenter: case TextAlignEnum.LeftCenter:
case TextAlignEnum.RightCenter: case TextAlignEnum.RightCenter:
hAdjust = hDiff / 2; hAdjust = hDiff / 2; //0; // hDiff / 2;
break; break;
default: default:
break; break;

View File

@ -1484,7 +1484,7 @@ public string Path
ShadingToPdf(myColumnText, left, top, x, w, y, h); // C2021-004 Table Cell Shading ShadingToPdf(myColumnText, left, top, x, w, y, h); // C2021-004 Table Cell Shading
return; return;
} }
BordersToPdf(myColumnText, left, top, x, w, y, h ); BordersToPdf(myColumnText, left, top, x, w, y, h ,false);
float hAdjust = VeritcalTextAlignment(h,_MyPageHelper.YMultiplier); float hAdjust = VeritcalTextAlignment(h,_MyPageHelper.YMultiplier);
iTextSharp.text.pdf.ColumnText myColumnText1 = new iTextSharp.text.pdf.ColumnText(myColumnText.Canvas); iTextSharp.text.pdf.ColumnText myColumnText1 = new iTextSharp.text.pdf.ColumnText(myColumnText.Canvas);
float adjustTextLocation = mult * 4; // RHM 20120925 Move text down about 1 half line from the border float adjustTextLocation = mult * 4; // RHM 20120925 Move text down about 1 half line from the border
@ -1529,11 +1529,15 @@ public string Path
{ {
if(obj is iTextSharp.text.Image) if(obj is iTextSharp.text.Image)
{ {
// B2022-028: Insert image into grid & print. Print was accounting for multiple rows in table where
// inserted image was not in first row (mod setabsoluteposition to account for location in table).
// Also, borders were no longer visible so draw those back in (added call to BordersToPdf)
iTextSharp.text.Image img = obj as iTextSharp.text.Image; iTextSharp.text.Image img = obj as iTextSharp.text.Image;
img.SetAbsolutePosition(left,top-h); img.SetAbsolutePosition(left + x, top - y - h);
img.ScaleAbsoluteWidth(w); img.ScaleAbsoluteWidth(w);
img.ScaleAbsoluteHeight(h); img.ScaleAbsoluteHeight(h);
myColumnText.Canvas.AddImage(img); myColumnText.Canvas.AddImage(img);
BordersToPdf(myColumnText, left, top, x, w, y, h, true);
} }
} }
float posBefore = myColumnText1.YLine; // RHM20150429 - Table Scrunch float posBefore = myColumnText1.YLine; // RHM20150429 - Table Scrunch
@ -1638,7 +1642,7 @@ public string Path
#region Private Border Methods #region Private Border Methods
// coordinate system is upside down of screen. 0,0 on screen is top/left. 0,0 on pdf is bottom/left. // coordinate system is upside down of screen. 0,0 on screen is top/left. 0,0 on pdf is bottom/left.
// i.e. x is same, y is flipped. // i.e. x is same, y is flipped.
private void BordersToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, float x, float w, float y, float h) private void BordersToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, float x, float w, float y, float h, bool doTop)
{ {
PdfContentByte cb = myColumnText.Canvas; PdfContentByte cb = myColumnText.Canvas;
cb.SaveState();// Save state before drawing borders cb.SaveState();// Save state before drawing borders
@ -1649,10 +1653,11 @@ public string Path
float yBottom = top - y - h + YOffset; float yBottom = top - y - h + YOffset;
// ZoomToCell(myColumnText, xLeft, yTop, xRight, yBottom); // ZoomToCell(myColumnText, xLeft, yTop, xRight, yBottom);
// Draw Top Side for the first row // Draw Top Side for the first row
if (r1 == 0) // B2022-028: Insert image into grid & print. The top/left was no longer visible if an image is in a grid cell, redraw it
if (r1 == 0 || doTop)
DrawHorizontalLine(cb, "Top", xLeft, xRight, yTop, TopSide, LeftSide, AboveLeftSide, LeftOfTopSide, AboveRightSide, RightSide, RightOfTopSide); DrawHorizontalLine(cb, "Top", xLeft, xRight, yTop, TopSide, LeftSide, AboveLeftSide, LeftOfTopSide, AboveRightSide, RightSide, RightOfTopSide);
// Draw Left Side for the first column // Draw Left Side for the first column
if (c1 == 0) if (c1 == 0 || doTop)
DrawLineVertical(cb, "Left", xLeft, yBottom, yTop, LeftSide, BottomSide, LeftOfBottomSide, BelowLeftSide, LeftOfTopSide, TopSide, AboveLeftSide); DrawLineVertical(cb, "Left", xLeft, yBottom, yTop, LeftSide, BottomSide, LeftOfBottomSide, BelowLeftSide, LeftOfTopSide, TopSide, AboveLeftSide);
// Draw Bottom Side // Draw Bottom Side
DrawHorizontalLine(cb, "Bottom", xLeft, xRight, yBottom, BottomSide, BelowLeftSide, LeftSide, LeftOfBottomSide, RightSide, BelowRightSide, RightOfBottomSide); DrawHorizontalLine(cb, "Bottom", xLeft, xRight, yBottom, BottomSide, BelowLeftSide, LeftSide, LeftOfBottomSide, RightSide, BelowRightSide, RightOfBottomSide);