Print Library, Svg Library, Utils Library, XYPlots
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
@@ -16,93 +15,54 @@ namespace Volian.Print.Library
|
||||
class CompleteROReport
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//Dictionary<string, PdfDestination> _MyErrorBookMarks = new Dictionary<string, PdfDestination>();
|
||||
Headers Hdrs; // Header stack object.
|
||||
readonly Headers Hdrs; // Header stack object.
|
||||
RODataFile RO_df = null;
|
||||
int curheaderlen;
|
||||
string RODataFileName;
|
||||
iTextSharp.text.Document _pdfReportDoc = null;
|
||||
readonly string RODataFileName;
|
||||
readonly iTextSharp.text.Document _pdfReportDoc;
|
||||
PdfPTable datatable = null;
|
||||
|
||||
private iTextSharp.text.Font _f14; // = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK);
|
||||
public iTextSharp.text.Font F14 { get; set; }
|
||||
|
||||
public iTextSharp.text.Font F14
|
||||
{
|
||||
get { return _f14; }
|
||||
set { _f14 = value; }
|
||||
}
|
||||
private iTextSharp.text.Font _f10;
|
||||
public iTextSharp.text.Font F10 { get; set; }
|
||||
|
||||
public iTextSharp.text.Font F10
|
||||
{
|
||||
get { return _f10; }
|
||||
set { _f10 = value; }
|
||||
}
|
||||
private iTextSharp.text.Font _f12;
|
||||
public iTextSharp.text.Font F12 { get; set; }
|
||||
|
||||
public iTextSharp.text.Font F12
|
||||
{
|
||||
get { return _f12; }
|
||||
set { _f12 = value; }
|
||||
}
|
||||
private iTextSharp.text.Font _f10Bold;
|
||||
public iTextSharp.text.Font F10Bold { get; set; }
|
||||
|
||||
public iTextSharp.text.Font F10Bold
|
||||
{
|
||||
get { return _f10Bold; }
|
||||
set { _f10Bold = value; }
|
||||
}
|
||||
private iTextSharp.text.Font _f12Bold;
|
||||
public iTextSharp.text.Font F12Bold { get; set; }
|
||||
|
||||
public iTextSharp.text.Font F12Bold
|
||||
{
|
||||
get { return _f12Bold; }
|
||||
set { _f12Bold = value; }
|
||||
}
|
||||
public bool ConvertCaretToDelta { get; set; } = true;
|
||||
|
||||
private bool _ConvertCaretToDelta = true;
|
||||
public bool IncludeEmptyROFields { get; set; } = false;
|
||||
|
||||
public bool ConvertCaretToDelta
|
||||
{
|
||||
get { return _ConvertCaretToDelta; }
|
||||
set { _ConvertCaretToDelta = value; }
|
||||
}
|
||||
private bool _IncludeEmptyROFields = false;
|
||||
|
||||
public bool IncludeEmptyROFields
|
||||
{
|
||||
get { return _IncludeEmptyROFields; }
|
||||
set { _IncludeEmptyROFields = value; }
|
||||
}
|
||||
private int _ROFstID;
|
||||
|
||||
public int ROFstID
|
||||
{
|
||||
get { return _ROFstID; }
|
||||
set { _ROFstID = value; }
|
||||
}
|
||||
private string ReportTitle = "Complete Referenced Objects Report";
|
||||
private PdfWriter _MyPDFWriter;
|
||||
public int ROFstID { get; set; }
|
||||
private readonly string ReportTitle = "Complete Referenced Objects Report";
|
||||
private readonly PdfWriter _MyPDFWriter;
|
||||
|
||||
public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields)
|
||||
{
|
||||
Hdrs = new Headers();
|
||||
_pdfReportDoc = document;
|
||||
RODataFileName = dataFileName;
|
||||
_ConvertCaretToDelta = convertCaretToDelta;
|
||||
ConvertCaretToDelta = convertCaretToDelta;
|
||||
_MyPDFWriter = mypdfwriter;
|
||||
_IncludeEmptyROFields = includeEmptyROFields;
|
||||
IncludeEmptyROFields = includeEmptyROFields;
|
||||
}
|
||||
public void StartNewDataTable()
|
||||
{
|
||||
datatable = new PdfPTable(1);
|
||||
datatable.TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin;
|
||||
datatable.LockedWidth = true;
|
||||
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14));
|
||||
cell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
cell.BackgroundColor = Color.WHITE;
|
||||
cell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(cell);
|
||||
datatable = new PdfPTable(1)
|
||||
{
|
||||
TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin,
|
||||
LockedWidth = true
|
||||
};
|
||||
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14))
|
||||
{
|
||||
HorizontalAlignment = Element.ALIGN_CENTER,
|
||||
BackgroundColor = Color.WHITE,
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
datatable.AddCell(cell);
|
||||
datatable.HeaderRows = 3;
|
||||
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||
}
|
||||
@@ -113,33 +73,17 @@ namespace Volian.Print.Library
|
||||
PrintReport();
|
||||
RO_df.close();
|
||||
}
|
||||
private Dictionary<int, DocOutline> _MyDocOutline = new Dictionary<int, DocOutline>();
|
||||
|
||||
internal Dictionary<int, DocOutline> MyDocOutline
|
||||
internal Dictionary<int, DocOutline> MyDocOutline { get; set; } = new Dictionary<int, DocOutline>();
|
||||
public class DocOutline
|
||||
{
|
||||
get { return _MyDocOutline; }
|
||||
set { _MyDocOutline = value; }
|
||||
}
|
||||
public class DocOutline
|
||||
{
|
||||
private PdfOutline _MyOutline;
|
||||
public PdfOutline MyOutline { get; set; }
|
||||
|
||||
public PdfOutline MyOutline
|
||||
public string MyHeader { get; set; }
|
||||
public DocOutline(PdfOutline outline, string header)
|
||||
{
|
||||
get { return _MyOutline; }
|
||||
set { _MyOutline = value; }
|
||||
}
|
||||
private string _MyHeader;
|
||||
|
||||
public string MyHeader
|
||||
{
|
||||
get { return _MyHeader; }
|
||||
set { _MyHeader = value; }
|
||||
}
|
||||
public DocOutline(PdfOutline outline, string header)
|
||||
{
|
||||
_MyHeader = header;
|
||||
_MyOutline = outline;
|
||||
MyHeader = header;
|
||||
MyOutline = outline;
|
||||
}
|
||||
}
|
||||
private string ReplaceLineDrawCharsWithUnicode(string text)
|
||||
@@ -167,7 +111,6 @@ namespace Volian.Print.Library
|
||||
instr = instr.Replace("[RHO]", "\u03C1"); // C2016-018 rho symbol - is being read in as a line draw character, so users need to put "[RHO]" in their text for the rho symbol to print
|
||||
if (ConvertCaretToDelta)
|
||||
{
|
||||
//char[] ca = instr.ToCharArray(); // for debug
|
||||
instr = instr.Replace("^", "\u0394"); // delta
|
||||
}
|
||||
//instr = instr.Replace("\x94", "\u0394"); // delta - the delta symbol is being read in as character x94
|
||||
@@ -188,7 +131,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
string tstr = (instr.Substring(idx+uidx, m1.Index - uidx));
|
||||
if (tstr.EndsWith(" "))
|
||||
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
|
||||
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
|
||||
chk = new Chunk(tstr, fnt);
|
||||
if (underlineChunk)
|
||||
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
|
||||
@@ -244,7 +187,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
string tstr = (strChk.Substring(uidx, m1.Index - uidx));
|
||||
if (tstr.EndsWith(" "))
|
||||
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
|
||||
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
|
||||
chk = new Chunk(tstr, fnt);
|
||||
if (underlineChunk)
|
||||
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
|
||||
@@ -264,7 +207,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
string tstr = strChk.Substring(uidx);
|
||||
if (tstr.EndsWith(" "))
|
||||
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
|
||||
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
|
||||
chk = new Chunk(tstr, fnt);
|
||||
if (underlineChunk)
|
||||
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
|
||||
@@ -276,12 +219,9 @@ 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)
|
||||
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
|
||||
@@ -289,11 +229,15 @@ namespace Volian.Print.Library
|
||||
string[] strlst = txt.Split(delim,StringSplitOptions.None);
|
||||
foreach (string str in strlst)
|
||||
{
|
||||
Font f = new Font(fnt);
|
||||
f.Color = txtcolor;
|
||||
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f));
|
||||
cell.BorderColor = Color.WHITE;
|
||||
if (strlst.Length > 1)
|
||||
Font f = new Font(fnt)
|
||||
{
|
||||
Color = txtcolor
|
||||
};
|
||||
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f))
|
||||
{
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
if (strlst.Length > 1)
|
||||
cell.PaddingBottom = 6;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
@@ -301,11 +245,12 @@ namespace Volian.Print.Library
|
||||
|
||||
public void AddImage(string filename)
|
||||
{
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(_ROFstID, filename);
|
||||
if (roImage == null) roImage = ROFstInfo.Get(_ROFstID).GetROImageByFilename(filename, null);
|
||||
PdfPCell spaceCell = new PdfPCell();
|
||||
spaceCell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(spaceCell);
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(ROFstID, filename) ?? ROFstInfo.Get(ROFstID).GetROImageByFilename(filename, null);
|
||||
PdfPCell spaceCell = new PdfPCell
|
||||
{
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
datatable.AddCell(spaceCell);
|
||||
if (roImage != null)
|
||||
{
|
||||
ROImageConfig rc = new ROImageConfig(roImage);
|
||||
@@ -318,8 +263,8 @@ namespace Volian.Print.Library
|
||||
it_image = iTextSharp.text.Image.GetInstance(dcnt);
|
||||
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(dcnt);
|
||||
@@ -342,9 +287,11 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
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);
|
||||
PdfPCell cell = new PdfPCell(it_image)
|
||||
{
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
datatable.AddCell(cell);
|
||||
roImage.Dispose();
|
||||
}
|
||||
else
|
||||
@@ -364,17 +311,21 @@ namespace Volian.Print.Library
|
||||
if (ConvertCaretToDelta)
|
||||
plotlang = plotlang.Replace("^", "\x394"); // delta
|
||||
plotlang = plotlang.Replace("\x7F", "\x394"); //delta
|
||||
PdfPCell spaceCell = new PdfPCell();
|
||||
spaceCell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(spaceCell);
|
||||
PdfPCell spaceCell = new PdfPCell
|
||||
{
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
datatable.AddCell(spaceCell);
|
||||
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);
|
||||
PdfPCell cell = new PdfPCell(it_image)
|
||||
{
|
||||
BorderColor = Color.WHITE
|
||||
};
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -386,94 +337,88 @@ namespace Volian.Print.Library
|
||||
}
|
||||
|
||||
private string processingRO = "";
|
||||
private string _MyROID = null;
|
||||
public string MyROID
|
||||
{
|
||||
get { return _MyROID; }
|
||||
set { _MyROID = value; }
|
||||
}
|
||||
|
||||
public void PrintReport()
|
||||
public string MyROID { get; set; } = null;
|
||||
|
||||
public void PrintReport()
|
||||
{
|
||||
bool StopPrinting = false;
|
||||
bool UserTerminate = false;
|
||||
Int16 iRecType = 0;
|
||||
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
|
||||
try
|
||||
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
|
||||
try
|
||||
{
|
||||
if (RO_df.GetFileLength() > 0)
|
||||
{
|
||||
showStatBar.BarMax = (int)RO_df.GetFileLength();
|
||||
showStatBar.StatMsg = "Creating Report";
|
||||
// Loop until either printing is aborted or end of file.
|
||||
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
|
||||
{
|
||||
//Console.WriteLine("Record Type: {0}.{0:X}", iRecType);
|
||||
switch (iRecType)
|
||||
{
|
||||
case 1: // Set Header
|
||||
SetHeader();
|
||||
break;
|
||||
case 2: // Push Header
|
||||
PushHeader();
|
||||
break;
|
||||
case 3: // Pop Header
|
||||
PopHeader();
|
||||
break;
|
||||
case 4: // RRO Begin
|
||||
RROBegin();
|
||||
break;
|
||||
case 5: // RRO End
|
||||
RROEnd();
|
||||
processingRO = "";
|
||||
break;
|
||||
case 6: // Msg
|
||||
Msg();
|
||||
break;
|
||||
case 7:
|
||||
processingRO = KeyField();
|
||||
break;
|
||||
case 8:
|
||||
MyROID = ROIDField();
|
||||
break;
|
||||
case 100: // Text Field - sometimes also XY Plot
|
||||
Text();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 101: // Plot Field
|
||||
XYPlot();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 102: // Image Field
|
||||
ImageFile();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 103: // Multi Begin - Display data for setpoints
|
||||
Multiple();
|
||||
break;
|
||||
case 104: // Multi End
|
||||
break;
|
||||
case 0: // nothing was entered in that field
|
||||
if (_IncludeEmptyROFields)
|
||||
NoInformatEntered();
|
||||
break;
|
||||
case 255:
|
||||
_pdfReportDoc.Add(datatable);
|
||||
_pdfReportDoc.NewPage();
|
||||
StartNewDataTable();
|
||||
showStatBar.BarValue = (int)RO_df.GetFilePointerPosition();
|
||||
//Console.WriteLine("Record Type: {0} No Operation", iRecType);
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
break;
|
||||
default: // Problem
|
||||
//Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType);
|
||||
StopPrinting = true;
|
||||
UserTerminate = true;
|
||||
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
short iRecType;
|
||||
// Loop until either printing is aborted or end of file.
|
||||
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
|
||||
{
|
||||
//Console.WriteLine("Record Type: {0}.{0:X}", iRecType);
|
||||
switch (iRecType)
|
||||
{
|
||||
case 1: // Set Header
|
||||
SetHeader();
|
||||
break;
|
||||
case 2: // Push Header
|
||||
PushHeader();
|
||||
break;
|
||||
case 3: // Pop Header
|
||||
PopHeader();
|
||||
break;
|
||||
case 4: // RRO Begin
|
||||
RROBegin();
|
||||
break;
|
||||
case 5: // RRO End
|
||||
RROEnd();
|
||||
processingRO = "";
|
||||
break;
|
||||
case 6: // Msg
|
||||
Msg();
|
||||
break;
|
||||
case 7:
|
||||
processingRO = KeyField();
|
||||
break;
|
||||
case 8:
|
||||
MyROID = ROIDField();
|
||||
break;
|
||||
case 100: // Text Field - sometimes also XY Plot
|
||||
Text();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 101: // Plot Field
|
||||
XYPlot();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 102: // Image Field
|
||||
ImageFile();
|
||||
Application.DoEvents();
|
||||
break;
|
||||
case 103: // Multi Begin - Display data for setpoints
|
||||
Multiple();
|
||||
break;
|
||||
case 104: // Multi End
|
||||
break;
|
||||
case 0: // nothing was entered in that field
|
||||
if (IncludeEmptyROFields)
|
||||
NoInformatEntered();
|
||||
break;
|
||||
case 255:
|
||||
_pdfReportDoc.Add(datatable);
|
||||
_pdfReportDoc.NewPage();
|
||||
StartNewDataTable();
|
||||
showStatBar.BarValue = (int)RO_df.GetFilePointerPosition();
|
||||
//Console.WriteLine("Record Type: {0} No Operation", iRecType);
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
break;
|
||||
default: // Problem
|
||||
StopPrinting = true;
|
||||
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
break;
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartNewDataTable();
|
||||
@@ -502,20 +447,22 @@ namespace Volian.Print.Library
|
||||
// if there is lenght then we are in the mist of processing an RO
|
||||
string headers = erMsg;
|
||||
for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++)
|
||||
headers += Hdrs.strHdrs[iLoop] + "\n ";
|
||||
headers += $"{Hdrs.strHdrs[iLoop]}\n ";
|
||||
if (processingRO.Length > 0)
|
||||
headers += processingRO;
|
||||
if (erMsg2 != null && erMsg2.Length > 0)
|
||||
headers += "\n" + erMsg2;
|
||||
//MessageBox.Show(headers, erMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (e != null)
|
||||
_MyLog.Error(headers, e);
|
||||
else
|
||||
_MyLog.Error(headers);
|
||||
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
|
||||
//DestSample(outl);
|
||||
}
|
||||
#pragma warning disable IDE0059 // Unnecessary assignment of a value - for debugging
|
||||
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
|
||||
#pragma warning restore IDE0059 // Unnecessary assignment of a value
|
||||
//DestSample(outl);
|
||||
}
|
||||
|
||||
//For Debugging/Testing
|
||||
//private void DestSample(PdfOutline outl)
|
||||
//{
|
||||
// new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT");
|
||||
@@ -531,29 +478,22 @@ namespace Volian.Print.Library
|
||||
public void AddErrorBookmarks()
|
||||
{
|
||||
if (_MyErrorOutline == null) return;
|
||||
//if (_MyErrorBookMarks.Count == 0) return;
|
||||
//PdfOutline outline = null;
|
||||
//foreach (string key in _MyErrorBookMarks.Keys)
|
||||
//{
|
||||
// if (outline == null) outline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, _MyErrorBookMarks[key], "Errors");
|
||||
// new PdfOutline(outline, _MyErrorBookMarks[key], key);
|
||||
//}
|
||||
string emsg = "A Bookmark grouping named \"Errors\" was added to the PDF.\n\n Click on the RO in this grouping to jump to the report page which will contain an error message.\n\nThe error were also recorded in the PROMS error log.";
|
||||
MessageBox.Show(emsg, "Errors Found Creating Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
public void Multiple()
|
||||
{
|
||||
Int16 typ, i, j, nw = 0;
|
||||
short typ, i, j;
|
||||
string str, sep;
|
||||
string buff = "";
|
||||
int[] width;
|
||||
LastHeader();
|
||||
sep = "";
|
||||
// nw - number of fields
|
||||
nw = RO_df.ReadInteger16();
|
||||
// allocate space for widths
|
||||
width = new int[nw];
|
||||
// nw - number of fields
|
||||
short nw = RO_df.ReadInteger16();
|
||||
// allocate space for widths
|
||||
width = new int[nw];
|
||||
// loop through and load field widths and names
|
||||
for (i = 0; i < nw; i++)
|
||||
{
|
||||
@@ -645,7 +585,7 @@ namespace Volian.Print.Library
|
||||
//Console.WriteLine("Set Header");
|
||||
|
||||
// Get the number of header records
|
||||
Int16 iNewCnt = RO_df.ReadInteger16();
|
||||
short iNewCnt = RO_df.ReadInteger16();
|
||||
|
||||
//Console.WriteLine("Num Header Records: {0}", iNewCnt);
|
||||
|
||||
@@ -676,16 +616,11 @@ namespace Volian.Print.Library
|
||||
bool _LastWasName = false;//B2016-251 Don't change underscore to underline to Name value
|
||||
public void PushHeader()
|
||||
{
|
||||
//if (m_pPrinterOut->Row() > 55)
|
||||
//// m_pPrinterOut->newpage();
|
||||
//pdfReportDoc.NewPage();
|
||||
string pTmp = RO_df.ReadText();
|
||||
//Console.WriteLine("PH[{0}]", pTmp);
|
||||
curheaderlen = pTmp.Length;
|
||||
_LastWasName = (pTmp == "Name");//B2016-251 Don't change underscore to underline to Name value
|
||||
//Hdrs.strHdrs[Hdrs.HdrCnt] = pTmp;
|
||||
Hdrs.strHdrs.Add(pTmp);
|
||||
//Hdrs.repeatCount[Hdrs.HdrCnt] = 2;
|
||||
Hdrs.repeatCount.Add(2);
|
||||
Hdrs.HdrCnt++;
|
||||
Hdrs.printedLastHeader = false;
|
||||
@@ -704,15 +639,12 @@ namespace Volian.Print.Library
|
||||
// if the last header was pushed on header list
|
||||
// print eject the page if the page ran out, and
|
||||
// print the header with "none".
|
||||
//if (m_pPrinterOut->Row() > 55)
|
||||
// m_pPrinterOut->NewPage();
|
||||
LastHeader();
|
||||
//m_pPrinterOut->PutLine(0, "none");
|
||||
//m_pPrinterOut->NewLine(1);
|
||||
}
|
||||
// Remove the header
|
||||
Hdrs.HdrCnt--;
|
||||
//Hdrs.strHdrs[Hdrs.HdrCnt] = null;
|
||||
Hdrs.strHdrs.RemoveAt(Hdrs.HdrCnt);
|
||||
Hdrs.repeatCount.RemoveAt(Hdrs.HdrCnt);
|
||||
|
||||
@@ -722,7 +654,6 @@ namespace Volian.Print.Library
|
||||
|
||||
public void RROBegin()
|
||||
{
|
||||
//m_pPrinterOut->NewPage();
|
||||
//Console.WriteLine("RRO Begin");
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
// Start of a new RO, print out the headers
|
||||
@@ -730,12 +661,11 @@ namespace Volian.Print.Library
|
||||
{
|
||||
if (!MyDocOutline.ContainsKey(iLoop) || MyDocOutline[iLoop].MyHeader != Hdrs.strHdrs[iLoop])
|
||||
{
|
||||
PdfOutline parentOutline = null;
|
||||
if (iLoop == 0)
|
||||
PdfOutline parentOutline;
|
||||
if (iLoop == 0)
|
||||
parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline;
|
||||
else
|
||||
parentOutline = MyDocOutline[iLoop - 1].MyOutline;
|
||||
//pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
|
||||
AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage);
|
||||
}
|
||||
// Change double underscore to spaces in header text
|
||||
@@ -748,20 +678,13 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// FITH was acting strange and shifting towards bottom of the page as the number of pages increased
|
||||
//Console.WriteLine("Top = {0}, {1}", _Top, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
|
||||
//return new PdfDestination(PdfDestination.FITH, _Top);//_MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
|
||||
return new PdfDestination(PdfDestination.XYZ, 0, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public PdfDestination MyPdfDestPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return new PdfDestination(PdfDestination.FITV,0);
|
||||
}
|
||||
}
|
||||
public PdfDestination MyPdfDestPage => new PdfDestination(PdfDestination.FITV, 0);
|
||||
|
||||
private PdfOutline _MyErrorOutline = null;
|
||||
private PdfOutline _MyErrorOutline = null;
|
||||
|
||||
public PdfOutline MyErrorOutline
|
||||
{
|
||||
@@ -787,7 +710,6 @@ namespace Volian.Print.Library
|
||||
return _MyRootOutline;
|
||||
}
|
||||
}
|
||||
private PdfDestination pdfDest = null;
|
||||
private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest)
|
||||
{
|
||||
if (MyDocOutline.ContainsKey(iLoop))
|
||||
@@ -798,7 +720,6 @@ namespace Volian.Print.Library
|
||||
|
||||
public void RROEnd()
|
||||
{
|
||||
//m_pPrinterOut->PageEnd();
|
||||
// Remove any headers that are left over
|
||||
//Console.WriteLine("{0} headers cleaned up.", Hdrs.HdrCnt);
|
||||
//Console.WriteLine("RRO End");
|
||||
@@ -843,7 +764,7 @@ namespace Volian.Print.Library
|
||||
public void Text()
|
||||
{
|
||||
// Get the lenght of the text string and read it in
|
||||
Int16 iValue = RO_df.ReadInteger16();
|
||||
short iValue = RO_df.ReadInteger16();
|
||||
string szStr = "";
|
||||
// B2016-247 If size is zero it is an empty string.
|
||||
if (iValue > 0)
|
||||
@@ -867,11 +788,9 @@ namespace Volian.Print.Library
|
||||
|
||||
if (isXYPlot || (iValue + curheaderlen) > 72 || (szStr.IndexOf('\r') != -1))
|
||||
{
|
||||
// If the lenght of the string plus the field title is greater
|
||||
// If the length of the string plus the field title is greater
|
||||
// than 72 characters or has a carriage return character in it
|
||||
// then output the text on multiple lines
|
||||
//if (m_pPrinterOut->Row() > 55)
|
||||
// m_pPrinterOut->newpage();
|
||||
|
||||
// the header goes on its own line
|
||||
cell.AddElement(p);
|
||||
@@ -891,10 +810,6 @@ namespace Volian.Print.Library
|
||||
datatable.AddCell(cell);
|
||||
//m_pPrinterOut->SetNumberOfNewLines(0);
|
||||
//m_pPrinterOut->putline(0, temp);
|
||||
//if (m_pPrinterOut->Row() + 1 > 55)
|
||||
// Hdrs.repeatCount[Hdrs.HdrCnt] = 1;
|
||||
//else
|
||||
// m_pPrinterOut->newline(1);
|
||||
}
|
||||
//Console.WriteLine("Text");
|
||||
//Console.WriteLine("Value: {0}", iValue);
|
||||
@@ -906,10 +821,11 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// use the key field as the PDF bookbark
|
||||
string szStr = RO_df.ReadText();
|
||||
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
|
||||
PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
|
||||
//DestSample(outl);
|
||||
return szStr;
|
||||
#pragma warning disable IDE0059 // Unnecessary assignment of a value - For Debugging
|
||||
PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
|
||||
#pragma warning restore IDE0059 // Unnecessary assignment of a value
|
||||
//DestSample(outl);
|
||||
return szStr;
|
||||
//Console.WriteLine("Key Field");
|
||||
//Console.WriteLine("Key Text: {0}", szStr);
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
@@ -918,6 +834,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// use the key field as the PDF bookbark
|
||||
string szStr = RO_df.ReadText();
|
||||
//For Dubugging
|
||||
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
|
||||
//PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
|
||||
//DestSample(outl);
|
||||
@@ -931,25 +848,26 @@ namespace Volian.Print.Library
|
||||
public void ImageFile()
|
||||
{
|
||||
string fn = RO_df.ReadText();
|
||||
Int16 ht = RO_df.ReadInteger16();
|
||||
Int16 wd = RO_df.ReadInteger16();
|
||||
//m_pPrinterOut->PrintImage(fn, wd, ht);
|
||||
#pragma warning disable IDE0059 // Unnecessary assignment of a value - for Debugging
|
||||
short ht = RO_df.ReadInteger16();
|
||||
short wd = RO_df.ReadInteger16();
|
||||
#pragma warning restore IDE0059 // Unnecessary assignment of a value
|
||||
//m_pPrinterOut->PrintImage(fn, wd, ht);
|
||||
|
||||
//Console.WriteLine("ImageFile");
|
||||
//Console.WriteLine("Name: {0}", fn);
|
||||
//Console.WriteLine("Height: {0}", ht);
|
||||
//Console.WriteLine("Width: {0}", wd);
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
AddImage(fn);
|
||||
//Console.WriteLine("ImageFile");
|
||||
//Console.WriteLine("Name: {0}", fn);
|
||||
//Console.WriteLine("Height: {0}", ht);
|
||||
//Console.WriteLine("Width: {0}", wd);
|
||||
//Console.WriteLine("----------------------------------------------");
|
||||
AddImage(fn);
|
||||
}
|
||||
// Read in the X/Y plot info.
|
||||
public void XYPlot()
|
||||
{
|
||||
// Get the lenght of the text string and read it in
|
||||
Int16 iValue = RO_df.ReadInteger16();
|
||||
short iValue = RO_df.ReadInteger16();
|
||||
string szStr = RO_df.ReadText(iValue);
|
||||
string temp = szStr;
|
||||
Chunk chk = LastHeader(); // = new Chunk(m.Value, fnt);
|
||||
Chunk chk = LastHeader();
|
||||
Phrase p = new Phrase();
|
||||
PdfPCell cell = new PdfPCell();
|
||||
p.Add(chk); // add the header chunk
|
||||
@@ -997,7 +915,6 @@ namespace Volian.Print.Library
|
||||
chk = new Chunk(hdrtxt, F10Bold);
|
||||
Hdrs.printedLastHeader = true;
|
||||
return chk;
|
||||
//m_pPrinterOut->LastHeader();
|
||||
}
|
||||
|
||||
}// end CompSumROReport
|
||||
@@ -1005,9 +922,7 @@ namespace Volian.Print.Library
|
||||
|
||||
public class Headers
|
||||
{
|
||||
//public string[] strHdrs;
|
||||
public List<string> strHdrs;
|
||||
// public int[] repeatCount;
|
||||
public int HdrCnt;
|
||||
public List<int> repeatCount;
|
||||
public bool printedLastHeader;
|
||||
@@ -1022,8 +937,8 @@ namespace Volian.Print.Library
|
||||
|
||||
public class RODataFile
|
||||
{
|
||||
FileStream fs = null;
|
||||
BinaryReader br = null;
|
||||
readonly FileStream fs = null;
|
||||
readonly BinaryReader br = null;
|
||||
public RODataFile(string fname)
|
||||
{
|
||||
fs = new FileStream(fname,FileMode.Open);
|
||||
@@ -1034,16 +949,10 @@ namespace Volian.Print.Library
|
||||
br.Close();
|
||||
fs.Close();
|
||||
}
|
||||
public long GetFileLength()
|
||||
{
|
||||
return fs.Length;
|
||||
}
|
||||
public long GetFilePointerPosition()
|
||||
{
|
||||
return fs.Position;
|
||||
}
|
||||
// Read an integer value from the data file
|
||||
public Int16 ReadInteger16()
|
||||
public long GetFileLength() => fs.Length;
|
||||
public long GetFilePointerPosition() => fs.Position;
|
||||
// Read an integer value from the data file
|
||||
public Int16 ReadInteger16()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1055,18 +964,15 @@ namespace Volian.Print.Library
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// Read a text string from the data file and returns it.
|
||||
// The calling program is responsible for free it
|
||||
// with the "delete" operator.
|
||||
// Read a text string from the data file and returns it.
|
||||
// The calling program is responsible for free it
|
||||
// with the "delete" operator.
|
||||
|
||||
public string ReadText()
|
||||
{
|
||||
return ReadText(-1);
|
||||
}
|
||||
public string ReadText() => ReadText(-1);
|
||||
|
||||
public string ReadText(Int16 i16CharCount)
|
||||
public string ReadText(Int16 i16CharCount)
|
||||
{
|
||||
Int16 i16DataSize;
|
||||
short i16DataSize;
|
||||
if (i16CharCount == -1)
|
||||
i16DataSize = ReadInteger16();
|
||||
else
|
||||
@@ -1082,15 +988,14 @@ namespace Volian.Print.Library
|
||||
for (int i = 0; i < i16DataSize; i++)
|
||||
str += Convert.ToChar(charbuff[i]).ToString();
|
||||
return (str);
|
||||
//return (Encoding.ASCII.GetString(charbuff, 0, i16DataSize)); // this didn't handle line draw chars
|
||||
}
|
||||
}
|
||||
|
||||
// Search through the file to find the next record
|
||||
public long NextRecord()
|
||||
{
|
||||
Int16 iType;
|
||||
Int16 RECORD_START = 255;
|
||||
short iType;
|
||||
short RECORD_START = 255;
|
||||
// While not the next record and not end of file get the next meta item
|
||||
while ((iType = ReadInteger16()) != RECORD_START && iType != -1)
|
||||
{
|
||||
@@ -1101,28 +1006,25 @@ namespace Volian.Print.Library
|
||||
// Get the next meta item and discard the data
|
||||
public long NextItem()
|
||||
{
|
||||
string pTmp;
|
||||
Int16 iRecType = ReadInteger16();
|
||||
Int16 iNewCnt;
|
||||
int iLoop;
|
||||
switch (iRecType)
|
||||
short iRecType = ReadInteger16();
|
||||
short iNewCnt;
|
||||
int iLoop;
|
||||
switch (iRecType)
|
||||
{
|
||||
case 1: // Set Header
|
||||
iNewCnt = ReadInteger16();
|
||||
for (iLoop = 0; iLoop < iNewCnt; iLoop++)
|
||||
{
|
||||
ReadInteger16();
|
||||
pTmp = ReadText();
|
||||
//delete pTmp;
|
||||
_ = ReadText();
|
||||
}
|
||||
break;
|
||||
case 2: // Push Header
|
||||
case 6: // Msg
|
||||
case 7: // Key Field
|
||||
case 100: // Text Field
|
||||
case 101: // Plot Field
|
||||
pTmp = ReadText();
|
||||
//delete pTmp;
|
||||
case 101: // Plot Field
|
||||
_ = ReadText();
|
||||
break;
|
||||
case 3: // Pop Header
|
||||
case 4: // RRO Begin
|
||||
@@ -1133,8 +1035,7 @@ namespace Volian.Print.Library
|
||||
// Do nothing
|
||||
break;
|
||||
case 102: // Image Field
|
||||
pTmp = ReadText();
|
||||
//delete pTmp;
|
||||
_ = ReadText();
|
||||
ReadInteger16();
|
||||
ReadInteger16();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user