Print Library, Svg Library, Utils Library, XYPlots

This commit is contained in:
2026-07-24 13:36:46 -04:00
parent 06c3136566
commit f67d37801a
68 changed files with 12173 additions and 16618 deletions
@@ -6,35 +6,20 @@ using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Linq;
namespace Volian.Print.Library
{
public class PDFConsistencyCheckReport
{
private DocVersionInfo _MyDocVersion;
public DocVersionInfo MyDocVersion
public DocVersionInfo MyDocVersion { get; set; }
public string FileName { get; set; }
public ItemInfoList MyItemInfoList { get; set; }
public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion)
{
get { return _MyDocVersion; }
set { _MyDocVersion = value; }
}
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private ItemInfoList _MyItemInfoList;
public ItemInfoList MyItemInfoList
{
get { return _MyItemInfoList; }
set { _MyItemInfoList = value; }
}
public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion)
{
_FileName = fileName;
_MyItemInfoList = myItemInfoList;
_MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format
FileName = fileName;
MyItemInfoList = myItemInfoList;
MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format
}
public void BuildReport()
{
@@ -47,7 +32,6 @@ namespace Volian.Print.Library
}
catch (Exception ex)
{
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:"));
while (ex != null)
{
@@ -61,7 +45,7 @@ namespace Volian.Print.Library
if (document.IsOpen())
{
document.Close();
System.Diagnostics.Process.Start(_FileName);
System.Diagnostics.Process.Start(FileName);
}
}
}
@@ -73,13 +57,13 @@ namespace Volian.Print.Library
// Try to open a file for creating the PDF.
while (result == false)
{
string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf");
string fileName = FileName.ToLower().Replace(".pdf", suffix + ".pdf");
try
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
document.SetMargins(36, 36, 36, 36);
document.Open();
_FileName = fileName;
FileName = fileName;
result = true;
}
catch (System.IO.IOException exIO)
@@ -118,10 +102,12 @@ namespace Volian.Print.Library
}
private PdfPCell BlankCell(int colSpan)
{
PdfPCell c = new PdfPCell();
c.Colspan = colSpan;
c.Border = 0;
return c;
PdfPCell c = new PdfPCell
{
Colspan = colSpan,
Border = 0
};
return c;
}
private void BuildConsistencyReport(iTextSharp.text.Document doc)
{
@@ -132,7 +118,6 @@ namespace Volian.Print.Library
iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK);
iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK);
int cols = 5;
int borders = 0;
int paddingBottom = 6;
// float[] widths;
Csla.SortedBindingList<ItemInfo> sortedProcs = new Csla.SortedBindingList<ItemInfo>(MyItemInfoList);
@@ -141,7 +126,7 @@ namespace Volian.Print.Library
// B2019-024: First page of Report prints the title at the top and the remainder of the page is blank.
// Check if procedure(s) are printed on that page and if not, change message to "No..." and don't do
// pagebreak.
foreach (ProcedureInfo pi in sortedProcs)
foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{
if (pi.IsSelected)
{
@@ -160,17 +145,21 @@ namespace Volian.Print.Library
lbSrchResults.DataSource = sortedResults;
*/
foreach (ProcedureInfo pi in sortedProcs)
foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{
if (pi.IsSelected)
{
PdfPTable tt = new PdfPTable(cols);
tt.KeepTogether = true;
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
PdfPTable tt = new PdfPTable(cols)
{
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt);
c.Colspan = cols;
t.AddCell(c);
PdfPCell c = new PdfPCell(tt)
{
Colspan = cols
};
t.AddCell(c);
}
}
t.AddCell(BlankCell(cols));
@@ -179,60 +168,76 @@ namespace Volian.Print.Library
if (didSome) doc.NewPage();
t = CreatePdfPTable(cols);
CreatePageHeader(t, f1, f4, cols, paddingBottom, "Approval Consistency Report", "Procedures that should be selected to be approved in order to maintain consistency");
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
if (!pi.IsSelected)
{
PdfPTable tt = new PdfPTable(cols);
tt.KeepTogether = true;
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
PdfPTable tt = new PdfPTable(cols)
{
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt);
c.Colspan = cols;
t.AddCell(c);
PdfPCell c = new PdfPCell(tt)
{
Colspan = cols
};
t.AddCell(c);
}
}
doc.Add(t);
}
private PdfPCell AddSubTableCell(string text, iTextSharp.text.Font f, int cols, float pb)
{
Phrase h = new Phrase();
h.Font = f;
h.Add(text);
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = pb;
return c;
Phrase h = new Phrase
{
Font = f
};
h.Add(text);
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = pb
};
return c;
}
private void CreatePageHeader(PdfPTable t, iTextSharp.text.Font f1, iTextSharp.text.Font f2, int cols, float pb, string hdr1, string hdr2)
{
//report title
Phrase h = new Phrase();
h.Font = f1;
h.Add(hdr1);
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = pb;
//c.Border = borders;
t.AddCell(c);
h = new Phrase();
h.Font = f2;
h.Add(hdr2);
c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = pb;
//c.Border = borders;
t.AddCell(c);
//report title
Phrase h = new Phrase
{
Font = f1
};
h.Add(hdr1);
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = pb
};
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(hdr2);
c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = pb
};
t.AddCell(c);
t.AddCell(BlankCell(cols));
}
private PdfPTable CreatePdfPTable(int cols)
{
PdfPTable t = new PdfPTable(cols);
t.HeaderRows = 3;
t.DefaultCell.Padding = 4;
PdfPTable t = new PdfPTable(cols)
{
HeaderRows = 3
};
t.DefaultCell.Padding = 4;
t.WidthPercentage = 100;
float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f };
t.SetWidths(widths);
@@ -251,7 +256,6 @@ namespace Volian.Print.Library
}
catch (Exception ex)
{
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:"));
while (ex != null)
{
@@ -265,7 +269,7 @@ namespace Volian.Print.Library
if (document.IsOpen())
{
document.Close();
System.Diagnostics.Process.Start(_FileName);
System.Diagnostics.Process.Start(FileName);
}
}
}
@@ -276,33 +280,40 @@ namespace Volian.Print.Library
iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 1, Color.BLACK);
iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK);
iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK);
iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK);
int cols = 3;
int borders = 0;
int paddingBottom = 6;
PdfPTable t = new PdfPTable(cols);
t.HeaderRows = 1;
t.WidthPercentage = 100;
float[] widths = new float[] { 1f, 1f, 10f };
PdfPTable t = new PdfPTable(cols)
{
HeaderRows = 1,
WidthPercentage = 100
};
float[] widths = new float[] { 1f, 1f, 10f };
t.SetWidths(widths);
Phrase h = new Phrase();
h.Font = f1;
h.Add("Approved Procedures Inconsistencies Report");
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = 1;
t.AddCell(c);
// C2021-013: Include the Procedure set name & date
h = new Phrase();
h.Font = f1;
string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy");
Phrase h = new Phrase
{
Font = f1
};
h.Add("Approved Procedures Inconsistencies Report");
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c);
// C2021-013: Include the Procedure set name & date
h = new Phrase
{
Font = f1
};
string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy");
h.Add(tmp);
c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = 1;
t.AddCell(c);
c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c);
Dictionary<int, string> types = new Dictionary<int, string>();
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
string type = pi.MyDifferences.ROConsistency.MyROChecks.Length > 0 ? "Reference Object Inconsistencies" : "";
if (type != string.Empty && !types.ContainsKey(0))
@@ -314,15 +325,18 @@ namespace Volian.Print.Library
if (type != string.Empty && !types.ContainsKey(2))
types.Add(2, type);
}
// types.Clear();
if (types.Count == 0)
{
h = new Phrase();
h.Font = f2;
h.Add("No Inconsistencies");
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add("No Inconsistencies");
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
}
else
{
@@ -335,7 +349,7 @@ namespace Volian.Print.Library
ROFSTLookup lu = rofst.GetROFSTLookup(dvi);
if (types.ContainsKey(0))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (ROCheck roc in pi.MyDifferences.ROConsistency.MyROChecks)
{
@@ -364,7 +378,7 @@ namespace Volian.Print.Library
//Dictionary<string, List<string>> trs = new Dictionary<string, List<string>>();
if (types.ContainsKey(1))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (TransitionCheck trc in pi.MyDifferences.TransitionConsistency.MyTransitionChecks)
{
@@ -397,7 +411,7 @@ namespace Volian.Print.Library
//Dictionary<string, List<string>> lds = new Dictionary<string, List<string>>();
if (types.ContainsKey(2))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (LibDocCheck ldc in pi.MyDifferences.LibDocConsistency.MyLibDocChecks)
{
@@ -420,28 +434,38 @@ namespace Volian.Print.Library
Color badColor = new Color(System.Drawing.Color.Khaki);
if (types.ContainsKey(0))
{
h = new Phrase();
h.Font = f2;
h.Add(types[0]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[0]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string rotitle in ros.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(rotitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(rotitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string,bool> d in ros[rotitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;
@@ -451,31 +475,40 @@ namespace Volian.Print.Library
}
}
}
//jcb
if (types.ContainsKey(1))
{
h = new Phrase();
h.Font = f2;
h.Add(types[1]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[1]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string trtitle in trs.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(trtitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(trtitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string, bool> d in trs[trtitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;
@@ -488,28 +521,38 @@ namespace Volian.Print.Library
//end jcb
if (types.ContainsKey(2))
{
h = new Phrase();
h.Font = f2;
h.Add(types[2]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[2]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string ldtitle in lds.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(ldtitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(ldtitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string, bool> d in lds[ldtitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;