Added logic to handle RO Database that have the same Setpoint ID value in multiple tables – this affect reporting on all RO Databases, sorting by Setoint ID

Fixed underline logic for instances where the underline ON is the first thing of text.  Added better error handling for X/Y Plots which is now display the plot language if the plot cannot be drawn.  When a problem occurs printing an image or x/y plot, the error text now prints in red.
Better handling of empty RO Database tables.  Now will print the message “—No Information Entered –“
This commit is contained in:
2015-05-12 20:27:47 +00:00
parent 7cb9861534
commit 5d5f84ce23
3 changed files with 67 additions and 60 deletions

View File

@@ -194,6 +194,11 @@ namespace Volian.Print.Library
strlen -= (tstr.Length + 1);
underlineChunk = !underlineChunk;
}
else if (uidx == m1.Index)
{
uidx++;
underlineChunk = !underlineChunk;
}
}
chk = new Chunk(instr.Substring(idx, strlen), fnt);
if (underlineChunk)
@@ -241,6 +246,11 @@ namespace Volian.Print.Library
uidx += (tstr.Length+1);
underlineChunk = !underlineChunk;
}
else if (uidx == m1.Index)
{
uidx++;
underlineChunk = !underlineChunk;
}
}
if (uidx < strChk.Length - 1)
{
@@ -257,8 +267,13 @@ namespace Volian.Print.Library
return p;
}
public void AddText(string txt, Font fnt)
{
AddText(txt, fnt, Color.BLACK);
}
public void AddText(string txt, Font fnt, Color txtcolor)
{
// break the text up on double returns (paragraphs) and put each in their own cell
// this will allow for page breaks between paragraphs0
@@ -266,7 +281,9 @@ namespace Volian.Print.Library
string[] strlst = txt.Split(delim,StringSplitOptions.None);
foreach (string str in strlst)
{
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, fnt));
Font f = new Font(fnt);
f.Color = txtcolor;
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f));
cell.BorderColor = Color.WHITE;
if (strlst.Length > 1)
cell.PaddingBottom = 6;
@@ -310,11 +327,8 @@ namespace Volian.Print.Library
}
catch (Exception ex2)
{
PdfPCell cell2 = new PdfPCell(new Phrase(string.Format("Bad Image File: {0}", filename)));
cell2.BorderColor = Color.WHITE;
datatable.AddCell(cell2);
AddText(string.Format("Bad Image File: {0}", filename), F12, Color.RED);
GenerateErrorMessage(ex2, "Bad Image File. ", string.Format("Image File: {0}", filename));
//_MyErrorBookMarks.Add(filename, pdfDest);
roImage.Dispose();
return;
}
@@ -327,29 +341,37 @@ namespace Volian.Print.Library
}
else
{
PdfPCell messageCell = new PdfPCell(new Phrase(string.Format("Image File {0} is missing.", filename)));
messageCell.BorderColor = Color.WHITE;
datatable.AddCell(messageCell);
AddText(string.Format("Image File {0} is missing.", filename), F12, Color.RED);
GenerateErrorMessage(null, "Image File Missing. ", string.Format("Image File: {0}", filename));
Application.DoEvents();
//_MyErrorBookMarks.Add(filename, pdfDest);
}
}
public void AddXYPlot(string plotlang)
{
string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png";
string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png";
string rawPlotLang = plotlang;
plotlang = plotlang.Replace("`", "\xB0");
plotlang = plotlang.Replace("\xF8", "\xB0");
System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile);
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell spaceCell = new PdfPCell();
spaceCell.BorderColor = Color.WHITE;
datatable.AddCell(spaceCell);
PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
try
{
System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile);
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
}
catch (Exception e)
{
AddText("-- Error Processing X/Y Plot Language --",F12,Color.RED);
datatable.AddCell(spaceCell);
AddText(rawPlotLang, F10);
GenerateErrorMessage(null, "Error Processing X/Y Plot Lanuage. ", e.Message);
}
}
private string processingRO = "";
@@ -606,43 +628,11 @@ namespace Volian.Print.Library
Int16 iNewCnt = RO_df.ReadInteger16();
//Console.WriteLine("Num Header Records: {0}", iNewCnt);
// Clear the existing headers
Hdrs.strHdrs.Clear();
// Loop through the headers
int iLoop = 0;
for (; iLoop < Hdrs.HdrCnt; iLoop++)
{
if (iLoop >= iNewCnt)
// If the current header index is above the new number
// of headers, delete it.
Hdrs.strHdrs[iLoop] = null;
else
{
// Otherwise:
Int16 iTmpRpt;
// Get the repeat count for the header
iTmpRpt = RO_df.ReadInteger16();
//Console.WriteLine("repeat count for header: {0}", iTmpRpt);
// Get the text of the header
pTmp = RO_df.ReadText();
//Console.WriteLine("Header Text: {0}", pTmp);
if (!pTmp.Equals(Hdrs.strHdrs[iLoop]))
{
// if the old header does not equal the new header
// delete the old header and create a the one
Hdrs.strHdrs[iLoop] = pTmp;
Hdrs.repeatCount[iLoop] = iTmpRpt;
}
else
{
// Otherwise, delete the temperary header data.
pTmp = null;
}
}
}
// If there are any other headers left in the file,
// load those in as well.
for (; iLoop < iNewCnt; iLoop++)
{
int hdrRptCnt = (int)RO_df.ReadInteger16();