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
@@ -1395,7 +1395,7 @@ namespace VEPROMS
DoCreatePDF(); // create indivitual pdfs DoCreatePDF(); // create indivitual pdfs
if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath; if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath;
// C2021-063 pass in whether to generate Alarm Point List text when a merge is done // C2021-063 pass in whether to generate Alarm Point List text when a merge is done
if (!_MergedPfd.DoTheMerge(PromsPrinter.MergedLandscapePages,cbxAlmPtTxt.Checked)) return; // merge them together. if (!_MergedPfd.DoTheMerge(cbxAlmPtTxt.Checked)) return; // merge them together.
// if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done // if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done
if (_DocVersionConfig.Print_MergedPdfsViewAfter) if (_DocVersionConfig.Print_MergedPdfsViewAfter)
{ {
+2 -2
View File
@@ -1001,7 +1001,7 @@ namespace VEPROMS
fs.Close(); fs.Close();
System.Diagnostics.Process.Start(fileName); System.Diagnostics.Process.Start(fileName);
} }
catch (Exception ex) catch (Exception)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -1767,7 +1767,7 @@ namespace VEPROMS
} }
else if (args.TypesSelected == "Complete RO Report") else if (args.TypesSelected == "Complete RO Report")
{ {
Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.CompleteROReport, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize); Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize);
myReport.Build(); myReport.Build();
} }
else if (args.TypesSelected == "RO Summary Report") else if (args.TypesSelected == "RO Summary Report")
+4 -34
View File
@@ -1,22 +1,14 @@
using System; using System.Xml;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public class CPSGen public class CPSGen
{ {
private vlnParagraph _MyVlnParagraph; public vlnParagraph MyVlnParagraph { get; set; }
public vlnParagraph MyVlnParagraph
{
get { return _MyVlnParagraph; }
set { _MyVlnParagraph = value; }
}
public CPSGen(vlnParagraph myParagraph) public CPSGen(vlnParagraph myParagraph)
{ {
_MyVlnParagraph = myParagraph; MyVlnParagraph = myParagraph;
} }
public void Generate(string fileName) public void Generate(string fileName)
{ {
@@ -33,7 +25,6 @@ namespace Volian.Print.Library
AddAttribute(xe, "FromType", fromType); AddAttribute(xe, "FromType", fromType);
AddAttribute(xe, "Ordinal", itm.Ordinal); AddAttribute(xe, "Ordinal", itm.Ordinal);
AddAttribute(xe, "ParentID", (itm.ActiveParent as ItemInfo).ItemID); AddAttribute(xe, "ParentID", (itm.ActiveParent as ItemInfo).ItemID);
//AddAttribute(xe, "Xoffset", para.XOffset);
AddAttribute(xe, "ItemID", itm.ItemID); AddAttribute(xe, "ItemID", itm.ItemID);
AddAttribute(xe, "PreviousID", itm.PreviousID); AddAttribute(xe, "PreviousID", itm.PreviousID);
AddAttribute(xe, "ContentID", itm.ContentID); AddAttribute(xe, "ContentID", itm.ContentID);
@@ -45,41 +36,20 @@ namespace Volian.Print.Library
AddAttribute(xe, "FormatID", itm.MyContent.FormatID); AddAttribute(xe, "FormatID", itm.MyContent.FormatID);
AddAttribute(xe, "Config", itm.MyContent.Config); AddAttribute(xe, "Config", itm.MyContent.Config);
AddAttribute(xe, "Rtf", para.Rtf); AddAttribute(xe, "Rtf", para.Rtf);
//AddParts(xe, "PartsAbove", para.PartsAbove);
//AddParts(xe, "PartsLeft", para.PartsLeft);
//AddParts(xe, "PartsRight", para.PartsRight);
//AddParts(xe, "PartsBelow", para.PartsBelow);
AddChildren(level,0, parent, "ChildrenAbove", para.ChildrenAbove); AddChildren(level,0, parent, "ChildrenAbove", para.ChildrenAbove);
AddChildren(level,0, parent, "ChildrenLeft", para.ChildrenLeft); AddChildren(level,0, parent, "ChildrenLeft", para.ChildrenLeft);
AddChildren(level,0, parent, "ChildrenRight", para.ChildrenRight); AddChildren(level,0, parent, "ChildrenRight", para.ChildrenRight);
AddChildren(level,0, parent, "ChildrenBelow", para.ChildrenBelow); AddChildren(level,0, parent, "ChildrenBelow", para.ChildrenBelow);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping fromType and name for Debugging")]
private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children) private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children)
{ {
if (children == null || children.Count == 0) return; if (children == null || children.Count == 0) return;
//XmlElement xchildren = xe.OwnerDocument.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement;
foreach(vlnParagraph child in children) foreach(vlnParagraph child in children)
{ {
//XmlElement xechild = xe.ParentNode.AppendChild(xe.OwnerDocument.CreateElement("Item")) as XmlElement;
Generate(level+1,0,parent,child); Generate(level+1,0,parent,child);
} }
} }
//private void AddParts(XmlElement xe, string name, vlnPrintObjects parts)
//{
// if (parts == null || parts.Count == 0) return;
// XmlElement xpart = xe.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement;
// foreach (vlnPrintObject part in parts)
// {
// XmlElement xechild = xpart.AppendChild(xe.OwnerDocument.CreateElement(part.GetType().Name)) as XmlElement;
// Generate(xechild, part);
// }
//}
//private void Generate(XmlElement xe, vlnPrintObject part)
//{
// AddAttribute(xe, "Xoffset", part.XOffset);
// AddAttribute(xe, "Width", part.Width);
// AddAttribute(xe, "Rtf", part.Rtf);
//}
private void AddAttribute(XmlElement xe, string attr, object val) private void AddAttribute(XmlElement xe, string attr, object val)
{ {
if (val == null) return; if (val == null) return;
+104 -203
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -16,92 +15,53 @@ namespace Volian.Print.Library
class CompleteROReport class CompleteROReport
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Dictionary<string, PdfDestination> _MyErrorBookMarks = new Dictionary<string, PdfDestination>(); readonly Headers Hdrs; // Header stack object.
Headers Hdrs; // Header stack object.
RODataFile RO_df = null; RODataFile RO_df = null;
int curheaderlen; int curheaderlen;
string RODataFileName; readonly string RODataFileName;
iTextSharp.text.Document _pdfReportDoc = null; readonly iTextSharp.text.Document _pdfReportDoc;
PdfPTable datatable = null; 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 public iTextSharp.text.Font F10 { get; set; }
{
get { return _f14; }
set { _f14 = value; }
}
private iTextSharp.text.Font _f10;
public iTextSharp.text.Font F10 public iTextSharp.text.Font F12 { get; set; }
{
get { return _f10; }
set { _f10 = value; }
}
private iTextSharp.text.Font _f12;
public iTextSharp.text.Font F12 public iTextSharp.text.Font F10Bold { get; set; }
{
get { return _f12; }
set { _f12 = value; }
}
private iTextSharp.text.Font _f10Bold;
public iTextSharp.text.Font F10Bold public iTextSharp.text.Font F12Bold { get; set; }
{
get { return _f10Bold; }
set { _f10Bold = value; }
}
private iTextSharp.text.Font _f12Bold;
public iTextSharp.text.Font F12Bold public bool ConvertCaretToDelta { get; set; } = true;
{
get { return _f12Bold; }
set { _f12Bold = value; }
}
private bool _ConvertCaretToDelta = true; public bool IncludeEmptyROFields { get; set; } = false;
public bool ConvertCaretToDelta public int ROFstID { get; set; }
{ private readonly string ReportTitle = "Complete Referenced Objects Report";
get { return _ConvertCaretToDelta; } private readonly PdfWriter _MyPDFWriter;
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 CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields) public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields)
{ {
Hdrs = new Headers(); Hdrs = new Headers();
_pdfReportDoc = document; _pdfReportDoc = document;
RODataFileName = dataFileName; RODataFileName = dataFileName;
_ConvertCaretToDelta = convertCaretToDelta; ConvertCaretToDelta = convertCaretToDelta;
_MyPDFWriter = mypdfwriter; _MyPDFWriter = mypdfwriter;
_IncludeEmptyROFields = includeEmptyROFields; IncludeEmptyROFields = includeEmptyROFields;
} }
public void StartNewDataTable() public void StartNewDataTable()
{ {
datatable = new PdfPTable(1); datatable = new PdfPTable(1)
datatable.TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin; {
datatable.LockedWidth = true; TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin,
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14)); LockedWidth = true
cell.HorizontalAlignment = Element.ALIGN_CENTER; };
cell.BackgroundColor = Color.WHITE; PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14))
cell.BorderColor = Color.WHITE; {
HorizontalAlignment = Element.ALIGN_CENTER,
BackgroundColor = Color.WHITE,
BorderColor = Color.WHITE
};
datatable.AddCell(cell); datatable.AddCell(cell);
datatable.HeaderRows = 3; datatable.HeaderRows = 3;
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
@@ -113,33 +73,17 @@ namespace Volian.Print.Library
PrintReport(); PrintReport();
RO_df.close(); 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>();
{
get { return _MyDocOutline; }
set { _MyDocOutline = value; }
}
public class DocOutline public class DocOutline
{ {
private PdfOutline _MyOutline; public PdfOutline MyOutline { get; set; }
public PdfOutline MyOutline public string MyHeader { get; set; }
{
get { return _MyOutline; }
set { _MyOutline = value; }
}
private string _MyHeader;
public string MyHeader
{
get { return _MyHeader; }
set { _MyHeader = value; }
}
public DocOutline(PdfOutline outline, string header) public DocOutline(PdfOutline outline, string header)
{ {
_MyHeader = header; MyHeader = header;
_MyOutline = outline; MyOutline = outline;
} }
} }
private string ReplaceLineDrawCharsWithUnicode(string text) 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 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) if (ConvertCaretToDelta)
{ {
//char[] ca = instr.ToCharArray(); // for debug
instr = instr.Replace("^", "\u0394"); // delta instr = instr.Replace("^", "\u0394"); // delta
} }
//instr = instr.Replace("\x94", "\u0394"); // delta - the delta symbol is being read in as character x94 //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)); string tstr = (instr.Substring(idx+uidx, m1.Index - uidx));
if (tstr.EndsWith(" ")) if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt); chk = new Chunk(tstr, fnt);
if (underlineChunk) if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); 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)); string tstr = (strChk.Substring(uidx, m1.Index - uidx));
if (tstr.EndsWith(" ")) if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt); chk = new Chunk(tstr, fnt);
if (underlineChunk) if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); 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); string tstr = strChk.Substring(uidx);
if (tstr.EndsWith(" ")) if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt); chk = new Chunk(tstr, fnt);
if (underlineChunk) if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
@@ -276,10 +219,7 @@ namespace Volian.Print.Library
return p; return p;
} }
public void AddText(string txt, Font fnt) public void AddText(string txt, Font fnt) => AddText(txt, fnt, Color.BLACK);
{
AddText(txt, fnt, Color.BLACK);
}
public void AddText(string txt, Font fnt, Color txtcolor) public void AddText(string txt, Font fnt, Color txtcolor)
{ {
@@ -289,10 +229,14 @@ namespace Volian.Print.Library
string[] strlst = txt.Split(delim,StringSplitOptions.None); string[] strlst = txt.Split(delim,StringSplitOptions.None);
foreach (string str in strlst) foreach (string str in strlst)
{ {
Font f = new Font(fnt); Font f = new Font(fnt)
f.Color = txtcolor; {
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f)); Color = txtcolor
cell.BorderColor = Color.WHITE; };
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f))
{
BorderColor = Color.WHITE
};
if (strlst.Length > 1) if (strlst.Length > 1)
cell.PaddingBottom = 6; cell.PaddingBottom = 6;
datatable.AddCell(cell); datatable.AddCell(cell);
@@ -301,10 +245,11 @@ namespace Volian.Print.Library
public void AddImage(string filename) public void AddImage(string filename)
{ {
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(_ROFstID, filename); ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(ROFstID, filename) ?? ROFstInfo.Get(ROFstID).GetROImageByFilename(filename, null);
if (roImage == null) roImage = ROFstInfo.Get(_ROFstID).GetROImageByFilename(filename, null); PdfPCell spaceCell = new PdfPCell
PdfPCell spaceCell = new PdfPCell(); {
spaceCell.BorderColor = Color.WHITE; BorderColor = Color.WHITE
};
datatable.AddCell(spaceCell); datatable.AddCell(spaceCell);
if (roImage != null) if (roImage != null)
{ {
@@ -318,7 +263,7 @@ namespace Volian.Print.Library
it_image = iTextSharp.text.Image.GetInstance(dcnt); it_image = iTextSharp.text.Image.GetInstance(dcnt);
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size)); //iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
} }
catch (Exception ex) catch (Exception)
{ {
try try
{ {
@@ -342,8 +287,10 @@ namespace Volian.Print.Library
} }
} }
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216); it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image); PdfPCell cell = new PdfPCell(it_image)
cell.BorderColor = Color.WHITE; {
BorderColor = Color.WHITE
};
datatable.AddCell(cell); datatable.AddCell(cell);
roImage.Dispose(); roImage.Dispose();
} }
@@ -364,16 +311,20 @@ namespace Volian.Print.Library
if (ConvertCaretToDelta) if (ConvertCaretToDelta)
plotlang = plotlang.Replace("^", "\x394"); // delta plotlang = plotlang.Replace("^", "\x394"); // delta
plotlang = plotlang.Replace("\x7F", "\x394"); //delta plotlang = plotlang.Replace("\x7F", "\x394"); //delta
PdfPCell spaceCell = new PdfPCell(); PdfPCell spaceCell = new PdfPCell
spaceCell.BorderColor = Color.WHITE; {
BorderColor = Color.WHITE
};
datatable.AddCell(spaceCell); datatable.AddCell(spaceCell);
try try
{ {
System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics); System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile); 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); it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image); PdfPCell cell = new PdfPCell(it_image)
cell.BorderColor = Color.WHITE; {
BorderColor = Color.WHITE
};
datatable.AddCell(cell); datatable.AddCell(cell);
} }
catch (Exception e) catch (Exception e)
@@ -386,18 +337,12 @@ namespace Volian.Print.Library
} }
private string processingRO = ""; private string processingRO = "";
private string _MyROID = null;
public string MyROID public string MyROID { get; set; } = null;
{
get { return _MyROID; }
set { _MyROID = value; }
}
public void PrintReport() public void PrintReport()
{ {
bool StopPrinting = false; bool StopPrinting = false;
bool UserTerminate = false;
Int16 iRecType = 0;
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report"); VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
try try
{ {
@@ -405,6 +350,7 @@ namespace Volian.Print.Library
{ {
showStatBar.BarMax = (int)RO_df.GetFileLength(); showStatBar.BarMax = (int)RO_df.GetFileLength();
showStatBar.StatMsg = "Creating Report"; showStatBar.StatMsg = "Creating Report";
short iRecType;
// Loop until either printing is aborted or end of file. // Loop until either printing is aborted or end of file.
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1) while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{ {
@@ -454,7 +400,7 @@ namespace Volian.Print.Library
case 104: // Multi End case 104: // Multi End
break; break;
case 0: // nothing was entered in that field case 0: // nothing was entered in that field
if (_IncludeEmptyROFields) if (IncludeEmptyROFields)
NoInformatEntered(); NoInformatEntered();
break; break;
case 255: case 255:
@@ -466,12 +412,11 @@ namespace Volian.Print.Library
//Console.WriteLine("----------------------------------------------"); //Console.WriteLine("----------------------------------------------");
break; break;
default: // Problem default: // Problem
//Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType);
StopPrinting = true; StopPrinting = true;
UserTerminate = true;
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
break; break;
}; }
;
} }
} }
else else
@@ -502,20 +447,22 @@ namespace Volian.Print.Library
// if there is lenght then we are in the mist of processing an RO // if there is lenght then we are in the mist of processing an RO
string headers = erMsg; string headers = erMsg;
for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++) for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++)
headers += Hdrs.strHdrs[iLoop] + "\n "; headers += $"{Hdrs.strHdrs[iLoop]}\n ";
if (processingRO.Length > 0) if (processingRO.Length > 0)
headers += processingRO; headers += processingRO;
if (erMsg2 != null && erMsg2.Length > 0) if (erMsg2 != null && erMsg2.Length > 0)
headers += "\n" + erMsg2; headers += "\n" + erMsg2;
//MessageBox.Show(headers, erMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (e != null) if (e != null)
_MyLog.Error(headers, e); _MyLog.Error(headers, e);
else else
_MyLog.Error(headers); _MyLog.Error(headers);
#pragma warning disable IDE0059 // Unnecessary assignment of a value - for debugging
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header"); PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
#pragma warning restore IDE0059 // Unnecessary assignment of a value
//DestSample(outl); //DestSample(outl);
} }
//For Debugging/Testing
//private void DestSample(PdfOutline outl) //private void DestSample(PdfOutline outl)
//{ //{
// new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT"); // new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT");
@@ -531,27 +478,20 @@ namespace Volian.Print.Library
public void AddErrorBookmarks() public void AddErrorBookmarks()
{ {
if (_MyErrorOutline == null) return; 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."; 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); MessageBox.Show(emsg, "Errors Found Creating Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
public void Multiple() public void Multiple()
{ {
Int16 typ, i, j, nw = 0; short typ, i, j;
string str, sep; string str, sep;
string buff = ""; string buff = "";
int[] width; int[] width;
LastHeader(); LastHeader();
sep = ""; sep = "";
// nw - number of fields // nw - number of fields
nw = RO_df.ReadInteger16(); short nw = RO_df.ReadInteger16();
// allocate space for widths // allocate space for widths
width = new int[nw]; width = new int[nw];
// loop through and load field widths and names // loop through and load field widths and names
@@ -645,7 +585,7 @@ namespace Volian.Print.Library
//Console.WriteLine("Set Header"); //Console.WriteLine("Set Header");
// Get the number of header records // Get the number of header records
Int16 iNewCnt = RO_df.ReadInteger16(); short iNewCnt = RO_df.ReadInteger16();
//Console.WriteLine("Num Header Records: {0}", iNewCnt); //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 bool _LastWasName = false;//B2016-251 Don't change underscore to underline to Name value
public void PushHeader() public void PushHeader()
{ {
//if (m_pPrinterOut->Row() > 55)
//// m_pPrinterOut->newpage();
//pdfReportDoc.NewPage();
string pTmp = RO_df.ReadText(); string pTmp = RO_df.ReadText();
//Console.WriteLine("PH[{0}]", pTmp); //Console.WriteLine("PH[{0}]", pTmp);
curheaderlen = pTmp.Length; curheaderlen = pTmp.Length;
_LastWasName = (pTmp == "Name");//B2016-251 Don't change underscore to underline to Name value _LastWasName = (pTmp == "Name");//B2016-251 Don't change underscore to underline to Name value
//Hdrs.strHdrs[Hdrs.HdrCnt] = pTmp;
Hdrs.strHdrs.Add(pTmp); Hdrs.strHdrs.Add(pTmp);
//Hdrs.repeatCount[Hdrs.HdrCnt] = 2;
Hdrs.repeatCount.Add(2); Hdrs.repeatCount.Add(2);
Hdrs.HdrCnt++; Hdrs.HdrCnt++;
Hdrs.printedLastHeader = false; Hdrs.printedLastHeader = false;
@@ -704,15 +639,12 @@ namespace Volian.Print.Library
// if the last header was pushed on header list // if the last header was pushed on header list
// print eject the page if the page ran out, and // print eject the page if the page ran out, and
// print the header with "none". // print the header with "none".
//if (m_pPrinterOut->Row() > 55)
// m_pPrinterOut->NewPage();
LastHeader(); LastHeader();
//m_pPrinterOut->PutLine(0, "none"); //m_pPrinterOut->PutLine(0, "none");
//m_pPrinterOut->NewLine(1); //m_pPrinterOut->NewLine(1);
} }
// Remove the header // Remove the header
Hdrs.HdrCnt--; Hdrs.HdrCnt--;
//Hdrs.strHdrs[Hdrs.HdrCnt] = null;
Hdrs.strHdrs.RemoveAt(Hdrs.HdrCnt); Hdrs.strHdrs.RemoveAt(Hdrs.HdrCnt);
Hdrs.repeatCount.RemoveAt(Hdrs.HdrCnt); Hdrs.repeatCount.RemoveAt(Hdrs.HdrCnt);
@@ -722,7 +654,6 @@ namespace Volian.Print.Library
public void RROBegin() public void RROBegin()
{ {
//m_pPrinterOut->NewPage();
//Console.WriteLine("RRO Begin"); //Console.WriteLine("RRO Begin");
//Console.WriteLine("----------------------------------------------"); //Console.WriteLine("----------------------------------------------");
// Start of a new RO, print out the headers // 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]) if (!MyDocOutline.ContainsKey(iLoop) || MyDocOutline[iLoop].MyHeader != Hdrs.strHdrs[iLoop])
{ {
PdfOutline parentOutline = null; PdfOutline parentOutline;
if (iLoop == 0) if (iLoop == 0)
parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline; parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline;
else else
parentOutline = MyDocOutline[iLoop - 1].MyOutline; parentOutline = MyDocOutline[iLoop - 1].MyOutline;
//pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage); AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage);
} }
// Change double underscore to spaces in header text // Change double underscore to spaces in header text
@@ -748,18 +678,11 @@ namespace Volian.Print.Library
{ {
// FITH was acting strange and shifting towards bottom of the page as the number of pages increased // 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); //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); return new PdfDestination(PdfDestination.XYZ, 0, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height, 1.5f);
} }
} }
public PdfDestination MyPdfDestPage public PdfDestination MyPdfDestPage => new PdfDestination(PdfDestination.FITV, 0);
{
get
{
return new PdfDestination(PdfDestination.FITV,0);
}
}
private PdfOutline _MyErrorOutline = null; private PdfOutline _MyErrorOutline = null;
@@ -787,7 +710,6 @@ namespace Volian.Print.Library
return _MyRootOutline; return _MyRootOutline;
} }
} }
private PdfDestination pdfDest = null;
private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest) private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest)
{ {
if (MyDocOutline.ContainsKey(iLoop)) if (MyDocOutline.ContainsKey(iLoop))
@@ -798,7 +720,6 @@ namespace Volian.Print.Library
public void RROEnd() public void RROEnd()
{ {
//m_pPrinterOut->PageEnd();
// Remove any headers that are left over // Remove any headers that are left over
//Console.WriteLine("{0} headers cleaned up.", Hdrs.HdrCnt); //Console.WriteLine("{0} headers cleaned up.", Hdrs.HdrCnt);
//Console.WriteLine("RRO End"); //Console.WriteLine("RRO End");
@@ -843,7 +764,7 @@ namespace Volian.Print.Library
public void Text() public void Text()
{ {
// Get the lenght of the text string and read it in // Get the lenght of the text string and read it in
Int16 iValue = RO_df.ReadInteger16(); short iValue = RO_df.ReadInteger16();
string szStr = ""; string szStr = "";
// B2016-247 If size is zero it is an empty string. // B2016-247 If size is zero it is an empty string.
if (iValue > 0) if (iValue > 0)
@@ -867,11 +788,9 @@ namespace Volian.Print.Library
if (isXYPlot || (iValue + curheaderlen) > 72 || (szStr.IndexOf('\r') != -1)) 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 // than 72 characters or has a carriage return character in it
// then output the text on multiple lines // then output the text on multiple lines
//if (m_pPrinterOut->Row() > 55)
// m_pPrinterOut->newpage();
// the header goes on its own line // the header goes on its own line
cell.AddElement(p); cell.AddElement(p);
@@ -891,10 +810,6 @@ namespace Volian.Print.Library
datatable.AddCell(cell); datatable.AddCell(cell);
//m_pPrinterOut->SetNumberOfNewLines(0); //m_pPrinterOut->SetNumberOfNewLines(0);
//m_pPrinterOut->putline(0, temp); //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("Text");
//Console.WriteLine("Value: {0}", iValue); //Console.WriteLine("Value: {0}", iValue);
@@ -906,8 +821,9 @@ namespace Volian.Print.Library
{ {
// use the key field as the PDF bookbark // use the key field as the PDF bookbark
string szStr = RO_df.ReadText(); string szStr = RO_df.ReadText();
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); #pragma warning disable IDE0059 // Unnecessary assignment of a value - For Debugging
PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
//DestSample(outl); //DestSample(outl);
return szStr; return szStr;
//Console.WriteLine("Key Field"); //Console.WriteLine("Key Field");
@@ -918,6 +834,7 @@ namespace Volian.Print.Library
{ {
// use the key field as the PDF bookbark // use the key field as the PDF bookbark
string szStr = RO_df.ReadText(); string szStr = RO_df.ReadText();
//For Dubugging
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); //PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
//PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); //PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
//DestSample(outl); //DestSample(outl);
@@ -931,8 +848,10 @@ namespace Volian.Print.Library
public void ImageFile() public void ImageFile()
{ {
string fn = RO_df.ReadText(); string fn = RO_df.ReadText();
Int16 ht = RO_df.ReadInteger16(); #pragma warning disable IDE0059 // Unnecessary assignment of a value - for Debugging
Int16 wd = RO_df.ReadInteger16(); 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); //m_pPrinterOut->PrintImage(fn, wd, ht);
//Console.WriteLine("ImageFile"); //Console.WriteLine("ImageFile");
@@ -946,10 +865,9 @@ namespace Volian.Print.Library
public void XYPlot() public void XYPlot()
{ {
// Get the lenght of the text string and read it in // 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 szStr = RO_df.ReadText(iValue);
string temp = szStr; Chunk chk = LastHeader();
Chunk chk = LastHeader(); // = new Chunk(m.Value, fnt);
Phrase p = new Phrase(); Phrase p = new Phrase();
PdfPCell cell = new PdfPCell(); PdfPCell cell = new PdfPCell();
p.Add(chk); // add the header chunk p.Add(chk); // add the header chunk
@@ -997,7 +915,6 @@ namespace Volian.Print.Library
chk = new Chunk(hdrtxt, F10Bold); chk = new Chunk(hdrtxt, F10Bold);
Hdrs.printedLastHeader = true; Hdrs.printedLastHeader = true;
return chk; return chk;
//m_pPrinterOut->LastHeader();
} }
}// end CompSumROReport }// end CompSumROReport
@@ -1005,9 +922,7 @@ namespace Volian.Print.Library
public class Headers public class Headers
{ {
//public string[] strHdrs;
public List<string> strHdrs; public List<string> strHdrs;
// public int[] repeatCount;
public int HdrCnt; public int HdrCnt;
public List<int> repeatCount; public List<int> repeatCount;
public bool printedLastHeader; public bool printedLastHeader;
@@ -1022,8 +937,8 @@ namespace Volian.Print.Library
public class RODataFile public class RODataFile
{ {
FileStream fs = null; readonly FileStream fs = null;
BinaryReader br = null; readonly BinaryReader br = null;
public RODataFile(string fname) public RODataFile(string fname)
{ {
fs = new FileStream(fname,FileMode.Open); fs = new FileStream(fname,FileMode.Open);
@@ -1034,15 +949,9 @@ namespace Volian.Print.Library
br.Close(); br.Close();
fs.Close(); fs.Close();
} }
public long GetFileLength() public long GetFileLength() => fs.Length;
{ public long GetFilePointerPosition() => fs.Position;
return fs.Length; // Read an integer value from the data file
}
public long GetFilePointerPosition()
{
return fs.Position;
}
// Read an integer value from the data file
public Int16 ReadInteger16() public Int16 ReadInteger16()
{ {
try try
@@ -1055,18 +964,15 @@ namespace Volian.Print.Library
return -1; return -1;
} }
} }
// Read a text string from the data file and returns it. // Read a text string from the data file and returns it.
// The calling program is responsible for free it // The calling program is responsible for free it
// with the "delete" operator. // with the "delete" operator.
public string ReadText() public string ReadText() => ReadText(-1);
{
return ReadText(-1);
}
public string ReadText(Int16 i16CharCount) public string ReadText(Int16 i16CharCount)
{ {
Int16 i16DataSize; short i16DataSize;
if (i16CharCount == -1) if (i16CharCount == -1)
i16DataSize = ReadInteger16(); i16DataSize = ReadInteger16();
else else
@@ -1082,15 +988,14 @@ namespace Volian.Print.Library
for (int i = 0; i < i16DataSize; i++) for (int i = 0; i < i16DataSize; i++)
str += Convert.ToChar(charbuff[i]).ToString(); str += Convert.ToChar(charbuff[i]).ToString();
return (str); 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 // Search through the file to find the next record
public long NextRecord() public long NextRecord()
{ {
Int16 iType; short iType;
Int16 RECORD_START = 255; short RECORD_START = 255;
// While not the next record and not end of file get the next meta item // While not the next record and not end of file get the next meta item
while ((iType = ReadInteger16()) != RECORD_START && iType != -1) while ((iType = ReadInteger16()) != RECORD_START && iType != -1)
{ {
@@ -1101,9 +1006,8 @@ namespace Volian.Print.Library
// Get the next meta item and discard the data // Get the next meta item and discard the data
public long NextItem() public long NextItem()
{ {
string pTmp; short iRecType = ReadInteger16();
Int16 iRecType = ReadInteger16(); short iNewCnt;
Int16 iNewCnt;
int iLoop; int iLoop;
switch (iRecType) switch (iRecType)
{ {
@@ -1112,8 +1016,7 @@ namespace Volian.Print.Library
for (iLoop = 0; iLoop < iNewCnt; iLoop++) for (iLoop = 0; iLoop < iNewCnt; iLoop++)
{ {
ReadInteger16(); ReadInteger16();
pTmp = ReadText(); _ = ReadText();
//delete pTmp;
} }
break; break;
case 2: // Push Header case 2: // Push Header
@@ -1121,8 +1024,7 @@ namespace Volian.Print.Library
case 7: // Key Field case 7: // Key Field
case 100: // Text Field case 100: // Text Field
case 101: // Plot Field case 101: // Plot Field
pTmp = ReadText(); _ = ReadText();
//delete pTmp;
break; break;
case 3: // Pop Header case 3: // Pop Header
case 4: // RRO Begin case 4: // RRO Begin
@@ -1133,8 +1035,7 @@ namespace Volian.Print.Library
// Do nothing // Do nothing
break; break;
case 102: // Image Field case 102: // Image Field
pTmp = ReadText(); _ = ReadText();
//delete pTmp;
ReadInteger16(); ReadInteger16();
ReadInteger16(); ReadInteger16();
break; break;
+15 -37
View File
@@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Drawing;
using LBWordLibrary; using LBWordLibrary;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -10,12 +8,12 @@ namespace Volian.Print.Library
{ {
public class ContinuousActionSummary : IDisposable public class ContinuousActionSummary : IDisposable
{ {
private LBApplicationClass _WordApp; private readonly LBApplicationClass _WordApp;
private LBDocumentClass _WordDoc; private readonly LBDocumentClass _WordDoc;
private LBSelection _WordSel; private readonly LBSelection _WordSel;
private LBTable _WordTbl; private LBTable _WordTbl;
private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
private VE_Font _pkFont; private readonly VE_Font _pkFont;
public ContinuousActionSummary() public ContinuousActionSummary()
{ {
_WordApp = new LBApplicationClass(); _WordApp = new LBApplicationClass();
@@ -41,7 +39,6 @@ namespace Volian.Print.Library
_WordApp = new LBApplicationClass(); _WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add(); _WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection; _WordSel = _WordApp.Selection;
//_WordApp.Visible = true;
_pkFont = pkFont; _pkFont = pkFont;
AddTable(); AddTable();
AddHeader(doingTimeCriticalSummary); // F2022-024 pass flag when creating a Time Critical Action Summary report AddHeader(doingTimeCriticalSummary); // F2022-024 pass flag when creating a Time Critical Action Summary report
@@ -72,11 +69,11 @@ namespace Volian.Print.Library
if (txtPageNum == "") txtPageNum = (pghC.MyParagraph.MyItemInfo.PageNumber + 1).ToString(); if (txtPageNum == "") txtPageNum = (pghC.MyParagraph.MyItemInfo.PageNumber + 1).ToString();
AddContinuousAction(NoteCautionTab, GetContActStepText(pghC.MyParagraph.MyItemInfo), doneStr, txtPageNum, 0, 0); AddContinuousAction(NoteCautionTab, GetContActStepText(pghC.MyParagraph.MyItemInfo), doneStr, txtPageNum, 0, 0);
} }
string stpTab = pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + " "; // this is either the High Level step tab or the sub-step tab string stpTab = $"{pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim()} "; // this is either the High Level step tab or the sub-step tab
float preTabLen = 0; float preTabLen = 0;
if (pgh.MyParagraph.MyItemInfo.IsNote || pgh.MyParagraph.MyItemInfo.IsCaution) // only the caution and/or note is on the CAS - high level step not selected if (pgh.MyParagraph.MyItemInfo.IsNote || pgh.MyParagraph.MyItemInfo.IsCaution) // only the caution and/or note is on the CAS - high level step not selected
{ {
stpTab = string.Format("{0} ", hlsii.MyTab.Text.Trim()) + " " + stpTab; stpTab = $"{hlsii.MyTab.Text.Trim()} {stpTab}";
} }
else if (!pgh.MyParagraph.MyItemInfo.IsHigh) // if the high level step was not included, adjust the tab for a sub-step/RNO else if (!pgh.MyParagraph.MyItemInfo.IsHigh) // if the high level step was not included, adjust the tab for a sub-step/RNO
{ {
@@ -98,13 +95,13 @@ namespace Volian.Print.Library
prevItemInfo = prevItemInfo.MyParent; prevItemInfo = prevItemInfo.MyParent;
} }
if (_FirstLine) // the first of a CAS on the report include the High Level Step tab if (_FirstLine) // the first of a CAS on the report include the High Level Step tab
sbTabPre.Insert(0, (hlsii != null) ? hlsii.MyTab.Text.Trim() + " " : ""); sbTabPre.Insert(0, (hlsii != null) ? $"{hlsii.MyTab.Text.Trim()} " : "");
tabPre = sbTabPre.ToString(); tabPre = sbTabPre.ToString();
if (!_FirstLine) // if not the first line we indent the size of high level step tab if (!_FirstLine) // if not the first line we indent the size of high level step tab
preTabLen = GetTextWidth(hlsii.MyTab.Text.Trim() + " ") / 72f; preTabLen = GetTextWidth($"{hlsii.MyTab.Text.Trim()} ") / 72f;
if (pgh.MyParagraph.MyItemInfo.IsInRNO) if (pgh.MyParagraph.MyItemInfo.IsInRNO)
{ {
stpTab = stpTab.TrimEnd() + "[R] "; stpTab = $"{stpTab.TrimEnd()}[R] ";
} }
stpTab = tabPre + stpTab; stpTab = tabPre + stpTab;
} }
@@ -135,7 +132,7 @@ namespace Volian.Print.Library
string stpTab = cpgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + (cpgh.MyParagraph.MyItemInfo.IsInRNO ? "[R] ": " "); string stpTab = cpgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + (cpgh.MyParagraph.MyItemInfo.IsInRNO ? "[R] ": " ");
if (cpgh.MyParagraph.MyItemInfo.IsNote || cpgh.MyParagraph.MyItemInfo.IsCaution) if (cpgh.MyParagraph.MyItemInfo.IsNote || cpgh.MyParagraph.MyItemInfo.IsCaution)
{ {
stpTab = string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim()) + " " + stpTab; stpTab = $"{string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim())} {stpTab}";
} }
ItemInfo prevItmInfo = cpgh.MyParagraph.MyItemInfo.MyParent; ItemInfo prevItmInfo = cpgh.MyParagraph.MyItemInfo.MyParent;
// F2026-001 the while loop below will add the sub-step's parent tab if applicable // F2026-001 the while loop below will add the sub-step's parent tab if applicable
@@ -154,17 +151,7 @@ namespace Volian.Print.Library
} }
} }
private string GetContActStepText(ItemInfo myItemInfo) private string GetContActStepText(ItemInfo myItemInfo) => myItemInfo.FormattedDisplayText;
{
//string conActSumText = "";
//StepConfig sc = myItemInfo.MyConfig as StepConfig;
//if (sc != null && sc.Step_AlternateContActSumText != null)
// conActSumText = sc.Step_AlternateContActSumText;
//if (conActSumText == "")
// conActSumText = myItemInfo.FormattedDisplayText;
//return conActSumText;
return myItemInfo.FormattedDisplayText;
}
private void AddNotesOrCautions(pkParagraph pgh, int level) private void AddNotesOrCautions(pkParagraph pgh, int level)
{ {
@@ -305,7 +292,7 @@ namespace Volian.Print.Library
} }
_FirstLine = false; _FirstLine = false;
} }
static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
private void WriteRTF(string text) private void WriteRTF(string text)
{ {
Match m = rgx.Match(text); Match m = rgx.Match(text);
@@ -363,17 +350,8 @@ namespace Volian.Print.Library
_WordSel.ParagraphFormat.Alignment = hAlign; _WordSel.ParagraphFormat.Alignment = hAlign;
_WordSel.Cells.VerticalAlignment = vAlign; _WordSel.Cells.VerticalAlignment = vAlign;
} }
private void Advance(int count) private void Advance(int count) => _WordSel.MoveRight(LBWdUnits.wdCell, count, false);
{ private void Advance() => Advance(1);
_WordSel.MoveRight(LBWdUnits.wdCell, count, false); public void Dispose() => _WordApp.Quit(false);
}
private void Advance()
{
Advance(1);
}
public void Dispose()
{
_WordApp.Quit(false);
}
} }
} }
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not modifying Naming Styles")]
+82 -515
View File
@@ -2,12 +2,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using C1.Win.C1FlexGrid; using C1.Win.C1FlexGrid;
using System.IO;
using Itenso.Rtf; using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support; using Itenso.Rtf.Support;
using Volian.Print.Library;
using Volian.Controls.Library; using Volian.Controls.Library;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
@@ -19,137 +15,35 @@ namespace Volian.Print.Library
#region Settings // RHM20150429 - Table Scrunch #region Settings // RHM20150429 - Table Scrunch
public partial class vlnTable public partial class vlnTable
{ {
private string _DebugInfo = null; // RHM20150429 - Table Scrunch public string DebugInfo { get; set; } = null;
public string DebugInfo public int ItemID { get; set; } = 0;
{ public bool ShowDetails { get; set; } = false;
get { return _DebugInfo; } public bool IsTooBig { get; set; } = false;
set { _DebugInfo = value; }
}
private int _ItemID = 0;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private bool _ShowDetails = false;
public bool ShowDetails
{
get { return _ShowDetails; }
set { _ShowDetails = value; }
}
private bool _IsTooBig = false;
public bool IsTooBig
{
get { return _IsTooBig; }
set { _IsTooBig = value; }
}
}
public partial class vlnCells
{
private static float YAdjust_HContent = 4; // 4
private float YAdjust_SpacingAfter
{
get
{
return 8-8*MyTable.Adjustment;//0; // 8
}
}
} }
public partial class vlnCell public partial class vlnCell
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
public bool ShowDetails public bool ShowDetails => MyTable.ShowDetails;
{ get { return MyTable.ShowDetails; } } private static readonly float YAdjust_h = 0;
private static float YAdjust_h = 0; // 0
private float YAdjust_TextLocation
{
get
{
return 4 - 4 * MyTable.Adjustment; ;//0; // 4
} }
}
}
//public partial class vlnTable
//{
// private static float YAdjust_RowTop = 0;//8; // 0
//}
//public partial class vlnCells
//{
// private static float YAdjust_HContent = 4; // 4
// private static float YAdjust_SpacingAfter = 8;//0; // 8
//}
//public partial class vlnCell
//{
// private static float YAdjust_h = 0; // 0
// private static float YAdjust_TextLocation = 4;//0; // 4
//}
#endregion #endregion
public partial class vlnTable public partial class vlnTable
{ {
#region Properties #region Properties
// HContents: For each row, contains the largest height for all columns in that row. // HContents: For each row, contains the largest height for all columns in that row.
// Merged cells are accounted for. This is done in vlnCells:SetupCells // Merged cells are accounted for. This is done in vlnCells:SetupCells
private float[] _HContents;// RHM20150525 - Table Scrunch public float[] HContents { get; set; }
public float[] HContents public float[] RowTop { get; set; }
{ public float[] ColLeft { get; set; }
get { return _HContents; } public VlnFlexGrid MyFlexGrid { get; set; }
set { _HContents = value; } public VlnBorders MyBorders { get; set; }
} public VlnGridCellShading MyShading { get; set; }
private float[] _RowTop; public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; }
public float[] RowTop public vlnCells MyCells { get; set; }
{ public float Height => RowTop[RowTop.Length - 1];
get { return _RowTop; } public float Width => ColLeft[ColLeft.Length - 1];
set { _RowTop = value; }
}
private float[] _ColLeft;
public float[] ColLeft
{
get { return _ColLeft; }
set { _ColLeft = value; }
}
private VlnFlexGrid _MyFlexGrid;
public VlnFlexGrid MyFlexGrid
{
get { return _MyFlexGrid; }
set { _MyFlexGrid = value; }
}
private VlnBorders _MyBorders;
public VlnBorders MyBorders
{
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
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
private vlnCells _MyCells;
public vlnCells MyCells
{
get { return _MyCells; }
set { _MyCells = value; }
}
public float Height
{ get
{
return RowTop[RowTop.Length - 1];
} }
public float Width
{ get
{
return ColLeft[ColLeft.Length - 1];
} }
private static float _XOffset = -1; // This moves the borders with respect to the text private static float _XOffset = -1; // This moves the borders with respect to the text
public static float XOffset public static float XOffset
@@ -186,7 +80,7 @@ namespace Volian.Print.Library
get { return (LineThicknessForThick - LineThicknessForDouble) / 2; }//LineThicknessForThick - 2 * LineThicknessForDouble; } get { return (LineThicknessForThick - LineThicknessForDouble) / 2; }//LineThicknessForThick - 2 * LineThicknessForDouble; }
} }
private float _TotalContentHeight = 0;// RHM20150525 - Table Scrunc private float _TotalContentHeight = 0;// RHM20150525 - Table Scrunc
// TotalContentHeight - height of just the content of all rows in the table.
public float TotalContentHeight public float TotalContentHeight
{ {
get get
@@ -199,20 +93,18 @@ namespace Volian.Print.Library
return _TotalContentHeight; return _TotalContentHeight;
} }
} }
public float SpaceAvailable// RHM20150525 - Table Scrunc
{ // RHM20150525 - Table Scrunc
// SpaceAvailable is the amount of white space there is to work with. It uses the bottom location // SpaceAvailable is the amount of white space there is to work with. It uses the bottom location
// of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight // of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight
// includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines) // includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines)
get { return TotalContentHeight ==0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight; } public float SpaceAvailable => TotalContentHeight == 0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight;
}
public float LeadingSpaceAvailable// B2018-085 - Table Scrunch Fix: // B2018-085 - Table Scrunch Fix:
{
// LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight. // LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight.
// 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading. // 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading.
// 1.5/13.5 is amount of space used by leading. // 1.5/13.5 is amount of space used by leading.
get { return TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F/13.5F; } public float LeadingSpaceAvailable => TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F / 13.5F;
}
// TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to // TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to
// (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit // (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit
private float _TooBig;// RHM20150525 - Table Scrunc private float _TooBig;// RHM20150525 - Table Scrunc
@@ -222,6 +114,7 @@ namespace Volian.Print.Library
set set
{ {
_TooBig = value; _TooBig = value;
//Debugging
//_Adjustment = Math.Min(1F, (_TooBig / (RowTop.Length - 1)) / 12); //_Adjustment = Math.Min(1F, (_TooBig / (RowTop.Length - 1)) / 12);
//if (ShowDetails) Console.WriteLine("TooBig\t{0}\t{1}", value, _Adjustment); //if (ShowDetails) Console.WriteLine("TooBig\t{0}\t{1}", value, _Adjustment);
//if(ShowDetails) Console.WriteLine("Before RowTop={0}", RowTop[RowTop.Length-1] ); //if(ShowDetails) Console.WriteLine("Before RowTop={0}", RowTop[RowTop.Length-1] );
@@ -252,20 +145,9 @@ namespace Volian.Print.Library
//if(ShowDetails) Console.WriteLine("After RowTop={0}", RowTop[RowTop.Length-1] ); //if(ShowDetails) Console.WriteLine("After RowTop={0}", RowTop[RowTop.Length-1] );
} }
} }
private float _Adjustment = 0;// RHM20150525 - Table Scrunc
public float Adjustment public float Adjustment { get; set; } = 0;
{ public float YAdjust_RowTop => Adjustment * 12;
get { return _Adjustment; }
set { _Adjustment = value; }
}
//private float _YAdjust_RowTop = 0;//8; // 0
public float YAdjust_RowTop
{
get
{
return _Adjustment * 12;
}
}
private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc
{ {
VlnSvgPageHelper myPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; VlnSvgPageHelper myPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
@@ -290,7 +172,7 @@ namespace Volian.Print.Library
cb.LineTo(x, y); cb.LineTo(x, y);
cb.Stroke(); cb.Stroke();
} }
i = 0;
cb.Stroke(); cb.Stroke();
cb.RestoreState(); cb.RestoreState();
cb.EndLayer(); cb.EndLayer();
@@ -321,13 +203,8 @@ namespace Volian.Print.Library
myItemInfo.StepLevel, myItemInfo.ShortPath, Width, XOffset, YOffset); myItemInfo.StepLevel, myItemInfo.ShortPath, Width, XOffset, YOffset);
} }
#endregion #endregion
private string _Path;
public string Path public string Path { get; set; }
{
get { return _Path; }
set { _Path = value; }
}
#region Constructors #region Constructors
public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
@@ -374,7 +251,7 @@ public string Path
string myLPI = myPageHelper.YMultiplier == 1.0F ? ",6LPI" : ",7LPI"; string myLPI = myPageHelper.YMultiplier == 1.0F ? ",6LPI" : ",7LPI";
Rtf2Pdf.DrawPdfDebug(myColumnText.Canvas, left-2, top+1, left + Width, top-myPageHelper.YMultiplier *(Height+1), Rtf2Pdf.DrawPdfDebug(myColumnText.Canvas, left-2, top+1, left + Width, top-myPageHelper.YMultiplier *(Height+1),
DebugInfo+", Height= " + (myPageHelper.YMultiplier * Height).ToString() + myLPI, 0); DebugInfo+", Height= " + (myPageHelper.YMultiplier * Height).ToString() + myLPI, 0);
PdfLayer textLayer = myPageHelper == null ? null : myPageHelper.TextLayer; // RHM20150429 - Table Scrunch PdfLayer textLayer = myPageHelper?.TextLayer; // RHM20150429 - Table Scrunch
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
myPageHelper.AddGap(top, top - Height, left, left + Width); myPageHelper.AddGap(top, top - Height, left, left + Width);
MyCells.ToPdf(myColumnText, left, top); MyCells.ToPdf(myColumnText, left, top);
@@ -383,6 +260,7 @@ public string Path
ShowRowTops("ToPDF2"); ShowRowTops("ToPDF2");
if (ShowDetails) Console.WriteLine("^^^^^^ToPdf============{0}===============", ItemID); if (ShowDetails) Console.WriteLine("^^^^^^ToPdf============{0}===============", ItemID);
} }
//For Debugging
private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
{ {
PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4); PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4);
@@ -396,26 +274,12 @@ public string Path
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Properties #region Properties
private VlnFlexGrid _MyFlexGrid; public VlnFlexGrid MyFlexGrid { get; set; }
public VlnFlexGrid MyFlexGrid public vlnTable MyTable { get; set; }
{
get { return _MyFlexGrid; }
set { _MyFlexGrid = value; }
}
private vlnTable _MyTable;
public vlnTable MyTable
{
get { return _MyTable; }
set { _MyTable = value; }
}
public bool ShowDetails// RHM20150525 - Table Scrunc public bool ShowDetails// RHM20150525 - Table Scrunc
{ get { return MyTable.ShowDetails; }} { get { return MyTable.ShowDetails; }}
private iTextSharp.text.pdf.PdfContentByte _MyContentByte;
public iTextSharp.text.pdf.PdfContentByte MyContentByte public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; }
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
#endregion #endregion
#region Constructors #region Constructors
public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
@@ -424,26 +288,11 @@ public string Path
MyFlexGrid = myFlexGrid; MyFlexGrid = myFlexGrid;
MyContentByte = myContentByte; MyContentByte = myContentByte;
SetupCells(); SetupCells();
foreach(vlnCell cell in this)
{
myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading
myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString()); myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString());
GridLinePattern glp = cell.AboveLeftSide;
glp = cell.AboveRightSide;
glp = cell.BelowLeftSide;
glp = cell.BelowRightSide;
glp = cell.RightOfBottomSide;
glp = cell.RightOfTopSide;
object ta = cell.TextAlign;
}
} }
#endregion #endregion
private float _MyLeading = 13.5F; // B2018-085 AEP and APP worked with 13.5 public float MyLeading { get; set; } = 13.5F;
public float MyLeading
{
get { return _MyLeading; }
set { _MyLeading = value; }
}
#region Private Methods #region Private Methods
private void SetupCells() private void SetupCells()
{ {
@@ -527,7 +376,7 @@ public string Path
myColumnText1.AddElement(myPara); myColumnText1.AddElement(myPara);
float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added
int status = myColumnText1.Go(true); // 'puts out' text for info only _ = myColumnText1.Go(true); // 'puts out' text for info only
float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this
float hContent = 4 + posBefore - posAfter; float hContent = 4 + posBefore - posAfter;
@@ -566,6 +415,7 @@ public string Path
} }
} }
} }
//For Debugging:
// This summarizes the Content heights per row // This summarizes the Content heights per row
//int i=0; //int i=0;
//foreach (float h in MyTable.HContents) //foreach (float h in MyTable.HContents)
@@ -580,41 +430,6 @@ public string Path
return total; return total;
} }
// B2017-105 if a symbol character was set to a bigger font size, then the positioning of the larger symbol character was printing too high on the line
// found with Wolf Creek use of the empty box symbol
//private float BiggestFontSize(Paragraph myPara)
//{
// float fontSize = 12;
// foreach (Chunk ck in myPara.Chunks)
// {
// fontSize = Math.Max(fontSize, ck.Font.Size);
// if (ck.Font.Size > 12)
// {
// ck.SetTextRise(-2f);
// //_MyLog.WarnFormat("set text rise");
// }
// }
// return fontSize;
//}
// B2017-233, B2017-234 needed to get the smallest font size to help decide if a vertical adjustment of the text is needed in a table cell
//private float SmallestFontSize(Paragraph myPara)
//{
// float fontSize = 30;
// foreach (Chunk ck in myPara.Chunks)
// {
// fontSize = Math.Min(fontSize, ck.Font.Size);
// }
// return fontSize;
//}
//private void ShowChunks(System.Collections.ArrayList chunks) // RHM20150429 - Table Scrunch
//{
// StringBuilder sb = new StringBuilder();
// foreach (Chunk chk in chunks)
// {
// sb.Append(BuildChunks(chk.Content));
// }
// //if (ShowDetails) Console.WriteLine("Chunks = '{0}'", sb.ToString());
//}
private string BuildChunks(string str) private string BuildChunks(string str)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -625,32 +440,14 @@ public string Path
else else
sb.Append(c); sb.Append(c);
} }
return "{" + sb.ToString() + "}"; return $"{{{sb}}}";
} }
private void TrimNewlines(Paragraph myPara) private void TrimNewlines(Paragraph myPara)
{ {
while (myPara.Count > 0 && ParaEndsWithNewLine(myPara)) while (myPara.Count > 0 && ParaEndsWithNewLine(myPara))
myPara.RemoveAt(myPara.Count - 1); myPara.RemoveAt(myPara.Count - 1);
} }
private bool ParaEndsWithNewLine(Paragraph myPara) private bool ParaEndsWithNewLine(Paragraph myPara) => myPara[myPara.Count - 1] is Chunk chk && chk.Content == "\n";
{
Chunk chk = myPara[myPara.Count - 1] as Chunk;
if (chk == null) return false;
if (chk.Content == "\n") return true;
return false;
}
public class VlnSplitCharacter : ISplitCharacter
{
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
{
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
internal static void FixHyphens(Paragraph myPara, vlnTable myTable) internal static void FixHyphens(Paragraph myPara, vlnTable myTable)
{ {
// Find chunk with hardhyphen // Find chunk with hardhyphen
@@ -658,10 +455,9 @@ public string Path
// If a hard hyphen is found, the remove it and add a dash (keyboard minus sign) to the beginning // If a hard hyphen is found, the remove it and add a dash (keyboard minus sign) to the beginning
// of the text that follows it. // of the text that follows it.
int hype=-1; int hype=-1;
Font fnt = null;
while ((hype = GetHyphen(myPara)) > -1) while ((hype = GetHyphen(myPara)) > -1)
{ {
fnt = null; Font fnt = null;
if (hype > 0) if (hype > 0)
{ {
Chunk chk1 = (Chunk)myPara[hype - 1]; Chunk chk1 = (Chunk)myPara[hype - 1];
@@ -755,10 +551,9 @@ public string Path
// If a backslash symbold is found, the remove it and add a backslash (keyboard char) to the beginning // If a backslash symbold is found, the remove it and add a backslash (keyboard char) to the beginning
// of the text that follows it. // of the text that follows it.
int bckSlsh = -1; int bckSlsh = -1;
Font fnt = null;
while ((bckSlsh = GetBackslash(myPara)) > -1) while ((bckSlsh = GetBackslash(myPara)) > -1)
{ {
fnt = null; Font fnt = null;
if (bckSlsh > 0) if (bckSlsh > 0)
{ {
Chunk chk1 = (Chunk)myPara[bckSlsh - 1]; Chunk chk1 = (Chunk)myPara[bckSlsh - 1];
@@ -850,15 +645,9 @@ public string Path
// This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character // This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character
// If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print // If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print
// but the text in that table cell will not be indented. - jsj 10/10/2014 // but the text in that table cell will not be indented. - jsj 10/10/2014
// add the symbol font and then surround the indent.
//IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 ")); //IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
IRtfDocument rtfDoc2 = null; IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
//if (rtf.Contains(@"\f1\fnil\fcharset0 "))
// rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
//else
//{
// first add the symbol font and then surround the indent as above.
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
//}
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2); Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert(); iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
@@ -883,7 +672,7 @@ public string Path
return chkW; return chkW;
} }
private static StepRTB _StatRTB = new StepRTB(); private static readonly StepRTB _StatRTB = new StepRTB();
private string PreProcessRTF(float w, string str) private string PreProcessRTF(float w, string str)
{ {
_StatRTB.Text = string.Empty; _StatRTB.Text = string.Empty;
@@ -912,25 +701,7 @@ public string Path
_StatRTB.Text = str; _StatRTB.Text = str;
_StatRTB.SelectAll(); _StatRTB.SelectAll();
_StatRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black); _StatRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
str = _StatRTB.Rtf; return _StatRTB.Rtf;
// RHM 20180607 The following lines calculated line spacing but it did not give consistent values
//System.Drawing.Point location0 = _StatRTB.GetPositionFromCharIndex(0);
//int ii = 1;
//System.Drawing.Point locnext = location0;
//while (ii < 1000 && (locnext = _StatRTB.GetPositionFromCharIndex(ii)).Y == location0.Y)
// ii++;
//if (ii < 1000)
//{
// myLeading = (locnext.Y - location0.Y) * 72.0F / 96.0F;
// Console.WriteLine("{0} - {1}", _StatRTB.Font, myLeading);
//}
//else
// myLeading = 12.0F;
// myLeading = 13.5F; // RHM 20180607 This worked for AEP
// RHM 20180607 The following did not work
//RTBAPI.ParaFormatTwo pft = RTBAPI.GetParaFormat(_StatRTB);
//myLeading = Math.Max(12.0F, pft.dyLineSpacing);
return str;
} }
private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont,int r, int c) private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont,int r, int c)
{ {
@@ -940,10 +711,11 @@ public string Path
rtf = rtf.Replace(@"\_", "-").Replace(@"\u8209?", "-"); rtf = rtf.Replace(@"\_", "-").Replace(@"\u8209?", "-");
rtf = FixRTFToPrint(rtf, r, c); rtf = FixRTFToPrint(rtf, r, c);
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc)
rtf2IText.DefaultFont = mySymFont; {
DefaultFont = mySymFont
};
iTextSharp.text.Paragraph para = rtf2IText.Convert(); iTextSharp.text.Paragraph para = rtf2IText.Convert();
//para.SetLeading(MyLeading , 0);// RHM 20180607 Not Needed - performed in SetupCells
return para; return para;
} }
// The text font used in FixRTFToPrint for grid // The text font used in FixRTFToPrint for grid
@@ -1011,7 +783,6 @@ public string Path
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style);
rtb.SelectionFont = VE_Font.GetWinSysFont(DefaultFont, fnt.Style); rtb.SelectionFont = VE_Font.GetWinSysFont(DefaultFont, fnt.Style);
changed = true; changed = true;
} }
@@ -1027,8 +798,7 @@ public string Path
{ {
//use bolding underline italics from local font //use bolding underline italics from local font
System.Drawing.Font fnt = rtb.SelectionFont; System.Drawing.Font fnt = rtb.SelectionFont;
//System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); System.Drawing.Font fntw = VE_Font.GetWinSysFont(rc.Family ?? fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
System.Drawing.Font fntw = VE_Font.GetWinSysFont((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
rtb.SelectionFont = fntw; rtb.SelectionFont = fntw;
if (rc.Replace != null) if (rc.Replace != null)
{ {
@@ -1047,7 +817,6 @@ public string Path
} }
return rtf; return rtf;
} }
private static float _SixLinesPerInch = 12; // twips
#endregion #endregion
#region Public Methods #region Public Methods
// C2021-005 Get the largest font size being used. // C2021-005 Get the largest font size being used.
@@ -1117,56 +886,16 @@ public string Path
public partial class vlnCell // RHM20150429 - Table Scrunch public partial class vlnCell // RHM20150429 - Table Scrunch
{ {
#region Properties #region Properties
private vlnTable _MyTable; public vlnTable MyTable { get; set; }
public vlnTable MyTable public VlnBorders MyBorders => MyTable.MyBorders;
{
get { return _MyTable; } public int r1 { get; set; }
set { _MyTable = value; } public int c1 { get; set; }
} public int r2 { get; set; }
public VlnBorders MyBorders public int c2 { get; set; }
{ public iTextSharp.text.Paragraph MyPara { get; set; }
get { return _MyTable.MyBorders; } public float HContent { get; set; }
} public VlnGridCellShading MyShading => MyTable.MyShading;
private int _r1;
public int r1
{
get { return _r1; }
set { _r1 = value; }
}
private int _c1;
public int c1
{
get { return _c1; }
set { _c1 = value; }
}
private int _r2;
public int r2
{
get { return _r2; }
set { _r2 = value; }
}
private int _c2;
public int c2
{
get { return _c2; }
set { _c2 = value; }
}
private iTextSharp.text.Paragraph _MyPara;
public iTextSharp.text.Paragraph MyPara
{
get { return _MyPara; }
set { _MyPara = value; }
}
private float _HContent;
public float HContent
{
get { return _HContent; }
set { _HContent = value; }
}
public VlnGridCellShading MyShading
{
get { return _MyTable.MyShading; }
}
#endregion #endregion
#region Line Pattern Diagram #region Line Pattern Diagram
/* /*
@@ -1410,22 +1139,22 @@ public string Path
} }
#endregion #endregion
#region Static Properties #region Static Properties
private static float XOffset { get { return vlnTable.XOffset; } } private static float XOffset => vlnTable.XOffset;
private static float YOffset { get { return vlnTable.YOffset; } } private static float YOffset => vlnTable.YOffset;
private static float LineThicknessForThin { get { return vlnTable.LineThicknessForThin; } } private static float LineThicknessForThin => vlnTable.LineThicknessForThin;
private static float LineThicknessForThick { get { return vlnTable.LineThicknessForThick; } } private static float LineThicknessForThick => vlnTable.LineThicknessForThick;
private static float LineThicknessForDouble { get { return vlnTable.LineThicknessForDouble; } } private static float LineThicknessForDouble => vlnTable.LineThicknessForDouble;
private static float DoubleLineOffset { get { return vlnTable.DoubleLineOffset; } } private static float DoubleLineOffset => vlnTable.DoubleLineOffset;
// adjustments for line intersections: // adjustments for line intersections:
private static float ThickOverDouble { get { return ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2; } } private static float ThickOverDouble => ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2;
private static float ThickUnderDouble { get { return DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2; } } private static float ThickUnderDouble => DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2;
private static float ThickOverThin { get { return (LineThicknessForThin - LineThicknessForThick) / 2; } } private static float ThickOverThin => (LineThicknessForThin - LineThicknessForThick) / 2;
private static float ThinOverThick { get { return (LineThicknessForThick - LineThicknessForThin) / 2; } } private static float ThinOverThick => (LineThicknessForThick - LineThicknessForThin) / 2;
private static float ThinUnderDouble { get { return DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2; } } private static float ThinUnderDouble => DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2;
private static float ThinOverDouble { get { return (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2; } } private static float ThinOverDouble => (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2;
private static float DoubleUnderThin { get { return (LineThicknessForThin - LineThicknessForDouble) / 2; } } private static float DoubleUnderThin => (LineThicknessForThin - LineThicknessForDouble) / 2;
private static float DoubleUnderThick { get { return (LineThicknessForThick - LineThicknessForDouble) / 2; } } private static float DoubleUnderThick => (LineThicknessForThick - LineThicknessForDouble) / 2;
#endregion #endregion
#region Constructors #region Constructors
public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent) public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent)
@@ -1440,16 +1169,11 @@ public string Path
} }
#endregion #endregion
#region Public Methods #region Public Methods
public override string ToString() public override string ToString() => string.Format("{0}:{1}", r1, c1);
{
return string.Format("{0}:{1}", r1, c1);
}
// B2018-003 - RHM 20180319 Add
public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent) public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent)
{ {
PdfContentByte cb = myColumnText.Canvas; PdfContentByte cb = myColumnText.Canvas;
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return; if (debugLayer == null) return;
System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray);
cb.SaveState(); cb.SaveState();
@@ -1481,7 +1205,6 @@ public string Path
cb.EndLayer(); cb.EndLayer();
cb.RestoreState(); cb.RestoreState();
} }
//RHM 20180319 End of Add
// B2021-137 Added doShading parameter // B2021-137 Added doShading parameter
// We call this twice. The first time to print the shading the second time to print the borders and text // We call this twice. The first time to print the shading the second time to print the borders and text
public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, int topPlacementAdjust, bool doShading) public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, int topPlacementAdjust, bool doShading)
@@ -1518,7 +1241,6 @@ public string Path
// B2019-093 missing table cell text when printing South Texas FSG-20 step 1 // B2019-093 missing table cell text when printing South Texas FSG-20 step 1
// Added two more to the last parameter of SetSimplColun (it's the ury value - upper y value) // Added two more to the last parameter of SetSimplColun (it's the ury value - upper y value)
// this will have the cell text print a little more toward the top of the cell // this will have the cell text print a little more toward the top of the cell
//myColumnText1.SetSimpleColumn(1 + left + x, top - y - h, left + x + w - 2, 3 + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding
// B2019-109 Adjusted width of cell to match edit cell // B2019-109 Adjusted width of cell to match edit cell
// B2020-034 - use the passed in topPlacementAdjust value which is set based on the font size. // B2020-034 - use the passed in topPlacementAdjust value which is set based on the font size.
myColumnText1.SetSimpleColumn(.5F + left + x, top - y - h, left + x + w - 1.5F, topPlacementAdjust + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding myColumnText1.SetSimpleColumn(.5F + left + x, top - y - h, left + x + w - 1.5F, topPlacementAdjust + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding
@@ -1566,7 +1288,6 @@ public string Path
int cellStatus = myColumnText1.Go(); // B2019-109 Add to Error Log if cell too small int cellStatus = myColumnText1.Go(); // B2019-109 Add to Error Log if cell too small
if (cellStatus != 1) if (cellStatus != 1)
{ {
//System.Windows.Forms.MessageBox.Show("Cell width too narrow \r\n" + MyTable.Path, "Narrow Cell", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
_MyLog.WarnFormat("\r\n=-=-=-= Cell Width too narrow, text is wrapping ItemID={0} Location={1}, Row={2}, Col={3}, Status={4}",MyTable.ItemID, MyTable.Path, r1, c1, cellStatus); _MyLog.WarnFormat("\r\n=-=-=-= Cell Width too narrow, text is wrapping ItemID={0} Location={1}, Row={2}, Col={3}, Status={4}",MyTable.ItemID, MyTable.Path, r1, c1, cellStatus);
} }
float posAfter = myColumnText1.YLine; // RHM20150429 - Table Scrunch float posAfter = myColumnText1.YLine; // RHM20150429 - Table Scrunch
@@ -1606,7 +1327,6 @@ public string Path
} }
return sb.ToString(); return sb.ToString();
} }
private static float _SixLinesPerInch = 12; // twips
public bool IsRangeStyleNull = false; public bool IsRangeStyleNull = false;
private TextAlignEnum? _TextAlign = null; private TextAlignEnum? _TextAlign = null;
public TextAlignEnum? TextAlign public TextAlignEnum? TextAlign
@@ -1635,7 +1355,6 @@ public string Path
private float VeritcalTextAlignment(float h, float mult) private float VeritcalTextAlignment(float h, float mult)
{ {
float hAdjust = 0; float hAdjust = 0;
//CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2);
if (!IsRangeStyleNull) if (!IsRangeStyleNull)
{ {
switch (TextAlign) switch (TextAlign)
@@ -1913,28 +1632,10 @@ public string Path
else if (linePattern == GridLinePattern.Dashed) else if (linePattern == GridLinePattern.Dashed)
cb.SetLineDash(4, 4, 0); cb.SetLineDash(4, 4, 0);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping row and col for Debugging")]
private static void SetLineColor(PdfContentByte cb, int row, int col, string side) private static void SetLineColor(PdfContentByte cb, int row, int col, string side)
{ {
iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
//switch (side)
//{
// case "Top":
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
// break;
// case "Left":
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
// break;
// case "Bottom":
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
// break;
// case "Right":
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
// break;
//}
cb.SetColorStroke(lineColor); cb.SetColorStroke(lineColor);
} }
private static void InitializeLineStyle(PdfContentByte cb) private static void InitializeLineStyle(PdfContentByte cb)
@@ -1946,8 +1647,10 @@ public string Path
#region Debug Methods #region Debug Methods
private static void SetOpacity(PdfContentByte cb, float opacity) private static void SetOpacity(PdfContentByte cb, float opacity)
{ {
PdfGState gs = new PdfGState(); PdfGState gs = new PdfGState
gs.StrokeOpacity = opacity; {
StrokeOpacity = opacity
};
cb.SetGState(gs); cb.SetGState(gs);
} }
private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom) private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom)
@@ -1956,141 +1659,5 @@ public string Path
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop); myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop);
} }
#endregion #endregion
#region Old Border Methods
//private void DrawLeftLine(PdfContentByte cb, float xLeft, float yTop, float yBottom)
//{
// if (c1 == 0 && LineLeft != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Left");
// if (LineLeft == GridLinePattern.Double)
// {
// //Left Line
// float dyTop = DoubleIntersectionLeft(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -DoubleIntersectionRight(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForDouble, xLeft - DoubleLineOffset, yTop + dyTop, xLeft - DoubleLineOffset, yBottom + dyBottom);
// //Right Line
// dyTop = DoubleIntersectionRight(LineTopLeft, LineTop, LineLeftAbove);
// dyBottom = -DoubleIntersectionLeft(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForDouble, xLeft + DoubleLineOffset, yTop + dyTop, xLeft + DoubleLineOffset, yBottom + dyBottom);
// }
// else if (LineLeft != GridLinePattern.Thick)
// {
// SetLinePattern(cb, LineLeft);
// float dyTop = ThinIntersection(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -ThinIntersection(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForThin, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom);
// }
// else
// {
// float dyTop = ThickIntersection(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -ThickIntersection(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForThick, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom);
// }
// cb.Stroke();
// }
//}
//private void DrawRightLine(PdfContentByte cb, float xRight, float yTop, float yBottom)
//{
// if (LineRight != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Right");
// if (LineRight == GridLinePattern.Double)
// {
// //Left Line
// float dyTop = DoubleIntersectionLeft(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -DoubleIntersectionRight(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForDouble, xRight - DoubleLineOffset, yTop + dyTop, xRight - DoubleLineOffset, yBottom + dyBottom);
// //Right Line
// dyTop = DoubleIntersectionRight(LineTop, LineTopRight, LineRightAbove);
// dyBottom = -DoubleIntersectionLeft(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForDouble, xRight + DoubleLineOffset, yTop + dyTop, xRight + DoubleLineOffset, yBottom + dyBottom);
// }
// else if (LineRight != GridLinePattern.Thick)
// {
// float dyTop = ThinIntersection(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -ThinIntersection(LineBottomRight, LineBottom, LineRightBelow);
// SetLinePattern(cb, LineRight);
// DrawLine(cb, LineThicknessForThin, xRight, yTop + dyTop, xRight, yBottom + dyBottom);
// }
// else
// {
// float dyTop = ThickIntersection(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -ThickIntersection(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForThick, xRight, yTop + dyTop, xRight, yBottom + dyBottom);
// }
// cb.Stroke();
// }
//}
//private void DrawTopLine(PdfContentByte cb, float xLeft, float xRight, float yTop)
//{
// if (r1 == 0 && TopSide != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Top");
// if (TopSide == GridLinePattern.Double)
// {
// // Top Line
// float dxLeft = -DoubleIntersectionRight(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = DoubleIntersectionLeft(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop + DoubleLineOffset, xRight + dxRight, yTop + DoubleLineOffset);
// // Bottom Line
// dxLeft = -DoubleIntersectionLeft(LeftSide, AboveLeftSide, LeftOfTopSide);
// dxRight = DoubleIntersectionRight(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop - DoubleLineOffset, xRight + dxRight, yTop - DoubleLineOffset);
// }
// else if (TopSide != GridLinePattern.Thick)
// {
// SetLinePattern(cb, TopSide);
// float dxLeft = -ThinIntersection(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = ThinIntersection(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yTop, xRight + dxRight, yTop);
// }
// else
// {
// float dxLeft = -ThickIntersection(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = ThickIntersection(AboveRightSide, RightSide, RightOfTopSide);
// if (c1 == 0)
// Console.WriteLine("'{0}','{1}','{2}',{3},{4}", LeftSide, AboveLeftSide, LeftOfTopSide, dxLeft, ThickOverThin);
// DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yTop, xRight + dxRight, yTop);
// }
// cb.Stroke();
// }
//}
//private void DrawBottomLine(PdfContentByte cb, float xLeft, float xRight, float yBottom)
//{
// if (BottomSide != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Bottom");
// if (BottomSide == GridLinePattern.Double)
// {
// // Top Line
// float dxLeft = -DoubleIntersectionRight(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = DoubleIntersectionLeft(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom + DoubleLineOffset, xRight + dxRight, yBottom + DoubleLineOffset);// Top Line
// // Bottom Line
// dxLeft = -DoubleIntersectionLeft(BelowLeftSide, LeftSide, LeftOfBottomSide);
// dxRight = DoubleIntersectionRight(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom - DoubleLineOffset, xRight + dxRight, yBottom - DoubleLineOffset);//Bottom Line
// }
// else if (BottomSide != GridLinePattern.Thick) // Bottom line is thin. Determine if intersecting with double:
// {
// SetLinePattern(cb, BottomSide);
// float dxLeft = -ThinIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = ThinIntersection(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom);
// }
// else
// {
// float dxLeft = -ThickIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = ThickIntersection(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom);
// }
// cb.Stroke();
// }
//}
#endregion
} }
} }
+22 -60
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -14,34 +13,15 @@ namespace Volian.Print.Library
{ {
public class MergedPdfProc public class MergedPdfProc
{ {
private string _Title; public string Title { get; // used for pdf outline
public string Title set; }
{ public int PageCount { get; set; }
get { return _Title; } // used for pdf outline public string PdfFileName { get; set; }
set { _Title = value; } public bool FirstPageNoPageNum { get; set; } = false;
}
private int _PageCount; // number of pages in the particular pdf, to aid in determining total page count for merged pdf
public int PageCount
{
get { return _PageCount; }
set { _PageCount = value; }
}
private string _PdfFileName; // used for finding the procedure's pdf file to merge
public string PdfFileName
{
get { return _PdfFileName; }
set { _PdfFileName = value; }
}
private bool _FirstPageNoPageNum = false;
public bool FirstPageNoPageNum
{
get { return _FirstPageNoPageNum; }
set { _FirstPageNoPageNum = value; }
}
public MergedPdfProc(string title, string pfname) public MergedPdfProc(string title, string pfname)
{ {
_Title = title; Title = title;
_PdfFileName = pfname; PdfFileName = pfname;
} }
} }
// this class will manage the data & do subsequent merging of pdf files. It is used if the user // this class will manage the data & do subsequent merging of pdf files. It is used if the user
@@ -49,25 +29,11 @@ namespace Volian.Print.Library
public class MergedPdf public class MergedPdf
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private List<MergedPdfProc> _mergedPdfs = null; // This list has all procedure pdfs that will be included in the merged file.
public List<MergedPdfProc> MergedPdfs public List<MergedPdfProc> MergedPdfs { get; set; } = null;
{ public string MergedFileName { get; set; } = null;
get { return _mergedPdfs; } public string Folder { get; set; }
set { _mergedPdfs = value; } private readonly DocVersionInfo _docVersionInfo;
}
string _mergedFileName = null; // this is the name to be given the merged file
public string MergedFileName
{
get { return _mergedFileName; }
set { _mergedFileName = value; }
}
private string _folder; // this is folder to create the merged file in
public string Folder
{
get { return _folder; }
set { _folder = value; }
}
private DocVersionInfo _docVersionInfo;
private string _pageof = null; private string _pageof = null;
private iTextSharp.text.Font _itextFont = null; private iTextSharp.text.Font _itextFont = null;
private MergedPdfsPageNumCorner _corner; private MergedPdfsPageNumCorner _corner;
@@ -80,11 +46,11 @@ namespace Volian.Print.Library
// the following constructs the class that contains data for merging a group of pdfs. // the following constructs the class that contains data for merging a group of pdfs.
public MergedPdf(string folder, DocVersionInfo dvi) public MergedPdf(string folder, DocVersionInfo dvi)
{ {
_folder = folder; Folder = folder;
_docVersionInfo = dvi; _docVersionInfo = dvi;
} }
// the following merges the procedure pdfs into a single pdf // the following merges the procedure pdfs into a single pdf
public bool DoTheMerge(Dictionary<string, List<int>> MergedLandscapPages, bool generatePointListFile) public bool DoTheMerge(bool generatePointListFile)
{ {
if (MergedPdfs == null) if (MergedPdfs == null)
{ {
@@ -93,7 +59,7 @@ namespace Volian.Print.Library
} }
iTextSharp.text.Document doc = new iTextSharp.text.Document(); iTextSharp.text.Document doc = new iTextSharp.text.Document();
string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_"; string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
MergedFileName = _folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf"; MergedFileName = Folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf";
MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName); MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName);
// C2021-063 file name of Alarm Point List file containing Serial Number, Title, and merged Page Number // C2021-063 file name of Alarm Point List file containing Serial Number, Title, and merged Page Number
StreamWriter sw = null; StreamWriter sw = null;
@@ -109,12 +75,12 @@ namespace Volian.Print.Library
{ {
writer = PdfWriter.GetInstance(doc, new FileStream(MergedFileName, FileMode.Create)); writer = PdfWriter.GetInstance(doc, new FileStream(MergedFileName, FileMode.Create));
} }
catch (Exception ex) catch (Exception)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create"); sb.AppendLine("Could not create");
sb.AppendLine(); sb.AppendLine();
sb.AppendLine(MergedFileName + "."); sb.AppendLine($"{MergedFileName}.");
sb.AppendLine(); sb.AppendLine();
sb.AppendLine("If it is open, close and retry."); sb.AppendLine("If it is open, close and retry.");
FlexibleMessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); FlexibleMessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -136,7 +102,7 @@ namespace Volian.Print.Library
// write Serial Number, Title, and Page Number in the Point List file // write Serial Number, Title, and Page Number in the Point List file
sw.WriteLine("{0}\t{1}\t{2}", idxSerialNum++, mpp.Title, mergedPageNumber + 1); sw.WriteLine("{0}\t{1}\t{2}", idxSerialNum++, mpp.Title, mergedPageNumber + 1);
} }
string pdffilename = _folder + @"\" + mpp.PdfFileName; string pdffilename = $@"{Folder}\{mpp.PdfFileName}";
if (!File.Exists(pdffilename)) if (!File.Exists(pdffilename))
{ {
FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -154,7 +120,7 @@ namespace Volian.Print.Library
PdfReader reader = null; PdfReader reader = null;
try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log. try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log.
{ {
reader = new PdfReader(_folder + @"\" + mpp.PdfFileName); reader = new PdfReader($@"{Folder}\{mpp.PdfFileName}");
int numPages = reader.NumberOfPages; int numPages = reader.NumberOfPages;
int currentPageNumber = 0; int currentPageNumber = 0;
PdfOutline outline = null; PdfOutline outline = null;
@@ -178,7 +144,7 @@ namespace Volian.Print.Library
// if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number. // if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number.
// Later this may need expanded to put sections/steps/etc. // Later this may need expanded to put sections/steps/etc.
if (currentPageNumber == 1) if (currentPageNumber == 1)
outline = new PdfOutline(canvas.RootOutline, dest, mpp.PdfFileName.Replace(".pdf", "") + " - " + mpp.Title, false); outline = new PdfOutline(canvas.RootOutline, dest, $"{mpp.PdfFileName.Replace(".pdf", "")} - {mpp.Title}", false);
else else
new PdfOutline(outline, dest, "Page " + currentPageNumber.ToString(), false); new PdfOutline(outline, dest, "Page " + currentPageNumber.ToString(), false);
canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf
@@ -204,17 +170,13 @@ namespace Volian.Print.Library
private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage, bool landscape) private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage, bool landscape)
{ {
float pgright = page.BoundingBox.Right; float pgright = page.BoundingBox.Right;
float pgleft = page.BoundingBox.Left;
float pgtop = page.BoundingBox.Top; float pgtop = page.BoundingBox.Top;
float pgbot = page.BoundingBox.Bottom;
MergedPdfsPageNumCorner cnr = _corner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location MergedPdfsPageNumCorner cnr = _corner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
// B2019-152: Landscape page numbers when merging // B2019-152: Landscape page numbers when merging
if (landscape) if (landscape)
{ {
pgright = page.BoundingBox.Top; pgright = page.BoundingBox.Top;
pgleft = page.BoundingBox.Bottom;
pgtop = page.BoundingBox.Right; pgtop = page.BoundingBox.Right;
pgbot = page.BoundingBox.Left;
cnr = _landcorner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location cnr = _landcorner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
} }
Phrase ph = new Phrase(); Phrase ph = new Phrase();
@@ -281,7 +243,7 @@ namespace Volian.Print.Library
private bool GetPageOfInfo() private bool GetPageOfInfo()
{ {
DocVersionConfig dvc = (DocVersionConfig) _docVersionInfo.MyConfig; DocVersionConfig dvc = (DocVersionConfig) _docVersionInfo.MyConfig;
MergedPdfsPageOf po = dvc.Print_MergedPdfsPageOf; _ = dvc.Print_MergedPdfsPageOf;
string tmp = EnumDescConverter.GetEnumDescription((Enum)dvc.Print_MergedPdfsPageOf); string tmp = EnumDescConverter.GetEnumDescription((Enum)dvc.Print_MergedPdfsPageOf);
if (tmp == "None") return false; // no page number, return false so no page number is put out. if (tmp == "None") return false; // no page number, return false so no page number is put out.
@@ -297,7 +259,7 @@ namespace Volian.Print.Library
famtmp = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Family; famtmp = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Family;
} }
tmp = dvc.Print_MergedPdfsPageNumFontSize; tmp = dvc.Print_MergedPdfsPageNumFontSize;
float? tmpi=0; float? tmpi;
if (tmp == null || tmp == "") if (tmp == null || tmp == "")
{ {
// use the default from the format from this working draft // use the default from the format from this working draft
File diff suppressed because it is too large Load Diff
@@ -6,35 +6,20 @@ using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Linq;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public class PDFConsistencyCheckReport public class PDFConsistencyCheckReport
{ {
private DocVersionInfo _MyDocVersion; public DocVersionInfo MyDocVersion { get; set; }
public DocVersionInfo MyDocVersion public string FileName { get; set; }
{ public ItemInfoList MyItemInfoList { get; set; }
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) public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion)
{ {
_FileName = fileName; FileName = fileName;
_MyItemInfoList = myItemInfoList; MyItemInfoList = myItemInfoList;
_MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format
} }
public void BuildReport() public void BuildReport()
{ {
@@ -47,7 +32,6 @@ namespace Volian.Print.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:")); document.Add(new Paragraph("Error:"));
while (ex != null) while (ex != null)
{ {
@@ -61,7 +45,7 @@ namespace Volian.Print.Library
if (document.IsOpen()) if (document.IsOpen())
{ {
document.Close(); 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. // Try to open a file for creating the PDF.
while (result == false) while (result == false)
{ {
string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); string fileName = FileName.ToLower().Replace(".pdf", suffix + ".pdf");
try try
{ {
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
document.SetMargins(36, 36, 36, 36); document.SetMargins(36, 36, 36, 36);
document.Open(); document.Open();
_FileName = fileName; FileName = fileName;
result = true; result = true;
} }
catch (System.IO.IOException exIO) catch (System.IO.IOException exIO)
@@ -118,9 +102,11 @@ namespace Volian.Print.Library
} }
private PdfPCell BlankCell(int colSpan) private PdfPCell BlankCell(int colSpan)
{ {
PdfPCell c = new PdfPCell(); PdfPCell c = new PdfPCell
c.Colspan = colSpan; {
c.Border = 0; Colspan = colSpan,
Border = 0
};
return c; return c;
} }
private void BuildConsistencyReport(iTextSharp.text.Document doc) 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 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); iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK);
int cols = 5; int cols = 5;
int borders = 0;
int paddingBottom = 6; int paddingBottom = 6;
// float[] widths; // float[] widths;
Csla.SortedBindingList<ItemInfo> sortedProcs = new Csla.SortedBindingList<ItemInfo>(MyItemInfoList); 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. // 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 // Check if procedure(s) are printed on that page and if not, change message to "No..." and don't do
// pagebreak. // pagebreak.
foreach (ProcedureInfo pi in sortedProcs) foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{ {
if (pi.IsSelected) if (pi.IsSelected)
{ {
@@ -160,16 +145,20 @@ namespace Volian.Print.Library
lbSrchResults.DataSource = sortedResults; lbSrchResults.DataSource = sortedResults;
*/ */
foreach (ProcedureInfo pi in sortedProcs) foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{ {
if (pi.IsSelected) if (pi.IsSelected)
{ {
PdfPTable tt = new PdfPTable(cols); PdfPTable tt = new PdfPTable(cols)
tt.KeepTogether = true; {
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt); PdfPCell c = new PdfPCell(tt)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
} }
} }
@@ -179,16 +168,20 @@ namespace Volian.Print.Library
if (didSome) doc.NewPage(); if (didSome) doc.NewPage();
t = CreatePdfPTable(cols); 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"); 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) if (!pi.IsSelected)
{ {
PdfPTable tt = new PdfPTable(cols); PdfPTable tt = new PdfPTable(cols)
tt.KeepTogether = true; {
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt); PdfPCell c = new PdfPCell(tt)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
} }
} }
@@ -196,42 +189,54 @@ namespace Volian.Print.Library
} }
private PdfPCell AddSubTableCell(string text, iTextSharp.text.Font f, int cols, float pb) private PdfPCell AddSubTableCell(string text, iTextSharp.text.Font f, int cols, float pb)
{ {
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = f; {
Font = f
};
h.Add(text); h.Add(text);
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = Element.ALIGN_LEFT; Colspan = cols,
c.PaddingBottom = pb; HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = pb
};
return c; return c;
} }
private void CreatePageHeader(PdfPTable t, iTextSharp.text.Font f1, iTextSharp.text.Font f2, int cols, float pb, string hdr1, string hdr2) private void CreatePageHeader(PdfPTable t, iTextSharp.text.Font f1, iTextSharp.text.Font f2, int cols, float pb, string hdr1, string hdr2)
{ {
//report title //report title
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = f1; {
Font = f1
};
h.Add(hdr1); h.Add(hdr1);
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = Element.ALIGN_CENTER; Colspan = cols,
c.PaddingBottom = pb; HorizontalAlignment = Element.ALIGN_CENTER,
//c.Border = borders; PaddingBottom = pb
};
t.AddCell(c); t.AddCell(c);
h = new Phrase(); h = new Phrase
h.Font = f2; {
Font = f2
};
h.Add(hdr2); h.Add(hdr2);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = Element.ALIGN_CENTER; Colspan = cols,
c.PaddingBottom = pb; HorizontalAlignment = Element.ALIGN_CENTER,
//c.Border = borders; PaddingBottom = pb
};
t.AddCell(c); t.AddCell(c);
t.AddCell(BlankCell(cols)); t.AddCell(BlankCell(cols));
} }
private PdfPTable CreatePdfPTable(int cols) private PdfPTable CreatePdfPTable(int cols)
{ {
PdfPTable t = new PdfPTable(cols); PdfPTable t = new PdfPTable(cols)
t.HeaderRows = 3; {
HeaderRows = 3
};
t.DefaultCell.Padding = 4; t.DefaultCell.Padding = 4;
t.WidthPercentage = 100; t.WidthPercentage = 100;
float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f };
@@ -251,7 +256,6 @@ namespace Volian.Print.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:")); document.Add(new Paragraph("Error:"));
while (ex != null) while (ex != null)
{ {
@@ -265,7 +269,7 @@ namespace Volian.Print.Library
if (document.IsOpen()) if (document.IsOpen())
{ {
document.Close(); 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 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 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 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 cols = 3;
int borders = 0; PdfPTable t = new PdfPTable(cols)
int paddingBottom = 6; {
PdfPTable t = new PdfPTable(cols); HeaderRows = 1,
t.HeaderRows = 1; WidthPercentage = 100
t.WidthPercentage = 100; };
float[] widths = new float[] { 1f, 1f, 10f }; float[] widths = new float[] { 1f, 1f, 10f };
t.SetWidths(widths); t.SetWidths(widths);
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = f1; {
Font = f1
};
h.Add("Approved Procedures Inconsistencies Report"); h.Add("Approved Procedures Inconsistencies Report");
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = 1; Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c); t.AddCell(c);
// C2021-013: Include the Procedure set name & date // C2021-013: Include the Procedure set name & date
h = new Phrase(); h = new Phrase
h.Font = f1; {
Font = f1
};
string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy"); string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy");
h.Add(tmp); h.Add(tmp);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = 1; Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c); t.AddCell(c);
Dictionary<int, string> types = new Dictionary<int, string>(); 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" : ""; string type = pi.MyDifferences.ROConsistency.MyROChecks.Length > 0 ? "Reference Object Inconsistencies" : "";
if (type != string.Empty && !types.ContainsKey(0)) if (type != string.Empty && !types.ContainsKey(0))
@@ -314,14 +325,17 @@ namespace Volian.Print.Library
if (type != string.Empty && !types.ContainsKey(2)) if (type != string.Empty && !types.ContainsKey(2))
types.Add(2, type); types.Add(2, type);
} }
// types.Clear();
if (types.Count == 0) if (types.Count == 0)
{ {
h = new Phrase(); h = new Phrase
h.Font = f2; {
Font = f2
};
h.Add("No Inconsistencies"); h.Add("No Inconsistencies");
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
} }
else else
@@ -335,7 +349,7 @@ namespace Volian.Print.Library
ROFSTLookup lu = rofst.GetROFSTLookup(dvi); ROFSTLookup lu = rofst.GetROFSTLookup(dvi);
if (types.ContainsKey(0)) if (types.ContainsKey(0))
{ {
foreach (ProcedureInfo pi in MyItemInfoList) foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{ {
foreach (ROCheck roc in pi.MyDifferences.ROConsistency.MyROChecks) 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>>(); //Dictionary<string, List<string>> trs = new Dictionary<string, List<string>>();
if (types.ContainsKey(1)) if (types.ContainsKey(1))
{ {
foreach (ProcedureInfo pi in MyItemInfoList) foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{ {
foreach (TransitionCheck trc in pi.MyDifferences.TransitionConsistency.MyTransitionChecks) 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>>(); //Dictionary<string, List<string>> lds = new Dictionary<string, List<string>>();
if (types.ContainsKey(2)) if (types.ContainsKey(2))
{ {
foreach (ProcedureInfo pi in MyItemInfoList) foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{ {
foreach (LibDocCheck ldc in pi.MyDifferences.LibDocConsistency.MyLibDocChecks) foreach (LibDocCheck ldc in pi.MyDifferences.LibDocConsistency.MyLibDocChecks)
{ {
@@ -420,27 +434,37 @@ namespace Volian.Print.Library
Color badColor = new Color(System.Drawing.Color.Khaki); Color badColor = new Color(System.Drawing.Color.Khaki);
if (types.ContainsKey(0)) if (types.ContainsKey(0))
{ {
h = new Phrase(); h = new Phrase
h.Font = f2; {
Font = f2
};
h.Add(types[0]); h.Add(types[0]);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
foreach (string rotitle in ros.Keys) foreach (string rotitle in ros.Keys)
{ {
t.AddCell(BlankCell(1)); t.AddCell(BlankCell(1));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(rotitle); h.Add(rotitle);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols - 1; {
c.BackgroundColor = goodColor; Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c); t.AddCell(c);
foreach (KeyValuePair<string,bool> d in ros[rotitle]) foreach (KeyValuePair<string,bool> d in ros[rotitle])
{ {
t.AddCell(BlankCell(2)); t.AddCell(BlankCell(2));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(d.Key); h.Add(d.Key);
c = new PdfPCell(h); c = new PdfPCell(h);
if (d.Value) if (d.Value)
@@ -451,30 +475,39 @@ namespace Volian.Print.Library
} }
} }
} }
//jcb
if (types.ContainsKey(1)) if (types.ContainsKey(1))
{ {
h = new Phrase(); h = new Phrase
h.Font = f2; {
Font = f2
};
h.Add(types[1]); h.Add(types[1]);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
foreach (string trtitle in trs.Keys) foreach (string trtitle in trs.Keys)
{ {
t.AddCell(BlankCell(1)); t.AddCell(BlankCell(1));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(trtitle); h.Add(trtitle);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols - 1; {
c.BackgroundColor = goodColor; Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c); t.AddCell(c);
foreach (KeyValuePair<string, bool> d in trs[trtitle]) foreach (KeyValuePair<string, bool> d in trs[trtitle])
{ {
t.AddCell(BlankCell(2)); t.AddCell(BlankCell(2));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(d.Key); h.Add(d.Key);
c = new PdfPCell(h); c = new PdfPCell(h);
if (d.Value) if (d.Value)
@@ -488,27 +521,37 @@ namespace Volian.Print.Library
//end jcb //end jcb
if (types.ContainsKey(2)) if (types.ContainsKey(2))
{ {
h = new Phrase(); h = new Phrase
h.Font = f2; {
Font = f2
};
h.Add(types[2]); h.Add(types[2]);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
Colspan = cols
};
t.AddCell(c); t.AddCell(c);
foreach (string ldtitle in lds.Keys) foreach (string ldtitle in lds.Keys)
{ {
t.AddCell(BlankCell(1)); t.AddCell(BlankCell(1));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(ldtitle); h.Add(ldtitle);
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols - 1; {
c.BackgroundColor = goodColor; Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c); t.AddCell(c);
foreach (KeyValuePair<string, bool> d in lds[ldtitle]) foreach (KeyValuePair<string, bool> d in lds[ldtitle])
{ {
t.AddCell(BlankCell(2)); t.AddCell(BlankCell(2));
h = new Phrase(); h = new Phrase
h.Font = f3; {
Font = f3
};
h.Add(d.Key); h.Add(d.Key);
c = new PdfPCell(h); c = new PdfPCell(h);
if (d.Value) if (d.Value)
+3 -6
View File
@@ -1,9 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VEPROMS.CSLA.Library;
using iTextSharp.text; using iTextSharp.text;
@@ -12,7 +7,9 @@ namespace Volian.Print.Library
public class PDFPageSize public class PDFPageSize
{ {
// C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using // C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, Rectangle> dicPDFPageSize = new Dictionary<string, Rectangle>(); private static Dictionary<string, Rectangle> dicPDFPageSize = new Dictionary<string, Rectangle>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, int> dicPDFPageSizePnts = new Dictionary<string, int>(); private static Dictionary<string, int> dicPDFPageSizePnts = new Dictionary<string, int>();
private static void BuildPDFPageSizeDic() private static void BuildPDFPageSizeDic()
{ {
File diff suppressed because it is too large Load Diff
+171 -162
View File
@@ -5,7 +5,7 @@ using VEPROMS.CSLA.Library;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Linq;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
@@ -13,26 +13,13 @@ namespace Volian.Print.Library
public class PDFTransitionReport public class PDFTransitionReport
{ {
public event TransitionReportEvent TransitionProcessed; public event TransitionReportEvent TransitionProcessed;
private void OnTransitionProcessed(object sender, EventArgs args) private void OnTransitionProcessed(object sender, EventArgs args) => TransitionProcessed?.Invoke(sender, args);
{
if (TransitionProcessed != null) TransitionProcessed(sender, args);
}
public event TransitionReportEvent ProcedureProcessed; public event TransitionReportEvent ProcedureProcessed;
private void OnProcedureProcessed(object sender, EventArgs args) private void OnProcedureProcessed(object sender, EventArgs args) => ProcedureProcessed?.Invoke(sender, args);
{
if (ProcedureProcessed != null) ProcedureProcessed(sender, args);
}
public event TransitionReportEvent DocVersionProcessed; public event TransitionReportEvent DocVersionProcessed;
private void OnDocVersionProcessed(object sender, EventArgs args) private void OnDocVersionProcessed(object sender, EventArgs args) => DocVersionProcessed?.Invoke(sender, args);
{
if (DocVersionProcessed != null) DocVersionProcessed(sender, args); public string FileName { get; set; }
}
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private PdfPCell _CurrentPageNumberCell = null; private PdfPCell _CurrentPageNumberCell = null;
private int _CurrentPageNumber = 1; private int _CurrentPageNumber = 1;
public int CurrentPageNumber public int CurrentPageNumber
@@ -51,41 +38,27 @@ namespace Volian.Print.Library
} }
} }
} }
private FolderInfo folderInfo; private readonly FolderInfo folderInfo;
private ProcedureInfo procedureInfo; private ProcedureInfo procedureInfo;
private TransitionInfoList transitionInfoList; private TransitionInfoList transitionInfoList;
private int _TransitionInfoCount;
public int TransitionInfoCount public int TransitionInfoCount { get; set; }
{ public List<DocVersionInfo> MyDocVersionList { get; set; }
get { return _TransitionInfoCount; } public int ProcedureCount { get; set; }
set { _TransitionInfoCount = value; } private readonly string _PaperSize = "Letter";
}
private List<DocVersionInfo> _MyDocVersionList;
public List<DocVersionInfo> MyDocVersionList
{
get { return _MyDocVersionList; }
set { _MyDocVersionList = value; }
}
private int _ProcedureCount;
public int ProcedureCount
{
get { return _ProcedureCount; }
set { _ProcedureCount = value; }
}
private string _PaperSize = "Letter";
public PDFTransitionReport(FolderInfo fi, string fileName) public PDFTransitionReport(FolderInfo fi, string fileName)
{ {
_FileName = fileName; FileName = fileName;
folderInfo = fi; folderInfo = fi;
if (fi.ActiveFormat != null) if (fi.ActiveFormat != null)
_PaperSize = fi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files _PaperSize = fi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
} }
public PDFTransitionReport(ProcedureInfo pi, string fileName) public PDFTransitionReport(ProcedureInfo pi, string fileName)
{ {
_FileName = fileName; FileName = fileName;
procedureInfo = pi; procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(procedureInfo.MyDocVersion.VersionID, procedureInfo.ItemID); transitionInfoList = TransitionInfoList.GetTransitionReportData(procedureInfo.MyDocVersion.VersionID, procedureInfo.ItemID);
_TransitionInfoCount = transitionInfoList.Count; TransitionInfoCount = transitionInfoList.Count;
_PaperSize = pi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files _PaperSize = pi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
} }
public void BuildTransitionReport() public void BuildTransitionReport()
@@ -100,13 +73,13 @@ namespace Volian.Print.Library
if (MyDocVersionList.Count == 1) if (MyDocVersionList.Count == 1)
{ {
DocVersionInfo dvi = MyDocVersionList[0]; DocVersionInfo dvi = MyDocVersionList[0];
foreach (ProcedureInfo pi in dvi.Procedures) foreach (ProcedureInfo pi in dvi.Procedures.OfType<ProcedureInfo>())
{ {
procedureInfo = pi; procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID); transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID);
if (transitionInfoList.Count > 0) if (transitionInfoList.Count > 0)
{ {
_TransitionInfoCount = transitionInfoList.Count; TransitionInfoCount = transitionInfoList.Count;
OnProcedureProcessed(this, new EventArgs()); OnProcedureProcessed(this, new EventArgs());
BuildProcedureReport(document); BuildProcedureReport(document);
} }
@@ -122,11 +95,11 @@ namespace Volian.Print.Library
{ {
ProcedureCount = dvi.Procedures.Count; ProcedureCount = dvi.Procedures.Count;
OnDocVersionProcessed(this, new EventArgs()); OnDocVersionProcessed(this, new EventArgs());
foreach (ProcedureInfo pi in dvi.Procedures) foreach (ProcedureInfo pi in dvi.Procedures.OfType<ProcedureInfo>())
{ {
procedureInfo = pi; procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID); transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID);
_TransitionInfoCount = transitionInfoList.Count; TransitionInfoCount = transitionInfoList.Count;
OnProcedureProcessed(this, new EventArgs()); OnProcedureProcessed(this, new EventArgs());
BuildProcedureReport(document); BuildProcedureReport(document);
} }
@@ -140,7 +113,6 @@ namespace Volian.Print.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:")); document.Add(new Paragraph("Error:"));
while (ex != null) while (ex != null)
{ {
@@ -160,10 +132,12 @@ namespace Volian.Print.Library
} }
PdfOutline outline = null; PdfOutline outline = null;
ProcedureInfo lastProcedureInfo = null; ProcedureInfo lastProcedureInfo = null;
private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level, iTextSharp.text.Document doc) private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level)
{ {
PdfPTable t = new PdfPTable(cols); PdfPTable t = new PdfPTable(cols)
t.HeaderRows = 4; {
HeaderRows = 4
};
t.DefaultCell.Padding = 4; t.DefaultCell.Padding = 4;
t.WidthPercentage = 100; t.WidthPercentage = 100;
float[] widths; float[] widths;
@@ -173,30 +147,40 @@ namespace Volian.Print.Library
widths = new float[] { 33f, 47f, 20f }; widths = new float[] { 33f, 47f, 20f };
t.SetWidths(widths); t.SetWidths(widths);
//report title //report title
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = fonts[1]; {
Font = fonts[1]
};
if (folderInfo != null) if (folderInfo != null)
h.Add(string.Format("Procedure Set {0} Transition Report", folderInfo.Name)); h.Add(string.Format("Procedure Set {0} Transition Report", folderInfo.Name));
else else
h.Add("Transition Report"); h.Add("Transition Report");
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.Colspan = cols-1; {
c.HorizontalAlignment = Element.ALIGN_LEFT; Colspan = cols - 1,
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod)
};
t.AddCell(c); t.AddCell(c);
//date generated //date generated
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt")); h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt"));
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_RIGHT; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_RIGHT,
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod)
};
t.AddCell(c); t.AddCell(c);
//procedure title //procedure title
h = new Phrase(); h = new Phrase
h.Font = fonts[2]; {
Font = fonts[2]
};
h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText)); h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText));
PdfDestination dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height); PdfDestination dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height);
if (lastProcedureInfo != procedureInfo) if (lastProcedureInfo != procedureInfo)
@@ -204,19 +188,23 @@ namespace Volian.Print.Library
outline = new PdfOutline(cb.RootOutline, dest, procedureInfo.DisplayNumber, false); outline = new PdfOutline(cb.RootOutline, dest, procedureInfo.DisplayNumber, false);
lastProcedureInfo = procedureInfo; lastProcedureInfo = procedureInfo;
} }
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols-1; {
c.HorizontalAlignment = Element.ALIGN_LEFT; Colspan = cols - 1,
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
c.BackgroundColor = new Color(System.Drawing.Color.Goldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.Goldenrod)
};
t.AddCell(c); t.AddCell(c);
//page number //page number
_CurrentPageNumberCell = BuildCell(1, string.Format("Page {0}",CurrentPageNumber), fonts[4], new Color(System.Drawing.Color.Goldenrod)); _CurrentPageNumberCell = BuildCell(1, string.Format("Page {0}",CurrentPageNumber), fonts[4], new Color(System.Drawing.Color.Goldenrod));
_CurrentPageNumberCell.PaddingBottom = paddingBottom; _CurrentPageNumberCell.PaddingBottom = paddingBottom;
t.AddCell(_CurrentPageNumberCell); t.AddCell(_CurrentPageNumberCell);
//transition category //transition category
h = new Phrase(); h = new Phrase
h.Font = fonts[3]; {
Font = fonts[3]
};
if (transitionInfoList.Count == 0) if (transitionInfoList.Count == 0)
h.Add("N/A"); h.Add("N/A");
else else
@@ -225,36 +213,50 @@ namespace Volian.Print.Library
dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height); dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height);
new PdfOutline(outline, dest, levels[level]); new PdfOutline(outline, dest, levels[level]);
} }
c = new PdfPCell(h); c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = Element.ALIGN_LEFT; Colspan = cols,
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
c.BackgroundColor = new Color(System.Drawing.Color.Khaki); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.Khaki)
};
t.AddCell(c); t.AddCell(c);
//add column headers //add column headers
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add("From Procedure Location"); h.Add("From Procedure Location");
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_CENTER; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_CENTER,
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c); t.AddCell(c);
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add("From Procedure Text"); h.Add("From Procedure Text");
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_CENTER; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_CENTER,
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c); t.AddCell(c);
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add("To Procedure Location"); h.Add("To Procedure Location");
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_CENTER; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_CENTER,
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c); t.AddCell(c);
return t; return t;
} }
@@ -262,37 +264,45 @@ namespace Volian.Print.Library
private void BuildProcedureReport(iTextSharp.text.Document doc) private void BuildProcedureReport(iTextSharp.text.Document doc)
{ {
Dictionary<int, string> tranTypes = FormatInfo.GetTransitionTypesByFormatID(procedureInfo.ActiveFormat.FormatID); Dictionary<int, string> tranTypes = FormatInfo.GetTransitionTypesByFormatID(procedureInfo.ActiveFormat.FormatID);
Dictionary<int, string> levels = new Dictionary<int, string>(); Dictionary<int, string> levels = new Dictionary<int, string>
levels.Add(1, "Internal Transitions"); {
levels.Add(2, "External From Transitions"); { 1, "Internal Transitions" },
levels.Add(3, "External To Transitions"); { 2, "External From Transitions" },
levels.Add(4, "Outside From Transitions"); { 3, "External To Transitions" },
levels.Add(5, "Outside To Transitions"); { 4, "Outside From Transitions" },
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>(); { 5, "Outside To Transitions" }
};
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>
{
// C2017-036 get best available proportional font for symbols that looks close to Arial // C2017-036 get best available proportional font for symbols that looks close to Arial
// Note that Microsoft no longer supplies Arial Unicode MS as of Word16 // Note that Microsoft no longer supplies Arial Unicode MS as of Word16
fonts.Add(1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK)); { 1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK) },
fonts.Add(2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK)); { 2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK) },
fonts.Add(3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK)); { 3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) },
fonts.Add(4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK)); { 4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) }
};
int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level
#region buildtable #region buildtable
int cols = 3; int cols = 3;
int paddingBottom = 6; int paddingBottom = 6;
if (folderInfo != null) if (folderInfo != null)
doc.NewPage(); doc.NewPage();
PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc); PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
#endregion #endregion
//gather data //gather data
if (transitionInfoList.Count == 0) if (transitionInfoList.Count == 0)
{ {
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add("This procedure contains no transitions"); h.Add("This procedure contains no transitions");
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.Colspan = cols; {
c.HorizontalAlignment = Element.ALIGN_LEFT; Colspan = cols,
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
t.AddCell(c); t.AddCell(c);
} }
else else
@@ -308,36 +318,48 @@ namespace Volian.Print.Library
doc.Add(t); doc.Add(t);
doc.NewPage(); doc.NewPage();
lastLevel = ti.Level; lastLevel = ti.Level;
t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc); t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
} }
} }
//add from path //add from path
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
h.Add(StripProcInfo(ti.PathFrom, procedureInfo)); h.Add(StripProcInfo(ti.PathFrom, procedureInfo));
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_LEFT; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c); t.AddCell(c);
//add from text //add from text
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
ItemInfo myItemInfo = ti.MyContent.ContentItems[0]; ItemInfo myItemInfo = ti.MyContent.ContentItems[0];
h.Add(GetTextPath(myItemInfo, 0)); h.Add(GetTextPath(myItemInfo, 0));
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_LEFT; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c); t.AddCell(c);
//add to text //add to text
h = new Phrase(); h = new Phrase
h.Font = fonts[4]; {
Font = fonts[4]
};
myItemInfo = ti.MyItemToID; myItemInfo = ti.MyItemToID;
h.Add(GetTextPath(myItemInfo, ti.Level)); h.Add(GetTextPath(myItemInfo, ti.Level));
c = new PdfPCell(h); c = new PdfPCell(h)
c.HorizontalAlignment = Element.ALIGN_LEFT; {
c.PaddingBottom = paddingBottom; HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c); t.AddCell(c);
} }
@@ -357,16 +379,16 @@ namespace Volian.Print.Library
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (myItemInfo.IsProcedure) if (myItemInfo.IsProcedure)
return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText; return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}";
if (myItemInfo.IsSection) if (myItemInfo.IsSection)
{ {
if (level > 1) if (level > 1)
return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText + "\r\n " + myItemInfo.DisplayText; return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}\r\n {myItemInfo.DisplayText}";
else else
return myItemInfo.DisplayText; return myItemInfo.DisplayText;
} }
if (myItemInfo.IsHigh) if (myItemInfo.IsHigh)
return myItemInfo.ActiveSection.DisplayText + "\r\n " + myItemInfo.DisplayText; return $"{myItemInfo.ActiveSection.DisplayText}\r\n {myItemInfo.DisplayText}";
else else
{ {
string tmp = ""; string tmp = "";
@@ -393,10 +415,6 @@ namespace Volian.Print.Library
} }
return sb.ToString(); return sb.ToString();
} }
public void BuildTransitionReport(FolderInfo fi)
{
System.Windows.Forms.MessageBox.Show("folder");
}
private bool CreateResultsPDF(iTextSharp.text.Document document) private bool CreateResultsPDF(iTextSharp.text.Document document)
{ {
bool result = false; bool result = false;
@@ -404,26 +422,20 @@ namespace Volian.Print.Library
int i = 0; int i = 0;
// just for safety, the while loop expects to find a file extension // just for safety, the while loop expects to find a file extension
// so make sure it has one before going into the loop // so make sure it has one before going into the loop
if (!_FileName.ToUpper().EndsWith(".PDF")) if (!FileName.ToUpper().EndsWith(".PDF"))
_FileName += ".pdf"; FileName += ".pdf";
// Try to open a file for creating the PDF. // Try to open a file for creating the PDF.
while (result == false) while (result == false)
{ {
string fileName = _FileName; string fileName = FileName;
// Bug fix: B2013-086
// the folder path part of _FileName contained a folder name with a period
// resulting is an invalid file location/file name.
// Changed the IndexOf call to the LastIndexOf
//int loc = fileName.IndexOf(".");
int loc = fileName.LastIndexOf("."); int loc = fileName.LastIndexOf(".");
if (loc > -1) if (loc > -1)
{ {
string fname = fileName.Substring(0, loc); string fname = fileName.Substring(0, loc);
fileName = fname + suffix + ".pdf"; fileName = $"{fname}{suffix}.pdf";
} }
else else
fileName = fileName + suffix + ".pdf"; fileName = $"{fileName}{suffix}.pdf";
// string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf");
try try
{ {
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
@@ -431,7 +443,7 @@ namespace Volian.Print.Library
document.SetMargins(36, 36, 36, 36); document.SetMargins(36, 36, 36, 36);
document.Open(); document.Open();
cb = writer.DirectContent; cb = writer.DirectContent;
_FileName = fileName; FileName = fileName;
result = true; result = true;
} }
catch (System.IO.IOException exIO) catch (System.IO.IOException exIO)
@@ -468,28 +480,25 @@ namespace Volian.Print.Library
} }
System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
} }
private PdfPCell BlankCell(int colSpan)
{
PdfPCell c = new PdfPCell();
c.Colspan = colSpan;
c.Border = 0;
return c;
}
private PdfPCell BuildCell(int colspan, string txt, Font f, iTextSharp.text.Color clr) private PdfPCell BuildCell(int colspan, string txt, Font f, iTextSharp.text.Color clr)
{ {
Phrase h = new Phrase(); Phrase h = new Phrase
h.Font = f; {
Font = f
};
h.Add(txt); h.Add(txt);
PdfPCell c = new PdfPCell(h); PdfPCell c = new PdfPCell(h)
c.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT; {
c.Colspan = colspan; HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT,
c.BackgroundColor = clr; Colspan = colspan,
BackgroundColor = clr
};
return c; return c;
} }
} }
public class MyPageEvent : PdfPageEventHelper public class MyPageEvent : PdfPageEventHelper
{ {
private PDFTransitionReport _rpt = null; private readonly PDFTransitionReport _rpt = null;
public MyPageEvent(PDFTransitionReport rpt) public MyPageEvent(PDFTransitionReport rpt)
{ {
_rpt = rpt; _rpt = rpt;
+16 -57
View File
@@ -1,39 +1,22 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using Volian.Svg.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public class PageCount public class PageCount
{ {
private bool _CanIncrement = true; public bool CanIncrement { get; set; } = true;
public bool CanIncrement
{
get { return _CanIncrement; }
set { _CanIncrement = value; }
}
private int Increment() private int Increment()
{ {
if (CanIncrement) Total++; if (CanIncrement) Total++;
CanIncrement = false; CanIncrement = false;
return Total; return Total;
} }
private int _Total;
public int Total
{
get { return _Total; }
set { _Total = value; }
}
private string _FinalPageMessage;
public string FinalPageMessage public int Total { get; set; }
{
get { return _FinalPageMessage; } public string FinalPageMessage { get; set; }
set { _FinalPageMessage = value; }
}
private PageCountTemplates _MyTemplates; // (for each page that has this key) private PageCountTemplates _MyTemplates; // (for each page that has this key)
internal PageCountTemplates MyTemplates internal PageCountTemplates MyTemplates
{ {
@@ -53,10 +36,10 @@ namespace Volian.Print.Library
foreach (PageCountTemplate pct in MyTemplates) foreach (PageCountTemplate pct in MyTemplates)
{ {
cnt++; cnt++;
string fstr = pct.Text.Replace("{OF}", _Total.ToString()); string fstr = pct.Text.Replace("{OF}", Total.ToString());
if (pct.Text.Contains("{TOCPAGE}")) if (pct.Text.Contains("{TOCPAGE}"))
{ {
fstr = pct.Text.Replace("{TOCPAGE}", _Total.ToString()); fstr = pct.Text.Replace("{TOCPAGE}", Total.ToString());
} }
if (fstr.Contains("{FINALPAGE}")) if (fstr.Contains("{FINALPAGE}"))
{ {
@@ -140,45 +123,21 @@ namespace Volian.Print.Library
public class PageCountTemplate public class PageCountTemplate
{ {
private string _Text;
public string Text // "Page 1 of {OF}" public string Text // "Page 1 of {OF}"
{ { get; set; }
get { return _Text; } public System.Drawing.Font MyFont { get; set; }
set { _Text = value; } public int Alignment { get; set; }
} public System.Drawing.Color MyColor { get; set; }
private System.Drawing.Font _MyFont; public PdfTemplate MyTemplate { get; set; }
public System.Drawing.Font MyFont
{
get { return _MyFont; }
set { _MyFont = value; }
}
private int _Alignment; // iTextSharp Element.<XYZ>
public int Alignment
{
get { return _Alignment; }
set { _Alignment = value; }
}
private System.Drawing.Color _MyColor;
public System.Drawing.Color MyColor
{
get { return _MyColor; }
set { _MyColor = value; }
}
private PdfTemplate _MyTemplate;
public PdfTemplate MyTemplate
{
get { return _MyTemplate; }
set { _MyTemplate = value; }
}
public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color) public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
{ {
// Create Template can be called with a small, i.e. 1, width/height because when // Create Template can be called with a small, i.e. 1, width/height because when
// it is actually drawn, the bounding box overrides the CreateTemplate values. // it is actually drawn, the bounding box overrides the CreateTemplate values.
_MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1); MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1);
_Text = text; Text = text;
_MyFont = myFont; MyFont = myFont;
_MyColor = color; MyColor = color;
_Alignment = alignment; Alignment = alignment;
} }
} }
public class PageCountTemplates : List<PageCountTemplate> public class PageCountTemplates : List<PageCountTemplate>
+52 -205
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
@@ -10,40 +9,16 @@ namespace Volian.Print.Library
{ {
public partial class vlnParagraph public partial class vlnParagraph
{ {
private string _PageBreakReason = null; public string PageBreakReason { get; set; } = null;
public string PageBreakReason public bool CompressPartOfStep { get; set; } = false;
{ public bool CompressFirstPartOfStep { get; set; } = false;
get { return _PageBreakReason; } public bool BreakHighLevelStepWithSection { get; set; } = false;
set { _PageBreakReason = value; }
}
private bool _CompressPartOfStep = false;
public bool CompressPartOfStep
{
get { return _CompressPartOfStep; }
set { _CompressPartOfStep = value; }
}
private bool _CompressFirstPartOfStep = false;
public bool CompressFirstPartOfStep
{
get { return _CompressFirstPartOfStep; }
set { _CompressFirstPartOfStep = value; }
}
private bool _BreakHighLevelStepWithSection = false;
public bool BreakHighLevelStepWithSection
{
get { return _BreakHighLevelStepWithSection; }
set { _BreakHighLevelStepWithSection = value; }
}
/// <summary> /// <summary>
/// This variable is used to match 16 bit pagination /// This variable is used to match 16 bit pagination
/// </summary> /// </summary>
private bool _Match16BitPagination = false; private readonly bool _Match16BitPagination = false;
private bool _CompressFoldout = false;
public bool CompressFoldout public bool CompressFoldout { get; set; } = false;
{
get { return _CompressFoldout; }
set { _CompressFoldout = value; }
}
/// <summary> /// <summary>
/// Dtermines if the current step is preceded by a Page Break /// Dtermines if the current step is preceded by a Page Break
/// </summary> /// </summary>
@@ -85,8 +60,8 @@ namespace Volian.Print.Library
if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint) if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint)
{ {
int retval = 0; int retval = 0;
SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section // C2018-003 fixed use of getting the active section
if (supInfoSect != null && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID)) if (MyItemInfo.ActiveSection is SectionInfo supInfoSect && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID))
{ {
MyPromsPrinter.SupInfoPdfPageCount++; MyPromsPrinter.SupInfoPdfPageCount++;
retval = 1; retval = 1;
@@ -141,13 +116,12 @@ namespace Volian.Print.Library
if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1; if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1;
// if this is a substep that has a preferredpage break, and it has caution/note that is where the page break had to go // if this is a substep that has a preferredpage break, and it has caution/note that is where the page break had to go
if (MyItemInfo.IsSubStep && ChildrenAbove != null && ChildrenAbove.Count > 0) return 0; if (MyItemInfo.IsSubStep && ChildrenAbove != null && ChildrenAbove.Count > 0) return 0;
// B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the
// ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also.
string reason = "Unknown";
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0]) if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0])
{ {
MyPageHelper.ParaBreaks.RemoveAt(0); MyPageHelper.ParaBreaks.RemoveAt(0);
reason = AddReason("Partial Step - Case 1"); // B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the
// ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also.
string reason = AddReason("Partial Step - Case 1");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
} }
return 2; return 2;
@@ -157,8 +131,8 @@ namespace Volian.Print.Library
// if the EndForSingle format flag is set to false, then we do not print an End message if the section // if the EndForSingle format flag is set to false, then we do not print an End message if the section
// is a single column section. // is a single column section.
//bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
SectionInfo si = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section // C2018-003 fixed use of getting the active section
bool _skipEndMessage = si != null && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; bool _skipEndMessage = MyItemInfo.ActiveSection is SectionInfo si && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
// TODO: This does not account for a long step as the last step that would exceed more than one page and // TODO: This does not account for a long step as the last step that would exceed more than one page and
// that has an end message that needs to be accounted for in determining pagination. To do that the last // that has an end message that needs to be accounted for in determining pagination. To do that the last
@@ -171,7 +145,7 @@ namespace Volian.Print.Library
// line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The // line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The
// procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8. // procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8.
//float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; //float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0;
float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages
// also consider if there is a phone list at the bottom of the page, add the amount of space the phone // also consider if there is a phone list at the bottom of the page, add the amount of space the phone
// list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the // list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the
@@ -196,7 +170,7 @@ namespace Volian.Print.Library
// location of a pagebreak. ParaBreaks contains the paragraphs that break within a step. // location of a pagebreak. ParaBreaks contains the paragraphs that break within a step.
if (MyPageHelper.ParaBreaks.Count > 0) if (MyPageHelper.ParaBreaks.Count > 0)
{ {
string reason = "Unknown"; string reason;
// if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]: // if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]:
if (this == MyPageHelper.ParaBreaks[0]) if (this == MyPageHelper.ParaBreaks[0])
{ {
@@ -230,14 +204,7 @@ namespace Volian.Print.Library
// B2018-065 Calvert's continue message was not including the substep number in AOP-1A Attachment 1, added AERandRNO check // B2018-065 Calvert's continue message was not including the substep number in AOP-1A Attachment 1, added AERandRNO check
else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost >= MyPageHelper.ParaBreaks[0].YTopMost && AERandRNO(this.MyItemInfo, MyPageHelper.ParaBreaks[0].MyItemInfo)) else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost >= MyPageHelper.ParaBreaks[0].YTopMost && AERandRNO(this.MyItemInfo, MyPageHelper.ParaBreaks[0].MyItemInfo))
{ {
//vlnParagraph removed = MyPageHelper.ParaBreaks[0];// 2018-081 Remember where the page break was going to be
MyPageHelper.ParaBreaks.RemoveAt(0); MyPageHelper.ParaBreaks.RemoveAt(0);
//if (MyParent == removed && MyItemInfo.IsRNOPart && MyParent.MyItemInfo.IsHigh)// B2018-081 If The High Level Step was going to break from the High Level RNO
//{
// reason = AddReason("Partial Step - Case 4B");
// ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
// return 0;
//}
reason = AddReason("Partial Step - Case 4"); reason = AddReason("Partial Step - Case 4");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step return 2; // break on this item within a step
@@ -276,9 +243,8 @@ namespace Volian.Print.Library
// flag SectionPageBreak is set to true to flag that a pagebreak should not be done // flag SectionPageBreak is set to true to flag that a pagebreak should not be done
// on that first step. // on that first step.
StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig; StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc == null ? false : sc.Step_ManualPagebreak) : ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc != null && sc.Step_ManualPagebreak) :
sc == null ? false : sc != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc.Step_NewManualPagebreak);
(MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null)? sc.Step_NewManualPagebreak : false;
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (sc != null && sc.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && if (sc != null && sc.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null &&
!MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(firstChild.MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(firstChild.MyItemInfo.ItemID); !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(firstChild.MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(firstChild.MyItemInfo.ItemID);
@@ -290,10 +256,7 @@ namespace Volian.Print.Library
} }
// can the title and the first step fit? // can the title and the first step fit?
// add the first child's size + (the section title's size) // add the first child's size + (the section title's size)
//if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
//if (ySizeIncludingFirst > (yLocation - yBottomMargin) && ySizeIncludingFirst < yPageSize)
vlnParagraph firstStepChild = firstChild; vlnParagraph firstStepChild = firstChild;
//while (firstStepChild.MyItemInfo.IsSection && firstStepChild.ChildrenBelow.Count > 0) firstStepChild = firstStepChild.ChildrenBelow[0];
if (firstStepChild.MyItemInfo.IsNumbered) if (firstStepChild.MyItemInfo.IsNumbered)
while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh)) while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh))
{ {
@@ -308,13 +271,12 @@ namespace Volian.Print.Library
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count - 1]; firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count - 1];
float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost); float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost);
float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess = GetBottomEndMessageSize(MyItemInfo.MyDocStyle); float ySizeBtmEndMess = GetBottomEndMessageSize();
bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > (yWithinMargins - ySizeBtmCtnMess -ySizeBtmEndMess); bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > (yWithinMargins - ySizeBtmCtnMess -ySizeBtmEndMess);
if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild) if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild)
KeepStepsOnPage = false; KeepStepsOnPage = false;
if (ySizeIncludingFirst == YSize) KeepStepsOnPage = false; if (ySizeIncludingFirst == YSize) KeepStepsOnPage = false;
//float ySectionEndMsg = !_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1 && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages
float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0)
{ {
float vpHeight = SixLinesPerInch; float vpHeight = SixLinesPerInch;
@@ -401,11 +363,10 @@ namespace Volian.Print.Library
return 1; return 1;
} }
//MyPageHelper.HLSText = MyItemInfo.DisplayText; // save the High Level Step Text
//Console.WriteLine("{0} Paginate", MyPageHelper.HLSText); //Console.WriteLine("{0} Paginate", MyPageHelper.HLSText);
StepConfig sc1 = MyItemInfo.MyConfig as StepConfig; StepConfig sc1 = MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) : ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 != null && sc1.Step_ManualPagebreak) :
sc1 == null ? false : (MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) ? sc1.Step_NewManualPagebreak : false; sc1 != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc1.Step_NewManualPagebreak);
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (sc1 != null && sc1.Step_NewManualPagebreak && if (sc1 != null && sc1.Step_NewManualPagebreak &&
MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(MyItemInfo.ItemID); MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(MyItemInfo.ItemID);
@@ -423,7 +384,6 @@ namespace Volian.Print.Library
string firstStep = "No"; string firstStep = "No";
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
firstStep = "Yes"; firstStep = "Yes";
//if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
// Pagination Fix - Break1LineShort1 // Pagination Fix - Break1LineShort1
float yExtra = (yWithinMargins == yPageSize ? 0 : SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0; float yExtra = (yWithinMargins == yPageSize ? 0 : SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0;
// Adjust yExtra and mySize for Component List items. // Adjust yExtra and mySize for Component List items.
@@ -452,11 +412,10 @@ namespace Volian.Print.Library
// B2017-254 Fixed Pagination Logic when checking to see if the current item is the last high level step // B2017-254 Fixed Pagination Logic when checking to see if the current item is the last high level step
if (MyItemInfo.IsHigh && mySize >= (2 * SixLinesPerInch) && MyItemInfo.MyDocStyle.Layout.FooterLength > 0 && (MyItemInfo.MyDocStyle.End.Message == null || MyItemInfo.MyDocStyle.End.Message == "") && MyItemInfo.NextItem == null && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0)) if (MyItemInfo.IsHigh && mySize >= (2 * SixLinesPerInch) && MyItemInfo.MyDocStyle.Layout.FooterLength > 0 && (MyItemInfo.MyDocStyle.End.Message == null || MyItemInfo.MyDocStyle.End.Message == "") && MyItemInfo.NextItem == null && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0))
mySize -= SixLinesPerInch; mySize -= SixLinesPerInch;
//// Account for extra lines in the end message (flag < 0)
float adjMsgY = 0;
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page.
{ {
adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch; //// Account for extra lines in the end message (flag < 0)
float adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch;
if (yEndMsg != 0) yEndMsg += adjMsgY; if (yEndMsg != 0) yEndMsg += adjMsgY;
} }
// F2023-015 check if on the first step of a sub-section that starts on its own page (separate pagination) // F2023-015 check if on the first step of a sub-section that starts on its own page (separate pagination)
@@ -489,7 +448,6 @@ namespace Volian.Print.Library
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins,ManualPageBreak); ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins,ManualPageBreak);
return 0; return 0;
} }
// !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
// YSize includes a blank line after the step which we don't want to include in the page break test, thus the // YSize includes a blank line after the step which we don't want to include in the page break test, thus the
// YSize - SixLinesPerInch: // YSize - SixLinesPerInch:
@@ -504,8 +462,6 @@ namespace Volian.Print.Library
if (MyItemInfo.IsStep && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 && if (MyItemInfo.IsStep && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 &&
(MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0)) (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0))
mySize += (2 * SixLinesPerInch); mySize += (2 * SixLinesPerInch);
//if (firstStep == "No")
// ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
if (MyPageHelper.DidFirstPageDocStyle && MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)// C2018-003 fixed use of getting the active section if (MyPageHelper.DidFirstPageDocStyle && MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)// C2018-003 fixed use of getting the active section
yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage();
@@ -532,33 +488,28 @@ namespace Volian.Print.Library
// Keep figure (the only figure, i.e. count==1) with its parent. // Keep figure (the only figure, i.e. count==1) with its parent.
if (ChildrenBelow.Count == 1 && ChildrenBelow[0].MyItemInfo.IsFigure) KeepStepsOnPage = false; if (ChildrenBelow.Count == 1 && ChildrenBelow[0].MyItemInfo.IsFigure) KeepStepsOnPage = false;
float sectionSpace = 0;
if (doSectionTitleContinued) if (doSectionTitleContinued)
{ {
if (SectionShowTitles) if (SectionShowTitles)
{ {
vlnParagraph paraSect = MyParent; vlnParagraph paraSect = MyParent;
while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent; while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent;
float sectionSpace;
if (paraSect.ContinueHeight > 24) if (paraSect.ContinueHeight > 24)
sectionSpace = paraSect.ContinueHeight; sectionSpace = paraSect.ContinueHeight;
else else
sectionSpace = 2 * SixLinesPerInch; sectionSpace = 2 * SixLinesPerInch;
// sectionSpace = 3 * SixLinesPerInch;// this should actuall use the physical size of the continue messsage. // this should actuall use the physical size of the continue messsage.
// Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2 // Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2
//if (MyItemInfo.ActiveSection.DisplayText.Length < 40) sectionSpace = SixLinesPerInch;
yPageSizeNextPage -= sectionSpace; yPageSizeNextPage -= sectionSpace;
yExtra -= sectionSpace; yExtra -= sectionSpace;
//yExtra2 -= sectionSpace; // This was removed for Calvert STP O-73H-2 Section 6.3.O.4 and 6.3.R.3
} }
} }
// Added for section that was breaking from steps this code was removed to fix B2020-112 float mySize7LPI = mySize;
//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && yPageSizeNextPage < yWithinMargins + 3 * 72 && MyItemInfo.MyPrevious == null)
// KeepStepsOnPage = true;
float mySize7LPI = mySize; // +SixLinesPerInch;
if (_Match16BitPagination) mySize7LPI += SixLinesPerInch; if (_Match16BitPagination) mySize7LPI += SixLinesPerInch;
float tableSpaceAvailable = TableSpaceAvailable;// RHM20150525 - Table Scrunch float tableSpaceAvailable = TableSpaceAvailable;// RHM20150525 - Table Scrunch
float ySizeBtmCtnMess1 = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); float ySizeBtmCtnMess1 = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess1 = GetBottomEndMessageSize(MyItemInfo.MyDocStyle); float ySizeBtmEndMess1 = GetBottomEndMessageSize();
// B2017-154 Don't leave an orphan on the next page if the high level step and first sub-step will fit on the current page // B2017-154 Don't leave an orphan on the next page if the high level step and first sub-step will fit on the current page
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.NoOrphans1 && KeepStepsOnPage && ChildrenBelow.Count == 2)// Handle Orphans when there are two sub-steps and only one will fit. if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.NoOrphans1 && KeepStepsOnPage && ChildrenBelow.Count == 2)// Handle Orphans when there are two sub-steps and only one will fit.
{ {
@@ -604,7 +555,6 @@ namespace Volian.Print.Library
// ySize7LPI includes a blank line after the step which we don't want to include in the page break test. // ySize7LPI includes a blank line after the step which we don't want to include in the page break test.
else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps
//&& (mySize7LPI - SixLinesPerInch + yEndMsg - tableSpaceAvailable) < (yPageSizeNextPage * SixLinesPerInch / _SevenLinesPerInch))// RHM20150525 - Table Scrunch
// if this is the first step, then the step has to fit in the space that remains on the page // if this is the first step, then the step has to fit in the space that remains on the page
// otherwise it needs to fit on a blank page // otherwise it needs to fit on a blank page
// This was originally (10/12/2015) added for Farley Shared AOP 79 but was found to be unnecessary // This was originally (10/12/2015) added for Farley Shared AOP 79 but was found to be unnecessary
@@ -631,24 +581,9 @@ namespace Volian.Print.Library
float myFirstPieceSize = GetFirstPieceSize(); //Case 0 float myFirstPieceSize = GetFirstPieceSize(); //Case 0
if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch; if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch;
// TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20. // TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20.
//float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit //Case 10 - this is to match 16bit
//is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2): //is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2):
// VCS EOP-4.3 Step 15 // VCS EOP-4.3 Step 15
// ***** Adjust yWithinMargins for the bottom continue message
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myBottomMsg = docstyle.Continue.Bottom.Message;
//float myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
//switch (docstyle.Continue.Bottom.Location)
//{
// case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
// // The following format flag was added for FNP, without the flag (which stops the reset of BottomMsgSpace)
// // a number of FNP procedures had overwritten steps/bottom continue message. An example can be
// // found in FNP = SAMGS;FNP-1-SACRG-2, step 1.
// if (!docstyle.Continue.Bottom.NoOverrideSpace)
// myBottomMsgSpace = 0;
// break;
//}
//float yWithinMarginsCM = yWithinMargins - myBottomMsgSpace;
//// **** Adjust yWithinMargins for the bottom continue message //// **** Adjust yWithinMargins for the bottom continue message
// B2018-080 Don't break if HLS and High Level RNO each have one line of text and there are substeps (keep single line HSL and High Level RNO with their substeps) AEP AOP Unit 1 016-004 steps 36 & 74 // B2018-080 Don't break if HLS and High Level RNO each have one line of text and there are substeps (keep single line HSL and High Level RNO with their substeps) AEP AOP Unit 1 016-004 steps 36 & 74
// B2018-081 The previous fix caused a different issue // B2018-081 The previous fix caused a different issue
@@ -668,8 +603,6 @@ namespace Volian.Print.Library
ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
//ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//} //}
//else
// ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur //BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
// B2020-027: adjust for lines that may print on first page of section only, added MyPageHelper.PrintedSectionPage // B2020-027: adjust for lines that may print on first page of section only, added MyPageHelper.PrintedSectionPage
// B2020-108: The bug itself was related to keeping a table with its parent. However compression for some pages was // B2020-108: The bug itself was related to keeping a table with its parent. However compression for some pages was
@@ -695,7 +628,6 @@ namespace Volian.Print.Library
// o888o // o888o
if (firstStep == "Yes") if (firstStep == "Yes")
{ {
//ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, CheckForFirstCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); ShowPageBreak(8, CheckForFirstCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
} }
else else
@@ -754,6 +686,7 @@ namespace Volian.Print.Library
ShowPageBreak(3, CheckForFirstCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); ShowPageBreak(3, CheckForFirstCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 1; // Paginate on High Level Steps return 1; // Paginate on High Level Steps
} }
//For Debugging:
//if (yWithinMargins > yPageSize / 2) //if (yWithinMargins > yPageSize / 2)
//{ //{
// Console.WriteLine("'PageBreak',4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); // Console.WriteLine("'PageBreak',4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
@@ -780,7 +713,7 @@ namespace Volian.Print.Library
return hasAER && hasRNO; return hasAER && hasRNO;
} }
// B2018-058 the the end message height accounting for multi-line end messages // B2018-058 the the end message height accounting for multi-line end messages
private float GetEndMessageHeight(DocStyle docstyle) private float GetEndMessageHeight()
{ {
float EndMsgHeight = 0; float EndMsgHeight = 0;
string endmsg = MyItemInfo.MyDocStyle.End.Message ?? ""; string endmsg = MyItemInfo.MyDocStyle.End.Message ?? "";
@@ -791,12 +724,12 @@ namespace Volian.Print.Library
} }
return EndMsgHeight; return EndMsgHeight;
} }
private float GetBottomEndMessageSize(DocStyle docstyle) private float GetBottomEndMessageSize()
{ {
float myBottomMsgSpace = 0; float myBottomMsgSpace = 0;
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page.
{ {
docstyle = MyItemInfo.MyDocStyle; DocStyle docstyle = MyItemInfo.MyDocStyle;
string myBottomMsg = docstyle.End.Message; string myBottomMsg = docstyle.End.Message;
myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
if (myBottomMsg != null && docstyle.End.Flag < 0) myBottomMsgSpace += (-(float)docstyle.End.Flag * SixLinesPerInch); if (myBottomMsg != null && docstyle.End.Flag < 0) myBottomMsgSpace += (-(float)docstyle.End.Flag * SixLinesPerInch);
@@ -806,20 +739,20 @@ namespace Volian.Print.Library
private string CheckForFirstCompression(string reason) private string CheckForFirstCompression(string reason)
{ {
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
return reason + " - 7 LPI"; return $"{reason} - 7 LPI";
return reason; return reason;
} }
private string CheckForCompression(string reason) private string CheckForCompression(string reason)
{ {
if (CompressPartOfStep) if (CompressPartOfStep)
return reason + " - 7 LPI"; return $"{reason} - 7 LPI";
return reason; return reason;
} }
private string AddReason(string prefix) private string AddReason(string prefix)
{ {
string retval = prefix; string retval = prefix;
if (PageBreakReason != null) if (PageBreakReason != null)
retval += " - " + PageBreakReason; retval += $" - {PageBreakReason}";
return retval; return retval;
} }
private bool SectionShowTitles private bool SectionShowTitles
@@ -864,8 +797,6 @@ namespace Volian.Print.Library
DebugText.WriteLine("*****PaginateError"); DebugText.WriteLine("*****PaginateError");
yPageStart = yTopMargin + YVeryTop; yPageStart = yTopMargin + YVeryTop;
yLocation = yPageStart - YOffset; yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
//_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath);
_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'" _MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
if (DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); if (DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath);
@@ -927,10 +858,7 @@ namespace Volian.Print.Library
return _AlternateBreaks; return _AlternateBreaks;
} }
} }
private void AddAlternateBreak(vlnParagraph vp) private void AddAlternateBreak(vlnParagraph vp) => AlternateBreaks.Add(vp);
{
AlternateBreaks.Add(vp);
}
private bool CheckAlternates(vlnParagraph vpBrk) private bool CheckAlternates(vlnParagraph vpBrk)
{ {
if (_AlternateBreaks == null) return false; if (_AlternateBreaks == null) return false;
@@ -957,7 +885,7 @@ namespace Volian.Print.Library
public float yPageSizeForPagination = -1; public float yPageSizeForPagination = -1;
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued, bool onNewPage) private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued, bool onNewPage)
{ {
float topContinueHeight = 2 * SixLinesPerInch; float topContinueHeight; //Defaults to: 2 * SixLinesPerInch;
int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList"); int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList");
// if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents // if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents
// to get each hls/caution/note to be on its own page), then any of the children above should // to get each hls/caution/note to be on its own page), then any of the children above should
@@ -997,9 +925,8 @@ namespace Volian.Print.Library
// the following logic was added to fix Pagination for VCS BDMG1 Step 4 // the following logic was added to fix Pagination for VCS BDMG1 Step 4
if (ChildrenRight.Count > 0 && ChildrenRight[0].YOffset == YOffset) if (ChildrenRight.Count > 0 && ChildrenRight[0].YOffset == YOffset)
{ {
float myFirstPieceRNOSize = 0; float myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize();
myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize(); if (myFirstPieceRNOSize < ySpaceOnCurPage)
if(myFirstPieceRNOSize < ySpaceOnCurPage)
if (ChildrenBelow.Count > 0) if (ChildrenBelow.Count > 0)
{ {
float myFirstPieceAERSize = ChildrenBelow[0].GetFirstPieceSize() + ChildrenBelow[0].YOffset - YOffset; float myFirstPieceAERSize = ChildrenBelow[0].GetFirstPieceSize() + ChildrenBelow[0].YOffset - YOffset;
@@ -1008,7 +935,6 @@ namespace Volian.Print.Library
} }
} }
if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit); if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit);
//while ((YSize - yTop) >= ySpaceOnCurPage)
// Pagination Fix Break1LineShort3b // Pagination Fix Break1LineShort3b
DocStyle docstyle = MyItemInfo.MyDocStyle; DocStyle docstyle = MyItemInfo.MyDocStyle;
float myBottomMsgSpace = GetBottomContinueMessageSize(docstyle); float myBottomMsgSpace = GetBottomContinueMessageSize(docstyle);
@@ -1052,21 +978,12 @@ namespace Volian.Print.Library
// The following code determines space required by the Checklist header (Wolf Creek) if a break occurs // The following code determines space required by the Checklist header (Wolf Creek) if a break occurs
// Their 2 HLS that define the checklists have 'UseSmartTemplate'. // Their 2 HLS that define the checklists have 'UseSmartTemplate'.
float accountForSmartTemplateHeader = 0; float accountForSmartTemplateHeader = 0;
//if (MyItemInfo.InList(878)) Console.WriteLine("Here");
if (MyItemInfo.FormatStepData.UseSmartTemplate) if (MyItemInfo.FormatStepData.UseSmartTemplate)
{ {
if (((MyItemInfo.MyDocStyle.End.Message ?? "") == "") || MyItemInfo.MyHLS.NextItem != null) if (((MyItemInfo.MyDocStyle.End.Message ?? "") == "") || MyItemInfo.MyHLS.NextItem != null)
ySpaceOnCurPage += SixLinesPerInch; ySpaceOnCurPage += SixLinesPerInch;
accountForSmartTemplateHeader = Height - (2 * SixLinesPerInch); accountForSmartTemplateHeader = Height - (2 * SixLinesPerInch);
} }
// This was added so that if a page break was immediately necessary the code would use the current step.
// However, a better solution was found and put in Paginate()
//if (YSize == Height + SixLinesPerInch && YSize + yEndMsg >= ySpaceOnCurPage)
//{
// _MyLog.WarnFormat("Would have been unable to break {0},{1}",MyItemInfo.ItemID, MyItemInfo.ShortPath);
// MyPageHelper.ParaBreaks.Add(this);
// return;
//}
// ooooo ooo . oooooooooo. oooo // ooooo ooo . oooooooooo. oooo
// `888b. `8' .o8 `888' `Y8b `888 // `888b. `8' .o8 `888' `Y8b `888
// 8 `88b. 8 .ooooo. oooo ooo .o888oo 888 888 oooo d8b .ooooo. .oooo. 888 oooo // 8 `88b. 8 .ooooo. oooo ooo .o888oo 888 888 oooo d8b .ooooo. .oooo. 888 oooo
@@ -1170,7 +1087,8 @@ namespace Volian.Print.Library
myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly, yTop); myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly, yTop);
if (paraBreak2 != null && paraBreak != paraBreak2) if (paraBreak2 != null && paraBreak != paraBreak2)
{ {
yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height)); //For Debugging:
//yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height));
if (paraBreak.YOffset == paraBreak2.YOffset + paraBreak2.Height) if (paraBreak.YOffset == paraBreak2.YOffset + paraBreak2.Height)
{ {
//_MyLog.WarnFormat("Fix Break when no blank line {0},{1},{2}", paraBreak2.MyItemInfo.ShortPath, paraBreak2.MyItemInfo.ItemID,yLoc); //_MyLog.WarnFormat("Fix Break when no blank line {0},{1},{2}", paraBreak2.MyItemInfo.ShortPath, paraBreak2.MyItemInfo.ItemID,yLoc);
@@ -1211,10 +1129,7 @@ namespace Volian.Print.Library
} }
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms
{ {
//if (lastBreak != null && lastBreak.MyItemInfo.InList(42656,42923)) Console.WriteLine("here");
// Or Step whose parent fits on a page should break at the parent step // Or Step whose parent fits on a page should break at the parent step
//if (MyItemInfo.InList(119826)) Console.WriteLine("here");
//if (paraBreak.MyItemInfo.InList(40339))
float ySpaceOnNextPage = yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace; float ySpaceOnNextPage = yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace;
if (paraBreak.MyItemInfo.IsOr && paraBreak.MyParent.YSize < ySpaceOnNextPage) if (paraBreak.MyItemInfo.IsOr && paraBreak.MyParent.YSize < ySpaceOnNextPage)
{ {
@@ -1307,7 +1222,8 @@ namespace Volian.Print.Library
if (firstLevel.MyParent.ChildrenBelow != null && firstLevel.MyParent.ChildrenBelow.Count > 0 && firstLevel.MyParent.ChildrenBelow[0] != firstLevel && if (firstLevel.MyParent.ChildrenBelow != null && firstLevel.MyParent.ChildrenBelow.Count > 0 && firstLevel.MyParent.ChildrenBelow[0] != firstLevel &&
firstLevel.YSize < yPageSize - (myTopMsgSpace + SixLinesPerInch)) firstLevel.YSize < yPageSize - (myTopMsgSpace + SixLinesPerInch))
{ {
vlnParagraph firstLevel1 = firstLevel; //For Debugging:
//vlnParagraph firstLevel1 = firstLevel;
if (firstLevel.ChildrenAbove != null && firstLevel.ChildrenAbove.Count > 0) // If the aerParent has caution or note if (firstLevel.ChildrenAbove != null && firstLevel.ChildrenAbove.Count > 0) // If the aerParent has caution or note
firstLevel = firstLevel.ChildrenAbove[0];//, break on the caution or note. firstLevel = firstLevel.ChildrenAbove[0];//, break on the caution or note.
if (firstLevel != lastBreak && paraBreak != firstLevel) if (firstLevel != lastBreak && paraBreak != firstLevel)
@@ -1320,14 +1236,10 @@ namespace Volian.Print.Library
} }
// If the break is going to happen on a table, and the tables parent would fit on a page with the table // If the break is going to happen on a table, and the tables parent would fit on a page with the table
// and the text in the parent includes the word table, then break on the parent // and the text in the parent includes the word table, then break on the parent
//if (lastBreak != paraBreak.MyParent && paraBreak.MyItemInfo.IsTable && paraBreak.YSize < ySpaceOnCurPage && paraBreak.MyParent.MyItemInfo.DisplayText.ToUpper().Contains("TABLE"))
// paraBreak = paraBreak.MyParent;
//paraBreak.ShowPageBreak(999, paraBreak.MyItemInfo.ShortPath, "Yes",paraBreak.YTop, paraBreak.YSize, paraBreak.Height, false); //paraBreak.ShowPageBreak(999, paraBreak.MyItemInfo.ShortPath, "Yes",paraBreak.YTop, paraBreak.YSize, paraBreak.Height, false);
//_MyLog.InfoFormat("Place to break\r\n==>'Place to Break',{0},'{1}','{2}'" //_MyLog.InfoFormat("Place to break\r\n==>'Place to Break',{0},'{1}','{2}'"
//, paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.MyDocVersion.MyFolder.Name, paraBreak.MyItemInfo.ShortPath); //, paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.MyDocVersion.MyFolder.Name, paraBreak.MyItemInfo.ShortPath);
// yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc // yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc
//float yTopNew = paraBreak.YVeryTop - YTopMost;
//float yTopNew = paraBreak.YTopMost - YTopMost;
if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg))) if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg)))
paraBreak = paraBreak.ChildrenBelow[0]; paraBreak = paraBreak.ChildrenBelow[0];
// B2020-112: complicated AER/RNO. yEndMsg was accounted for twice -> put endmsg part back in, it broke wcn and didn't affect bge // B2020-112: complicated AER/RNO. yEndMsg was accounted for twice -> put endmsg part back in, it broke wcn and didn't affect bge
@@ -1412,14 +1324,6 @@ namespace Volian.Print.Library
PageBreakOnStepList.RemoveAt(0); PageBreakOnStepList.RemoveAt(0);
yTopNew = paraBreak.YTop - YTopMost; yTopNew = paraBreak.YTop - YTopMost;
} }
// The following code caused forced pagination for Catawba EOP BG - EP/1/A/5000/FR-C.1.SC..S16..N2..S4..S1.
//else if(PageBreakOnStepList[0].YSize - yTop <= ySpaceOnCurPage)
//{
// DebugPagination.WriteLine("======>>>>> Other Condition");
// paraBreak = PageBreakOnStepList[0];
// PageBreakOnStepList.RemoveAt(0);
// yTopNew = paraBreak.YTop - YTopMost;
//}
} }
RemoveProcessedParagraphs(myList, yTopNew - yTop); RemoveProcessedParagraphs(myList, yTopNew - yTop);
yTop = yTopNew; yTop = yTopNew;
@@ -1440,13 +1344,6 @@ namespace Volian.Print.Library
// B2017-252 Pagination Fix - RNP was not paginating correctly. Added logic to set ySPaceOnCurPage if ySpaceOnNextPage was larger // B2017-252 Pagination Fix - RNP was not paginating correctly. Added logic to set ySPaceOnCurPage if ySpaceOnNextPage was larger
if (!usedPageBreakOnStepList || ySpaceOnNextPage1 > ySpaceOnCurPage) ySpaceOnCurPage = ySpaceOnNextPage1; if (!usedPageBreakOnStepList || ySpaceOnNextPage1 > ySpaceOnCurPage) ySpaceOnCurPage = ySpaceOnNextPage1;
//ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
//if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null)
// ySpaceOnCurPage = yPageSize;
//ySpaceOnCurPage = yPageSize; // Allow for continue message and blank line.
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myMsg = docstyle.Continue.Bottom.Message;
//if ((myMsg ?? "") != "") ySpaceOnCurPage -= 2 * SixLinesPerInch; // Allow for continue message and blank line.
yLowerLimit = ySpaceOnCurPage / 2; yLowerLimit = ySpaceOnCurPage / 2;
if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP
yStart = 0; yStart = 0;
@@ -1505,7 +1402,6 @@ namespace Volian.Print.Library
{ {
// C2023-015: Pagination on a sub-step added. Do the code if supplemental info or if format supports sub-step pagination // C2023-015: Pagination on a sub-step added. Do the code if supplemental info or if format supports sub-step pagination
// C2023-018: Remove the supplemental info & alarm check, doing the possible page breaks on sub-steps // C2023-018: Remove the supplemental info & alarm check, doing the possible page breaks on sub-steps
//if (!MyItemInfo.MyDocStyle.SupplementalInformation && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AlarmPagination) return null;
SortedList<float, vlnParagraph> sdpara = null; SortedList<float, vlnParagraph> sdpara = null;
foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest.
{ {
@@ -1534,8 +1430,7 @@ namespace Volian.Print.Library
private float GetBottomContinueMessageSize(DocStyle docstyle) private float GetBottomContinueMessageSize(DocStyle docstyle)
{ {
float myBottomMsgSpace = 0; float myBottomMsgSpace;
docstyle = MyItemInfo.MyDocStyle;
string myBottomMsg = docstyle.Continue.Bottom.Message; string myBottomMsg = docstyle.Continue.Bottom.Message;
myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
if (myBottomMsg != null && myBottomMsg.Contains("par")) myBottomMsgSpace += SixLinesPerInch; if (myBottomMsg != null && myBottomMsg.Contains("par")) myBottomMsgSpace += SixLinesPerInch;
@@ -1603,7 +1498,7 @@ namespace Volian.Print.Library
float? yLocationMin=null; float? yLocationMin=null;
vlnParagraph minPara2 = null; vlnParagraph minPara2 = null;
float? yLocationMin2=null; float? yLocationMin2=null;
float yAddForBtmMsg = 0; float yAddForBtmMsg;
// useful for debugging pagination issues, lastbreak gets the paragraph at the top of the previous page, shows all // useful for debugging pagination issues, lastbreak gets the paragraph at the top of the previous page, shows all
// of the locations within 'range' on the next page. // of the locations within 'range' on the next page.
//if (lastBreak != null && lastBreak.MyItemInfo.InList(72481)) //if (lastBreak != null && lastBreak.MyItemInfo.InList(72481))
@@ -1670,16 +1565,9 @@ namespace Volian.Print.Library
// Note that this bug fix for WCN was commented out. Harry Julian wanted this on 11/15/19. A new bug will be written for the WCN error. // Note that this bug fix for WCN was commented out. Harry Julian wanted this on 11/15/19. A new bug will be written for the WCN error.
// B2019-173 reintroduced the 'IsHigh' portion and added IsRNOPart, the HLS & RNOPart print at same location on page so code needs // B2019-173 reintroduced the 'IsHigh' portion and added IsRNOPart, the HLS & RNOPart print at same location on page so code needs
// to account for either. second iteration of this fix removed IsRNOPart (see code in Paginate) // to account for either. second iteration of this fix removed IsRNOPart (see code in Paginate)
&& !myParent.MyItemInfo.IsHigh) /*|| myPara.MyItemInfo.IsRNOPart)) */// B2018-104: don't return if my parent is a high level - a top continue message was printing && !myParent.MyItemInfo.IsHigh) // B2018-104: don't return if my parent is a high level - a top continue message was printing
{ {
//_MyLog.WarnFormat("\r\nMyParentBreak {0},{1},{2},{3},{4}", myParent, myParent.YSize, yUpperLimit, myParent.ChildrenRight[0].YSize, spaceOnPage); //_MyLog.WarnFormat("\r\nMyParentBreak {0},{1},{2},{3},{4}", myParent, myParent.YSize, yUpperLimit, myParent.ChildrenRight[0].YSize, spaceOnPage);
// Removed the following and moved logic to Paginate method for the second iteration of the bug fix. This code below AND the IsRNOPart above caused another
// pagination problem. The insert and subsequent removal of this code are both done under bug B22019-173.
// Initial code for B2019-173: make minPara2 the first step on next page
//if (minPara2 != null && minPara2.MyParent == myParent && minPara2 != lastBreak && minPara2.MyItemInfo.Ordinal == 1)
//{
// return minPara2;
//}
if (myParent != lastBreak) if (myParent != lastBreak)
return myParent; return myParent;
} }
@@ -1736,17 +1624,11 @@ namespace Volian.Print.Library
} }
} }
} }
//while (myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent;
while (myPara.MyParent != null && myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent; while (myPara.MyParent != null && myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent;
int everyNLines = myPara.MyItemInfo.MyPrevious != null && myPara.MyItemInfo.FormatStepData == null ? 1 : myPara.MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1; int everyNLines = myPara.MyItemInfo.MyPrevious != null && myPara.MyItemInfo.FormatStepData == null ? 1 : myPara.MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
bool inSameBox = InSameBox(myPara, minPara2); // if this note/caution is in same box as the break, don't break within the notes/cautions in the same box bool inSameBox = InSameBox(myPara, minPara2); // if this note/caution is in same box as the break, don't break within the notes/cautions in the same box
if (!inSameBox && myPara.ChildrenAbove.Count == 0 && wcnChkLstBorder - yLocation < yUpperLimit + yAddForBtmMsg || (everyNLines != 99 && (wcnChkLstBorder - yLocation == yUpperLimit + yAddForBtmMsg))) // Fix for OFN-RJ-23 if (!inSameBox && myPara.ChildrenAbove.Count == 0 && wcnChkLstBorder - yLocation < yUpperLimit + yAddForBtmMsg || (everyNLines != 99 && (wcnChkLstBorder - yLocation == yUpperLimit + yAddForBtmMsg))) // Fix for OFN-RJ-23
//if (-yLocation < yUpperLimit) // Before
//if (-yLocation < yWithinMargins && myList[stepLevel][yLocation].MyItemInfo.MyPrevious != null)
{ {
//ItemInfo prev = myList[stepLevel][yLocation].MyItemInfo.MyPrevious;
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5609) Console.WriteLine("aer");
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 4312) Console.WriteLine("rno");
// The top of this step is more than 1/2 way down the page // The top of this step is more than 1/2 way down the page
if ((-yLocation + yStart) >= yLowerLimit) if ((-yLocation + yStart) >= yLowerLimit)
if (myPara != lastBreak) if (myPara != lastBreak)
@@ -1825,6 +1707,7 @@ namespace Volian.Print.Library
// B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1. // B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1.
// B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15 // B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15
// B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c // B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping myList and stepLevel for Debugging")]
private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop) private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop)
{ {
// B2020-120: for calvert alarms/condition response table, don't run code for second rno // B2020-120: for calvert alarms/condition response table, don't run code for second rno
@@ -1856,12 +1739,6 @@ namespace Volian.Print.Library
if ((chld.YTopMost + yStart + yTop - yTopParent) < yUpperLimit) if ((chld.YTopMost + yStart + yTop - yTopParent) < yUpperLimit)
return chld; // second RNO will fit, use this instead of myPara return chld; // second RNO will fit, use this instead of myPara
// check to see if there is AER substep children that would be split if we pagination on the RNO
// B2020-150 commented out below. Found it is not needed for B2020-085 fix but it was what cause B2020-150
//foreach (vlnParagraph chld in parent.ChildrenBelow)
// if (chld.YOffset < this.YOffset && YBottomMostExcludingRNO(chld) > this.YTopMost) // B2020-085 Does AER child start before myPara and length greater than myPara start
// return null; // the AER text positioning overlaps the RNO text positioning (caused AER sub-steps to be split onto next page (i.e. RO step) have pagination logic keep looking for place to break
return this; // current myPara is good return this; // current myPara is good
} }
@@ -1903,6 +1780,7 @@ namespace Volian.Print.Library
} }
return false; return false;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping yLocation for Debugging")]
private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak) private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak)
{ {
foreach (int stepLevel in myList.Keys) foreach (int stepLevel in myList.Keys)
@@ -1935,27 +1813,7 @@ namespace Volian.Print.Library
if (MyParent == null || MyParent.MyItemInfo.IsHigh) return false; if (MyParent == null || MyParent.MyItemInfo.IsHigh) return false;
return MyParent.HasAncestor(myParaBreak); return MyParent.HasAncestor(myParaBreak);
} }
//private void WalkStepLevel(float yTopMost)
//{
// foreach (vlnParagraph child in ChildrenAbove)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenLeft)
// child.WalkStepLevel(yTopMost);
// ShowStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenRight)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenBelow)
// child.WalkStepLevel(yTopMost);
//}
//private void ShowStepLevel(float yTopMost)
//{
// ItemInfo item = MyItemInfo;
// ItemInfo parent = item.ActiveParent as ItemInfo;
// //if (para.MyItemInfo.ItemID == 205)
// // Console.Write("");
// DebugPagination.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
// parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
//}
public float TableSpaceAvailable// RHM20150525 - Table Scrunch public float TableSpaceAvailable// RHM20150525 - Table Scrunch
{ {
get // B2019-111 Keep AER Table with parent when RNO extends past the end of the page. get // B2019-111 Keep AER Table with parent when RNO extends past the end of the page.
@@ -1992,18 +1850,7 @@ namespace Volian.Print.Library
} }
public partial class VlnSvgPageHelper : SvgPageHelper public partial class VlnSvgPageHelper : SvgPageHelper
{ {
private bool _OriginalPageBreak; // use 16bit page breaks. public bool OriginalPageBreak { get; set; }
public bool OriginalPageBreak public List<vlnParagraph> ParaBreaks { get; set; } = new List<vlnParagraph>();
{
get { return _OriginalPageBreak; }
set { _OriginalPageBreak = value; }
}
// This handles Page Breaks within a Step
private List<vlnParagraph> _ParaBreaks = new List<vlnParagraph>();
public List<vlnParagraph> ParaBreaks
{
get { return _ParaBreaks; }
set { _ParaBreaks = value; }
}
} }
} }
+10 -59
View File
@@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using LBWordLibrary; using LBWordLibrary;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -10,12 +7,12 @@ namespace Volian.Print.Library
{ {
public class Placekeeper : IDisposable public class Placekeeper : IDisposable
{ {
private LBApplicationClass _WordApp; private readonly LBApplicationClass _WordApp;
private LBDocumentClass _WordDoc; private readonly LBDocumentClass _WordDoc;
private LBSelection _WordSel; private readonly LBSelection _WordSel;
private LBTable _WordTbl; private LBTable _WordTbl;
private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
private VE_Font _pkFont; private readonly VE_Font _pkFont;
public Placekeeper() public Placekeeper()
{ {
_WordApp = new LBApplicationClass(); _WordApp = new LBApplicationClass();
@@ -28,37 +25,11 @@ namespace Volian.Print.Library
_WordApp.Visible = true; _WordApp.Visible = true;
_WordApp.Activate(); _WordApp.Activate();
} }
//public Placekeeper(pkParagraph myPlacekeeper)
//{
// _WordApp = new LBApplicationClass();
// _WordDoc = _WordApp.Documents.Add();
// _WordSel = _WordApp.Selection;
// _WordApp.Visible = true;
// AddTable();
// AddHeader();
// AddSectionHeader(myPlacekeeper.MyParagraph.MyItemInfo.DisplayNumber, myPlacekeeper.MyParagraph.MyItemInfo.DisplayText);
// foreach (pkParagraph pgh in myPlacekeeper.MyChildren)
// {
// AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.DisplayText, pgh.MyParagraph.MyItemInfo.FormatStepType==9 ? "C" : "", pgh.MyParagraph.MyItemInfo.PageNumber.ToString());
// if (pgh.MyChildren.Count > 0)
// {
// StartSubStep();
// foreach (pkParagraph cpgh in pgh.MyChildren)
// {
// ContinueSubStep(cpgh.MyParagraph.MyItemInfo.DisplayText, 1);
// foreach (pkParagraph ccpgh in cpgh.MyChildren)
// ContinueSubStep(ccpgh.MyParagraph.MyItemInfo.DisplayText, 2);
// }
// FinishSubstep("", "");
// }
// }
//}
public Placekeeper(pkParagraphs myPlacekeepers, VE_Font pkFont) public Placekeeper(pkParagraphs myPlacekeepers, VE_Font pkFont)
{ {
_WordApp = new LBApplicationClass(); _WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add(); _WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection; _WordSel = _WordApp.Selection;
//_WordApp.Visible = true;
_pkFont = pkFont; _pkFont = pkFont;
AddTable(); AddTable();
AddHeader(); AddHeader();
@@ -97,7 +68,7 @@ namespace Volian.Print.Library
if (cpgh.MyCautionsAndNotes.Count > 0) if (cpgh.MyCautionsAndNotes.Count > 0)
AddNotesOrCautions(cpgh,level, ref conAct); AddNotesOrCautions(cpgh,level, ref conAct);
if (!conAct) if (!conAct)
conAct = IsContinuousActionPlacekeeper(conAct, cpgh); conAct = IsContinuousActionPlacekeeper(cpgh);
ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level); ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level);
AddChildren(cpgh, level+1, ref conAct); AddChildren(cpgh, level+1, ref conAct);
} }
@@ -108,17 +79,12 @@ namespace Volian.Print.Library
foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes) foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes)
{ {
if (!conAct) if (!conAct)
conAct = IsContinuousActionPlacekeeper(conAct, cpgh); conAct = IsContinuousActionPlacekeeper(cpgh);
ContinueNoteOrCaution(cpgh.MyParagraph.MyItemInfo, level); ContinueNoteOrCaution(cpgh.MyParagraph.MyItemInfo, level);
} }
} }
private static bool IsContinuousActionPlacekeeper(bool conAct, pkParagraph pkPar) private static bool IsContinuousActionPlacekeeper(pkParagraph pkPar) => (pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig).Step_Placekeeper.ToUpper() == "C";
{
StepConfig sc = pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig;
conAct = (sc.Step_Placekeeper.ToUpper() == "C");
return conAct;
}
private void ContinueNoteOrCaution(ItemInfo ii, int level) private void ContinueNoteOrCaution(ItemInfo ii, int level)
{ {
@@ -176,22 +142,17 @@ namespace Volian.Print.Library
_WordTbl.TopPadding = 6F; _WordTbl.TopPadding = 6F;
_WordTbl.BottomPadding = 6F; _WordTbl.BottomPadding = 6F;
LBColumn col = _WordTbl.Columns.First; LBColumn col = _WordTbl.Columns.First;
//col.SetWidth(12F, LBWdRulerStyle.wdAdjustNone);
//col = col.Next;
col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone);
col = col.Next; col = col.Next;
col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone);
col = col.Next; col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
col = col.Next; col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
_WordTbl.Rows.AllowBreakAcrossPages = 0; _WordTbl.Rows.AllowBreakAcrossPages = 0;
} }
private void AddHeader() private void AddHeader()
{ {
//Advance();
WriteCell("START", true, true); WriteCell("START", true, true);
SetIndent(0.32F, -0F); SetIndent(0.32F, -0F);
WriteCell("FUNCTION", true, true); WriteCell("FUNCTION", true, true);
@@ -219,7 +180,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(_pkFont.Family, (float)_pkFont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(_pkFont.Family, (float)_pkFont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(_pkFont.Family, (float)_pkFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = 0; float w = 0;
@@ -227,8 +187,6 @@ namespace Volian.Print.Library
{ {
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)_pkFont.Size); w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)_pkFont.Size);
} }
// indented text didn't always line up doing it this way
//float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)_pkFont.Size);
return w; return w;
} }
private void AddHighLevelStep(string number, string text, string done, string page) private void AddHighLevelStep(string number, string text, string done, string page)
@@ -276,7 +234,6 @@ namespace Volian.Print.Library
{ {
Advance(2); Advance(2);
SetIndent(.64F, -.31F); SetIndent(.64F, -.31F);
//_WordSel.InsertSymbol(8226, _WordSel.Font, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
WriteCell("\u2022" + "\t" + text, false, true); WriteCell("\u2022" + "\t" + text, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom); SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true); WriteCell(done, false, true);
@@ -316,7 +273,7 @@ namespace Volian.Print.Library
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom); SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false); WriteCell(page, false, false);
} }
static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
private void WriteRTF(string text) private void WriteRTF(string text)
{ {
//if (text.Contains("\\")) //if (text.Contains("\\"))
@@ -381,13 +338,7 @@ namespace Volian.Print.Library
{ {
_WordSel.MoveRight(LBWdUnits.wdCell, count, false); _WordSel.MoveRight(LBWdUnits.wdCell, count, false);
} }
private void Advance() private void Advance() => Advance(1);
{ public void Dispose() => _WordApp.Quit(false);
Advance(1);
}
public void Dispose()
{
_WordApp.Quit(false);
}
} }
} }
File diff suppressed because it is too large Load Diff
+31 -97
View File
@@ -1,12 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf; using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support; using Itenso.Rtf.Support;
using System.IO; using System.IO;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -37,24 +32,14 @@ namespace Volian.Print.Library
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
private string _Rtf;
public string Rtf public string Rtf { get; set; }
{
get { return _Rtf; }
set { _Rtf = value; }
}
private string _FileName;
public string FileName public string FileName { get; set; }
{
get { return _FileName; }
set { _FileName = value; }
}
public Rtf2Pdf(string rtf, string fileName) public Rtf2Pdf(string rtf, string fileName)
{ {
_Rtf = rtf; Rtf = rtf;
_FileName = fileName; FileName = fileName;
} }
public void Process() public void Process()
{ {
@@ -83,66 +68,30 @@ namespace Volian.Print.Library
yTop = newYTop; yTop = newYTop;
} }
} }
private static string _PaperSize = "LETTER"; // default paper size
public static string PaperSize // C2020-002 paper size is now set in the format files public static string PaperSize // C2020-002 paper size is now set in the format files
{ { get; set; } = "LETTER";
get { return Rtf2Pdf._PaperSize; } public Rectangle PaperSizeRec => PDFPageSize.UsePaperSize(PaperSize); // default paper size = PageSize.LETTER
set { Rtf2Pdf._PaperSize = value; }
} public static bool PdfDebug { get; set; } = true;
private Rectangle _PaperSizeRec = PageSize.LETTER; // default paper size
public Rectangle PaperSizeRec
{
get { return PDFPageSize.UsePaperSize(PaperSize); }
}
private static bool _PdfDebug = true;
public static bool PdfDebug
{
get { return Rtf2Pdf._PdfDebug; }
set { Rtf2Pdf._PdfDebug = value; }
}
private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0); private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0);
public static System.Drawing.PointF Offset public static System.Drawing.PointF Offset
{ {
get { return Rtf2Pdf._Offset; } get { return _Offset; }
set { Rtf2Pdf._Offset = value; } set { _Offset = value; }
} }
public static float FillWidth = 0; // max text width (used in autoToc code) public static float FillWidth = 0; // max text width (used in autoToc code)
private static int _TextAtCounter = 0;
public static int TextAtCounter public static int TextAtCounter { get; set; } = 0;
{ private static int NextTextAtCounter => ++TextAtCounter;
get { return Rtf2Pdf._TextAtCounter; }
set { Rtf2Pdf._TextAtCounter = value; }
}
private static int NextTextAtCounter
{
get
{
int retval = ++TextAtCounter;
//if (InList(retval, 17)) Console.WriteLine("TextAt {0}", retval);
return retval;
}
}
public class VlnSplitCharacter : ISplitCharacter public class VlnSplitCharacter : ISplitCharacter
{ {
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
{ public bool IsSplitCharacter(char c) => (c == ' ');
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
private static TableScrunching _AllowTableScrunching = TableScrunching.AllPhases; // RHM20150507 Table Scrunch
public static TableScrunching AllowTableScrunching
{
get { return Rtf2Pdf._AllowTableScrunching; }
set { Rtf2Pdf._AllowTableScrunching = value; }
}
public static bool GetTableScrunchingStatus(TableScrunching val)
{
return (val & _AllowTableScrunching) == val;
} }
public static TableScrunching AllowTableScrunching { get; set; } = TableScrunching.AllPhases;
public static bool GetTableScrunchingStatus(TableScrunching val) => (val & AllowTableScrunching) == val;
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
public static string ChunkTextAttributesInfo(Chunk chk1) // C2018-004 create meta file for baseline compares public static string ChunkTextAttributesInfo(Chunk chk1) // C2018-004 create meta file for baseline compares
{ {
@@ -180,10 +129,7 @@ namespace Volian.Print.Library
return rtnval; return rtnval;
} }
public static int _lastPageNum = 0; // C2018-004 create meta file for baseline compares public static int _lastPageNum = 0; // C2018-004 create meta file for baseline compares
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) => TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null);
{
return TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null);
}
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID) public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID)
{ {
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
@@ -192,7 +138,7 @@ namespace Volian.Print.Library
_lastPageNum = cb.PdfDocument.PageNumber; _lastPageNum = cb.PdfDocument.PageNumber;
} }
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; PdfLayer textLayer = _MyPageHelper?.TextLayer;
float left = x + Offset.X; float left = x + Offset.X;
float top = y + Offset.Y; float top = y + Offset.Y;
// B2020-059 - Barakah 1T4-OP-EOP-AC-0001 Instructions and Contingency Actions section step 6 last table in RNO is compressed - cause first bullet substep in AER to print on top HLS text // B2020-059 - Barakah 1T4-OP-EOP-AC-0001 Instructions and Contingency Actions section step 6 last table in RNO is compressed - cause first bullet substep in AER to print on top HLS text
@@ -224,8 +170,6 @@ namespace Volian.Print.Library
chk.Attributes.Add("NoSplit", false); chk.Attributes.Add("NoSplit", false);
} }
} }
float right = left + width;
float bottom = top - height;
ColumnText myColumnText = new ColumnText(cb); ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin);
myColumnText.AddElement(iParagraph); myColumnText.AddElement(iParagraph);
@@ -259,21 +203,21 @@ namespace Volian.Print.Library
} }
return myColumnText.YLine; return myColumnText.YLine;
} }
//For Debugging:
private static bool InList(int value, params int [] examples) private static bool InList(int value, params int [] examples)
{ {
foreach (int ex in examples) foreach (int ex in examples)
if (ex == value) return true; if (ex == value) return true;
return false; return false;
} }
public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, float yBottommargin, bool hasBorder, int itmID, float sixLinesPerInch) public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, bool hasBorder, int itmID, float sixLinesPerInch)
{ {
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
{ {
Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber); Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber);
_lastPageNum = cb.PdfDocument.PageNumber; _lastPageNum = cb.PdfDocument.PageNumber;
} }
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
float left = x + Offset.X; float left = x + Offset.X;
float top = y + Offset.Y + sixLinesPerInch; float top = y + Offset.Y + sixLinesPerInch;
float bottom = top - height; float bottom = top - height;
@@ -309,12 +253,9 @@ namespace Volian.Print.Library
return bottom; return bottom;
} }
private static float _GridTopAdjust = -10;
public static float GridTopAdjust public static float GridTopAdjust { get; set; } = -10;
{ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "debugText Kept For Debugging")]
get { return _GridTopAdjust; }
set { _GridTopAdjust = value; }
}
public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder) public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder)
{ {
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
@@ -322,8 +263,6 @@ namespace Volian.Print.Library
Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber); Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber);
_lastPageNum = cb.PdfDocument.PageNumber; _lastPageNum = cb.PdfDocument.PageNumber;
} }
//VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; // RHM20150507 Table Scrunch
//PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; // RHM20150507 Table Scrunch
float left = x + Offset.X; float left = x + Offset.X;
float top = y + Offset.Y; float top = y + Offset.Y;
float right = left + width; float right = left + width;
@@ -331,7 +270,6 @@ namespace Volian.Print.Library
int paperSizePoints = PDFPageSize.PaperSizePoints(myGrid.MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files int paperSizePoints = PDFPageSize.PaperSizePoints(myGrid.MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files
ColumnText myColumnText = new ColumnText(cb); ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin);
//if (textLayer != null) cb.BeginLayer(textLayer); // RHM20150507 Table Scrunch
// C2018-004 create meta file for baseline compares // C2018-004 create meta file for baseline compares
if (top + GridTopAdjust > paperSizePoints) // B2019-110 Table continued on the next page - off the top of page if (top + GridTopAdjust > paperSizePoints) // B2019-110 Table continued on the next page - off the top of page
{ {
@@ -340,13 +278,11 @@ namespace Volian.Print.Library
} }
Volian.Base.Library.BaselineMetaFile.WriteLine("GD left={0} top={1} right={2} bottom={3} Mygrid.ItmID={4}", left, top + GridTopAdjust, right, bottom, myGrid.ItemID); Volian.Base.Library.BaselineMetaFile.WriteLine("GD left={0} top={1} right={2} bottom={3} Mygrid.ItmID={4}", left, top + GridTopAdjust, right, bottom, myGrid.ItemID);
myGrid.ToPdf(myColumnText, left, top + GridTopAdjust); myGrid.ToPdf(myColumnText, left, top + GridTopAdjust);
//if (textLayer != null) cb.EndLayer(); // RHM20150507 Table Scrunch
return bottom; return bottom;
} }
internal static void DrawPdfDebug(PdfContentByte cb, float left, float top, float right, float bottom, string debugText, float yDescent) internal static void DrawPdfDebug(PdfContentByte cb, float left, float top, float right, float bottom, string debugText, float yDescent)
{ {
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return; if (debugLayer == null) return;
System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray);
cb.SaveState(); cb.SaveState();
@@ -374,18 +310,16 @@ namespace Volian.Print.Library
cb.RestoreState(); cb.RestoreState();
} }
internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, float yBottomMargin, bool hasBorder) internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, bool hasBorder)
{ {
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
float left = XOffset + Offset.X; float left = XOffset + Offset.X;
float top = yLocation + Offset.Y; float top = yLocation + Offset.Y;
float bottom = top - Height; float bottom = top - Height;
float scale = .6f; float scale = .6f;
iTextSharp.text.Image it_image=null;
try try
{ {
it_image = iTextSharp.text.Image.GetInstance(image,iTextSharp.text.Color.WHITE); iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(image, iTextSharp.text.Color.WHITE);
float itxtWid = scale * Width * 300 / 72; float itxtWid = scale * Width * 300 / 72;
float itxtHt = scale * Height * 300 / 72; float itxtHt = scale * Height * 300 / 72;
it_image.ScaleAbsoluteWidth(scale * Width); it_image.ScaleAbsoluteWidth(scale * Width);
+39 -96
View File
@@ -1,18 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf; using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
//using Itenso.Rtf.Model;
using Itenso.Rtf.Support; using Itenso.Rtf.Support;
using Microsoft.Win32;
using Volian.Base.Library; using Volian.Base.Library;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using System.Linq;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
@@ -21,17 +16,13 @@ namespace Volian.Print.Library
public static bool CompressSub = false; public static bool CompressSub = false;
public static bool CompressSuper = false; public static bool CompressSuper = false;
public static bool CompressPropSubSup = false; public static bool CompressPropSubSup = false;
private static System.Drawing.Color _TextColor = System.Drawing.Color.Empty;
public static System.Drawing.Color TextColor public static System.Drawing.Color TextColor { get; set; } = System.Drawing.Color.Empty;
{
get { return _TextColor; }
set { _TextColor = value; }
}
public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color) public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color)
{ {
if (_TextColor == System.Drawing.Color.Empty) if (TextColor == System.Drawing.Color.Empty)
return color; return color;
return _TextColor; return TextColor;
} }
private static System.Drawing.Color _SvgColor = System.Drawing.Color.Empty; private static System.Drawing.Color _SvgColor = System.Drawing.Color.Empty;
public static System.Drawing.Color SvgColor public static System.Drawing.Color SvgColor
@@ -45,29 +36,21 @@ namespace Volian.Print.Library
return color; return color;
return _SvgColor; return _SvgColor;
} }
private static System.Drawing.Color _BoxColor = System.Drawing.Color.Empty;
public static System.Drawing.Color BoxColor public static System.Drawing.Color BoxColor { get; set; } = System.Drawing.Color.Empty;
{
get { return _BoxColor; }
set { _BoxColor = value; }
}
public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color) public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color)
{ {
if (_BoxColor == System.Drawing.Color.Empty) if (BoxColor == System.Drawing.Color.Empty)
return color; return color;
return _BoxColor; return BoxColor;
}
private static System.Drawing.Color _ChangeBarColor = System.Drawing.Color.Empty;
public static System.Drawing.Color ChangeBarColor
{
get { return _ChangeBarColor; }
set { _ChangeBarColor = value; }
} }
public static System.Drawing.Color ChangeBarColor { get; set; } = System.Drawing.Color.Empty;
public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color) public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color)
{ {
if (_ChangeBarColor == System.Drawing.Color.Empty) if (ChangeBarColor == System.Drawing.Color.Empty)
return color; return color;
return _ChangeBarColor; return ChangeBarColor;
} }
private static System.Drawing.Color _DebugColor = System.Drawing.Color.Empty; private static System.Drawing.Color _DebugColor = System.Drawing.Color.Empty;
public static System.Drawing.Color DebugColor public static System.Drawing.Color DebugColor
@@ -93,42 +76,16 @@ namespace Volian.Print.Library
public class Rtf2iTextSharp : RtfVisualVisitorBase public class Rtf2iTextSharp : RtfVisualVisitorBase
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool _HasIndent = false;
public bool HasIndent public bool HasIndent { get; set; } = false;
{ private readonly IRtfDocument _RtfDoc;
get { return _HasIndent; } private readonly Paragraph _MyParagraph = new Paragraph();
set { _HasIndent = value; }
}
private IRtfDocument _RtfDoc;
private Paragraph _MyParagraph = new Paragraph();
private iTextSharp.text.Font _MyFont; private iTextSharp.text.Font _MyFont;
// Allow for definition of a default font: if the font is not proportional, this gets set. public iTextSharp.text.Font DefaultFont { get; set; }
// It is needed to set the chunk's font if the first character of a cell is a hardspace (or various public string MyDebugID { get; set; } = null;
// other special cases (see its use below). Without this, pdfs were using the Helvetica font,
// which is a default itextsharp font (this was causing a problem for HLP, their pdfs could not
// contain a Helvetica font when putting them in their production environment).
private iTextSharp.text.Font _DefaultFont;
public iTextSharp.text.Font DefaultFont
{
get { return _DefaultFont; }
set { _DefaultFont = value; }
}
private string _MyDebugID = null;
public string MyDebugID
{
get { return _MyDebugID; }
set { _MyDebugID = value; }
}
public bool DoPdfLinks = false; public bool DoPdfLinks = false;
// public Rtf2iTextSharp(IRtfDocument rtfDoc, Document doc, PdfWriter writer) public Rtf2iTextSharp(IRtfDocument rtfDoc) => _RtfDoc = rtfDoc ?? throw new ArgumentNullException("rtfDoc");
public Rtf2iTextSharp(IRtfDocument rtfDoc)
{
if (rtfDoc == null)
throw new ArgumentNullException("rtfDoc");
_RtfDoc = rtfDoc;
}
public Paragraph Convert() public Paragraph Convert()
{ {
int profileDepth = ProfileTimer.Push(">>>> Rtf2ITextSharp.Convert"); int profileDepth = ProfileTimer.Push(">>>> Rtf2ITextSharp.Convert");
@@ -138,7 +95,6 @@ namespace Volian.Print.Library
{ {
visual.Visit(this); visual.Visit(this);
} }
//_MyParagraph.SetLeading(0, 1);
ProfileTimer.Pop(profileDepth); ProfileTimer.Pop(profileDepth);
return _MyParagraph; return _MyParagraph;
} }
@@ -177,6 +133,7 @@ namespace Volian.Print.Library
_lastWasLineBreak = 0; // B2017-191 reset hard return count _lastWasLineBreak = 0; // B2017-191 reset hard return count
break; break;
} }
//For Debugging:
//_MyParagraph.Add(string.Format("<{0}>", visualBreak.BreakKind.ToString())); //_MyParagraph.Add(string.Format("<{0}>", visualBreak.BreakKind.ToString()));
} }
private void AddChunk(string str, iTextSharp.text.Font font) private void AddChunk(string str, iTextSharp.text.Font font)
@@ -188,6 +145,7 @@ namespace Volian.Print.Library
} }
protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar) protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar)
{ {
//For Debugging:
//_MyParagraph.Add(string.Format("<special {0}>", visualSpecialChar.CharKind.ToString())); //_MyParagraph.Add(string.Format("<special {0}>", visualSpecialChar.CharKind.ToString()));
iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont; iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont;
switch (visualSpecialChar.CharKind) switch (visualSpecialChar.CharKind)
@@ -248,23 +206,15 @@ namespace Volian.Print.Library
if (c <= '\x7F') return false; if (c <= '\x7F') return false;
return true; return true;
} }
//For Debugging:
private bool ContainsAnySymbols(string p) private bool ContainsAnySymbols(string p)
{ {
foreach (char c in p) foreach (char c in p)
if (c > '\x7F' && c != '\xA0' && c != '\xB0') return true; if (c > '\x7F' && c != '\xA0' && c != '\xB0') return true;
return false; return false;
} }
// The funcction below was used for the first few lines of DoVisitText which have been commented-out
//private object FixText(string str)
//{
// StringBuilder sb = new StringBuilder();
// foreach (char c in str)
// if (c < ' ' || c > '\xFF')
// sb.Append(string.Format("[{0}]", (int)c));
// else
// sb.Append(c);
// return sb.ToString();
//}
// ParseLink & GetDefaultItemInfo (which used to be in vlnParagraph) support coding that was added to DoVisitText for // ParseLink & GetDefaultItemInfo (which used to be in vlnParagraph) support coding that was added to DoVisitText for
// doing pdflink for each transition/ro in a step, see bug B2019-052 // doing pdflink for each transition/ro in a step, see bug B2019-052
private RoUsageInfo _Roui = null; private RoUsageInfo _Roui = null;
@@ -278,8 +228,9 @@ namespace Volian.Print.Library
if (_LinkInfoText.Contains(@"\v")) if (_LinkInfoText.Contains(@"\v"))
throw new Exception("LinkText.ParseLink found RTF token"); throw new Exception("LinkText.ParseLink found RTF token");
Match m = Regex.Match(_LinkInfoText, @"[#]Link:([A-Za-z]*):(.*)"); Match m = Regex.Match(_LinkInfoText, @"[#]Link:([A-Za-z]*):(.*)");
string _MyValue = m.Groups[1].Value; //For Debugging:
string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value; //string _MyValue = m.Groups[1].Value;
//string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value;
switch (m.Groups[1].Value) switch (m.Groups[1].Value)
{ {
case "ReferencedObject": case "ReferencedObject":
@@ -319,7 +270,7 @@ namespace Volian.Print.Library
if (myItemInfo.IsProcedure && myItemInfo.Sections != null) if (myItemInfo.IsProcedure && myItemInfo.Sections != null)
{ {
SectionInfo siProcedureSteps = null; SectionInfo siProcedureSteps = null;
foreach (SectionInfo si in myItemInfo.Sections) foreach (SectionInfo si in myItemInfo.Sections.OfType<SectionInfo>())
{ {
if (si.IsDefaultSection) if (si.IsDefaultSection)
{ {
@@ -347,7 +298,7 @@ namespace Volian.Print.Library
private static int chkStart = -1; private static int chkStart = -1;
protected override void DoVisitText(IRtfVisualText visualText) protected override void DoVisitText(IRtfVisualText visualText)
{ {
//Code to find text (non-symbol) being output with a symbol font //Debugging Code to find text (non-symbol) being output with a symbol font
//if(visualText.Format.Font.Name=="VESymbFix" && visualText.Text.Length > 1) //if(visualText.Format.Font.Name=="VESymbFix" && visualText.Text.Length > 1)
//{ //{
// string s = visualText.Text; // string s = visualText.Text;
@@ -375,8 +326,7 @@ namespace Volian.Print.Library
{ {
try try
{ {
Chunk chk = _MyParagraph.Chunks[i] as Chunk; if (_MyParagraph.Chunks[i] is Chunk chk)
if (chk != null)
{ {
if (_linkType == 2 && _Ti != null) // transition if (_linkType == 2 && _Ti != null) // transition
{ {
@@ -398,7 +348,7 @@ namespace Volian.Print.Library
{ {
// C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference. // C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference.
DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig; DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig;
string remotePDFName = dvc.Print_PDFFilePrefix + _Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_") + dvc.Print_PDFFileSuffix + ".pdf"; string remotePDFName = $"{dvc.Print_PDFFilePrefix}{_Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_")}{dvc.Print_PDFFileSuffix}.pdf";
chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID)); chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID));
chk.SetBackground(new Color(System.Drawing.Color.PeachPuff)); chk.SetBackground(new Color(System.Drawing.Color.PeachPuff));
} }
@@ -630,6 +580,7 @@ namespace Volian.Print.Library
} }
} }
//For Debugging:
private string ShowSpecialCharacters(string p) private string ShowSpecialCharacters(string p)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -642,31 +593,23 @@ namespace Volian.Print.Library
sb.Append(c); sb.Append(c);
} }
return sb.ToString(); return sb.ToString();
}// DoVisitText }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
protected override void DoVisitImage(IRtfVisualImage visualImage) protected override void DoVisitImage(IRtfVisualImage visualImage)
{ {
//_MyParagraph.Add(new Chunk("<Image>"));
//DateTime dt1 = DateTime.Now;
//System.Drawing.Image img2 = visualImage.ImageForDrawing;
//Console.WriteLine("1 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
//img2.Save(@"c:\datacvrt\x.png");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
//Console.WriteLine("2 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
//Console.WriteLine("Size {0}", visualImage.ImageForDrawing.Size); {
visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
//Console.WriteLine("3 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
ms.Seek(0, System.IO.SeekOrigin.Begin); ms.Seek(0, System.IO.SeekOrigin.Begin);
//Console.WriteLine("4 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms);
//Console.WriteLine("5 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
_MyParagraph.Add(img); _MyParagraph.Add(img);
//Console.WriteLine("6 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); }
_lastWasLineBreak = 0; // B2017-191 reset hard return count _lastWasLineBreak = 0; // B2017-191 reset hard return count
} // DoVisitImage }
} }
} }
File diff suppressed because it is too large Load Diff
@@ -106,6 +106,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="CompleteRORpt.cs" /> <Compile Include="CompleteRORpt.cs" />
<Compile Include="CPSGen.cs" /> <Compile Include="CPSGen.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Grid2Pdf.cs" /> <Compile Include="Grid2Pdf.cs" />
<Compile Include="MergedPdf.cs" /> <Compile Include="MergedPdf.cs" />
<Compile Include="PageCount.cs" /> <Compile Include="PageCount.cs" />
+23 -42
View File
@@ -1,46 +1,26 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using System.IO; using System.IO;
using Microsoft.Win32;
using Volian.Base.Library; using Volian.Base.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public class pdf public class pdf
{ {
private Document _MyDocument; public Document MyDocument { get; set; }
public Document MyDocument public PdfWriter MyWriter { get; set; }
{ public string MyFileName { get; set; }
get { return _MyDocument; } public PdfContentByte ContentByte => MyWriter.DirectContent;
set { _MyDocument = value; }
}
private PdfWriter _MyWriter;
public PdfWriter MyWriter
{
get { return _MyWriter; }
set { _MyWriter = value; }
}
private string _MyFileName;
public string MyFileName
{
get { return _MyFileName; }
set { _MyFileName = value; }
}
public PdfContentByte ContentByte
{
get { return _MyWriter.DirectContent; }
}
public pdf(string myFileName) public pdf(string myFileName)
{ {
_MyFileName = myFileName; MyFileName = myFileName;
_MyDocument = new Document(PageSize.LETTER); MyDocument = new Document(PageSize.LETTER);
try try
{ {
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create)); MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -49,24 +29,21 @@ namespace Volian.Print.Library
} }
public pdf(string myFileName, Rectangle mySize) public pdf(string myFileName, Rectangle mySize)
{ {
_MyFileName = myFileName; MyFileName = myFileName;
_MyDocument = new Document(mySize); MyDocument = new Document(mySize);
try try
{ {
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create)); MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("{0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); Console.WriteLine("{0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
} }
} }
public void Close() public void Close() => MyDocument.Close();
{ private readonly Color _WatermarkColor = Color.BLUE;
MyDocument.Close(); private readonly float _WatermarkOpacity = .10F;
}
private Color _WatermarkColor = Color.BLUE;
private float _WatermarkOpacity = .10F;
public void WatermarkPageNumber(int pageNumber) public void WatermarkPageNumber(int pageNumber)
{ {
Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size
@@ -84,8 +61,10 @@ namespace Volian.Print.Library
ContentByte.SetLineWidth(.5F); ContentByte.SetLineWidth(.5F);
ContentByte.SetFontAndSize(myBasefont, myFontSize);// Set font and size ContentByte.SetFontAndSize(myBasefont, myFontSize);// Set font and size
ContentByte.SetColorStroke(_WatermarkColor); ContentByte.SetColorStroke(_WatermarkColor);
PdfGState gs2 = new PdfGState(); PdfGState gs2 = new PdfGState
gs2.StrokeOpacity = _WatermarkOpacity; {
StrokeOpacity = _WatermarkOpacity
};
ContentByte.SetGState(gs2); ContentByte.SetGState(gs2);
ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, strPage, pageSize.Width / 2, 0, 0);// Draw the text ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, strPage, pageSize.Width / 2, 0, 0);// Draw the text
ContentByte.EndText(); ContentByte.EndText();
@@ -108,8 +87,10 @@ namespace Volian.Print.Library
{ {
PdfPatternPainter myPatternPainter; PdfPatternPainter myPatternPainter;
myPatternPainter = ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2); myPatternPainter = ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
PdfGState gState = new PdfGState(); PdfGState gState = new PdfGState
gState.FillOpacity = _WatermarkOpacity; {
FillOpacity = _WatermarkOpacity
};
myPatternPainter.SetGState(gState); myPatternPainter.SetGState(gState);
myPatternPainter.SetColorFill(_WatermarkColor); myPatternPainter.SetColorFill(_WatermarkColor);
myPatternPainter.Rectangle(0, 0, radius, radius); myPatternPainter.Rectangle(0, 0, radius, radius);
+6 -17
View File
@@ -1,26 +1,15 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public class pkParagraph public class pkParagraph
{ {
private vlnParagraph _MyParagraph; private readonly vlnParagraph _MyParagraph;
public vlnParagraph MyParagraph public vlnParagraph MyParagraph => _MyParagraph;
{ private readonly pkParagraphs _MyChildren;
get { return _MyParagraph; } public pkParagraphs MyChildren => _MyChildren;
} private readonly pkParagraphs _MyCautionsAndNotes;
private pkParagraphs _MyChildren; public pkParagraphs MyCautionsAndNotes => _MyCautionsAndNotes;
public pkParagraphs MyChildren
{
get { return _MyChildren; }
}
private pkParagraphs _MyCautionsAndNotes;
public pkParagraphs MyCautionsAndNotes
{
get { return _MyCautionsAndNotes; }
}
public pkParagraph(vlnParagraph myParagraph) public pkParagraph(vlnParagraph myParagraph)
{ {
_MyParagraph = myParagraph; _MyParagraph = myParagraph;
+35 -69
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Drawing; using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -12,20 +11,8 @@ namespace Volian.Print.Library
public partial class vlnBox : vlnPrintObject public partial class vlnBox : vlnPrintObject
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _LineType; /* how to represent?? */
private System.Drawing.Color _Color;
public System.Drawing.Color Color
{
get { return _Color; }
set { _Color = value; }
}
private Box _MyBox;
public Box MyBox public Box MyBox { get; set; }
{
get { return _MyBox; }
set { _MyBox = value; }
}
// the following two fields are used if 'boxed' step, thus // the following two fields are used if 'boxed' step, thus
// no 'Box' was defined in format file. // no 'Box' was defined in format file.
public override float Height public override float Height
@@ -41,26 +28,13 @@ namespace Volian.Print.Library
public string DefBox = null; public string DefBox = null;
public float DefEnd = 0; public float DefEnd = 0;
private bool _ContainsPageBreak = false; public bool ContainsPageBreak { get; set; } = false;
public bool ContainsPageBreak public bool DoubleBoxHls { get; set; } = false;
{
get { return _ContainsPageBreak; }
set { _ContainsPageBreak = value; }
}
private bool _DoubleBoxHls = false; // BGE double lined box around HLS
public bool DoubleBoxHls
{
get { return _DoubleBoxHls; }
set { _DoubleBoxHls = value; }
}
public const string DOUBLEboxHLS = "DoubleBox"; public const string DOUBLEboxHLS = "DoubleBox";
//private bool _DoBottom = true; //private bool _DoBottom = true;
public vlnBox() public vlnBox()
{ {
} }
public vlnBox(vlnParagraph paragraph)
{
}
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . "; public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . "; const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . "; const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . ";
@@ -95,10 +69,9 @@ namespace Volian.Print.Library
if (MyBox == null) return yPageStart; if (MyBox == null) return yPageStart;
cb.SaveState(); cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; PdfLayer textLayer = _MyPageHelper?.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
MyContentByte = cb; MyContentByte = cb;
//Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier); float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier);
float bottom = top - (Height * MyPageHelper.YMultiplier); float bottom = top - (Height * MyPageHelper.YMultiplier);
float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin); float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin);
@@ -157,7 +130,7 @@ namespace Volian.Print.Library
else else
{ {
const float llxOffset = 3; const float llxOffset = 3;
float lineThickness = 0; float lineThickness;
switch (MyBox.BoxStyle) switch (MyBox.BoxStyle)
{ {
case BoxThin: case BoxThin:
@@ -331,8 +304,6 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline. // create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false; bool UseBoxFont = false;
try try
{ {
@@ -341,6 +312,8 @@ namespace Volian.Print.Library
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{ {
} }
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont) if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else else
@@ -355,21 +328,21 @@ namespace Volian.Print.Library
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXULC); sb.Append(MyBox.BXULC);
float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI)); float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI));
string bxstr = null; string bxstr;
if (!ContainsPageBreak) // Only do top line if there is no page break. if (!ContainsPageBreak) // Only do top line if there is no page break.
{ {
while (size < endHorz) while (size < endHorz)
{ {
sb.Append(MyBox.BXHorz); sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); size += bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
} }
// Tack on the right upper corner. For some formats, the upper right corner in the // Tack on the right upper corner. For some formats, the upper right corner in the
// had the first character as a space, this would put two spaces in a row at the // had the first character as a space, this would put two spaces in a row at the
// end of the string, so remove the space before tacking on the upper right corner: // end of the string, so remove the space before tacking on the upper right corner:
bxstr = sb.ToString(); bxstr = sb.ToString();
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd(); if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
bxstr = bxstr + MyBox.BXURC; bxstr += MyBox.BXURC;
size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf); Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin); Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
@@ -384,15 +357,15 @@ namespace Volian.Print.Library
while (size < endHorz) while (size < endHorz)
{ {
sb.Append(MyBox.BXHorz); sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); size += bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
} }
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); size += GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf); Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin); Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
} }
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed // add symbol characters as needed
// "\u25CF" - solid bullet // "\u25CF" - solid bullet
// \x0394 - delta // \x0394 - delta
@@ -409,8 +382,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle // window handle
//System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
//System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size); System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
@@ -424,9 +395,9 @@ namespace Volian.Print.Library
else else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
} }
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w; return w;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")]
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
{ {
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these. // set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
@@ -453,8 +424,6 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline. // create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false; bool UseBoxFont = false;
try try
{ {
@@ -463,6 +432,8 @@ namespace Volian.Print.Library
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{ {
} }
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont) if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else else
@@ -503,17 +474,8 @@ namespace Volian.Print.Library
} }
return sb.ToString(); return sb.ToString();
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<string> _UnimplementedBoxStyles = new List<string>(); private static List<string> _UnimplementedBoxStyles = new List<string>();
private string CharToAsc(string p)
{
StringBuilder sb = new StringBuilder();
foreach (char c in p)
{
if (c >= ' ' && c < 127) sb.Append(c);
else sb.Append(string.Format("\\x{0:x}", (int)c));
}
return sb.ToString();
}
private void DrawAsteriskTopBottomHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left, VE_Font vef) private void DrawAsteriskTopBottomHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left, VE_Font vef)
{ {
// this box is not drawn, it is a series of asterisks drawn above and below text. // this box is not drawn, it is a series of asterisks drawn above and below text.
@@ -527,8 +489,6 @@ namespace Volian.Print.Library
bottom = ytmpbottom1; bottom = ytmpbottom1;
// create a new font without any styles such as underline. // create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false; bool UseBoxFont = false;
try try
{ {
@@ -537,6 +497,8 @@ namespace Volian.Print.Library
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{ {
} }
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont) if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else else
@@ -550,22 +512,22 @@ namespace Volian.Print.Library
// Do the top line first: // Do the top line first:
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXULC); sb.Append(MyBox.BXULC);
float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI)); float size = GetTextWidth(vf, MyBox.BXULC);
string bxstr = null; string bxstr;
if (!ContainsPageBreak) // Only do top line if there is no page break. if (!ContainsPageBreak) // Only do top line if there is no page break.
{ {
while (size < endHorz) while (size < endHorz)
{ {
sb.Append(MyBox.BXHorz); sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); size += bxHorzTextWidth;
} }
// Tack on the right upper corner. For some formats, the upper right corner in the // Tack on the right upper corner. For some formats, the upper right corner in the
// had the first character as a space, this would put two spaces in a row at the // had the first character as a space, this would put two spaces in a row at the
// end of the string, so remove the space before tacking on the upper right corner: // end of the string, so remove the space before tacking on the upper right corner:
bxstr = sb.ToString(); bxstr = sb.ToString();
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd(); if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
bxstr = bxstr + MyBox.BXURC; bxstr += MyBox.BXURC;
size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf); Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin); Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
@@ -576,23 +538,24 @@ namespace Volian.Print.Library
sb.Remove(0, sb.Length); sb.Remove(0, sb.Length);
sb.Append(MyBox.BXLLC); sb.Append(MyBox.BXLLC);
size = GetTextWidth(vf, MyBox.BXLLC); //(float)(MyBox.BXLLC.Length * (72 / vf.CPI)); size = GetTextWidth(vf, MyBox.BXLLC);
while (size < endHorz) while (size < endHorz)
{ {
sb.Append(MyBox.BXHorz); sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); size += bxHorzTextWidth;
} }
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); size += GetTextWidth(vf, MyBox.BXLRC);
Rtf = GetRtf(bxstr, vf); Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin); Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")]
private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
{ {
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these. // set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
// The vlnBox property, ContainsPageBreak, flags that a break occurred. // The vlnBox property, ContainsPageBreak, flags that a break occurred.
float yOffBreak = 0; float yOffBreak;
if (!ContainsPageBreak) if (!ContainsPageBreak)
{ {
top = CalculateYOffset(yPageStart, yTopMargin); top = CalculateYOffset(yPageStart, yTopMargin);
@@ -613,7 +576,10 @@ namespace Volian.Print.Library
} }
else else
{ {
#pragma warning disable IDE0059 // Unnecessary assignment of a value - Keeping top for Debugging
top = CalculateYOffset(yPageStart, yTopMargin); top = CalculateYOffset(yPageStart, yTopMargin);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0; yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0;
if (yOffBreak > 0) if (yOffBreak > 0)
bottom = (yPageStart - yOffBreak) * MyPageHelper.YMultiplier; bottom = (yPageStart - yOffBreak) * MyPageHelper.YMultiplier;
@@ -636,8 +602,6 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline. // create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false; bool UseBoxFont = false;
try try
{ {
@@ -646,6 +610,8 @@ namespace Volian.Print.Library
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{ {
} }
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont) if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else else
+22 -71
View File
@@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@@ -10,44 +8,25 @@ namespace Volian.Print.Library
{ {
public class vlnChangeBarMessage public class vlnChangeBarMessage
{ {
private float _ParentX; public float ParentX { get; set; }
public float ParentX public string Message { get; set; }
{
get { return _ParentX; }
set { _ParentX = value; }
}
private string _Message;
public string Message
{
get { return _Message; }
set { _Message = value; }
}
private static int _UniqueMessageId = 0; private static int _UniqueMessageId = 0;
public static int UniqueMessageId public static int UniqueMessageId
{ {
get { return vlnChangeBarMessage._UniqueMessageId++; } get { return _UniqueMessageId++; }
set { vlnChangeBarMessage._UniqueMessageId = value; } set { _UniqueMessageId = value; }
}
private int _MessageId = UniqueMessageId;
public int MessageId
{
get { return _MessageId; }
set { _MessageId = value; }
} }
public int MessageId { get; set; } = UniqueMessageId;
public vlnChangeBarMessage(float parentx, string msg) public vlnChangeBarMessage(float parentx, string msg)
{ {
_ParentX = parentx; ParentX = parentx;
_Message = msg; Message = msg;
} }
} }
public partial class vlnChangeBar : vlnPrintObject public partial class vlnChangeBar : vlnPrintObject
{ {
private bool _HasChangeBar; public bool HasChangeBar { get; set; }
public bool HasChangeBar
{
get { return _HasChangeBar; }
set { _HasChangeBar = value; }
}
protected float _YChangeBarBottom; protected float _YChangeBarBottom;
public float YChangeBarBottom public float YChangeBarBottom
{ {
@@ -62,36 +41,15 @@ namespace Volian.Print.Library
_Height = _YOffset - _YChangeBarBottom; _Height = _YOffset - _YChangeBarBottom;
} }
} }
private SortedDictionary<float, vlnChangeBarMessage> _Messages;
public SortedDictionary<float, vlnChangeBarMessage> Messages public SortedDictionary<float, vlnChangeBarMessage> Messages { get; set; }
{ public int MessageAlignment { get; set; }
get { return _Messages; } public float YExtendLine { get; set; } = 4.75F;
set { _Messages = value; } public float YChangeBarBottomExtend => YChangeBarBottom - YExtendLine;
}
private int _MessageAlignment; public bool BottomIsTable { get; set; } = false;
public int MessageAlignment private readonly bool _IsRev;
{ private readonly bool _MsgAtTop; // flags that message should be drawn at top of change bar
get { return _MessageAlignment; }
set { _MessageAlignment = value; }
}
private float _YExtendLine = 4.75F;
public float YExtendLine
{
get { return _YExtendLine; }
set {_YExtendLine = value; }
}
public float YChangeBarBottomExtend
{
get {return YChangeBarBottom - YExtendLine; }
}
private bool _BottomIsTable = false;
public bool BottomIsTable
{
get { return _BottomIsTable; }
set { _BottomIsTable = value; }
}
private bool _IsRev;
private bool _MsgAtTop; // flags that message should be drawn at top of change bar
public vlnChangeBar(PdfContentByte cb, vlnParagraph parent, float xoff, float yoff, int msgAlignment, bool isRev, bool msgAtTop) public vlnChangeBar(PdfContentByte cb, vlnParagraph parent, float xoff, float yoff, int msgAlignment, bool isRev, bool msgAtTop)
{ {
// for grids, a y adjustment is made to match 16bit output, see the variable 'GridTopAdjust'. Take this // for grids, a y adjustment is made to match 16bit output, see the variable 'GridTopAdjust'. Take this
@@ -113,7 +71,7 @@ namespace Volian.Print.Library
{ {
// see if any of children don't have changebar // see if any of children don't have changebar
if ((vpo as vlnRNOSeparator).ExtendChangeBar) if ((vpo as vlnRNOSeparator).ExtendChangeBar)
_YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier; YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier;
} }
} }
foreach (vlnPrintObject vph in parent.PartsAbove) foreach (vlnPrintObject vph in parent.PartsAbove)
@@ -152,12 +110,9 @@ namespace Volian.Print.Library
} }
} }
} }
_MessageAlignment = msgAlignment; MessageAlignment = msgAlignment;
}
public override string ToString()
{
return string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID);
} }
public override string ToString() => string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID);
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{ {
float? topMost = null; float? topMost = null;
@@ -170,11 +125,9 @@ namespace Volian.Print.Library
// calculate a new starting position for the change bar // calculate a new starting position for the change bar
if (_MyParent is vlnParagraph) if (_MyParent is vlnParagraph)
{ {
vlnParagraph pgh = _MyParent as vlnParagraph;
topMost = cb.PdfWriter.PageSize.Height - yPageStart; topMost = cb.PdfWriter.PageSize.Height - yPageStart;
} }
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
float yAdj = -3.75F; //0.5F; float yAdj = -3.75F; //0.5F;
float xAdj = 3F; float xAdj = 3F;
@@ -226,8 +179,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B21017-117 // window handle B21017-117
//iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 10F)):
// Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 5.5F));
iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 10F)): iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 10F)):
Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 5.5F)); Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 5.5F));
+2 -10
View File
@@ -1,20 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public partial class vlnHeader: vlnText public partial class vlnHeader: vlnText
{ {
private string _OrigStr; private readonly string _OrigStr;
public float HeaderWidth public float HeaderWidth => _WidthAdjust + (MyFont.CharsToTwips * Text.Length);
{
get { return _WidthAdjust + (MyFont.CharsToTwips * Text.Length); }
}
public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont) public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont)
{ {
MyParent = myParent; MyParent = myParent;
+2 -14
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
@@ -13,12 +7,7 @@ namespace Volian.Print.Library
private bool _UseInternalY = false; private bool _UseInternalY = false;
// B2020-121: Account for Header on Caution or Note // B2020-121: Account for Header on Caution or Note
public bool UseInternalY { get => _UseInternalY; set => _UseInternalY = value; } public bool UseInternalY { get => _UseInternalY; set => _UseInternalY = value; }
private string _MacroDef; public string MacroDef { get; set; }
public string MacroDef
{
get { return _MacroDef; }
set { _MacroDef = value; }
}
public vlnMacro(float xoffset, float yoffset, string macroDef) public vlnMacro(float xoffset, float yoffset, string macroDef)
{ {
YOffset = yoffset; YOffset = yoffset;
@@ -33,8 +22,7 @@ namespace Volian.Print.Library
if (UseInternalY) yLocation = YOffset; // B2020-121: Account for Header on Caution or Note if (UseInternalY) yLocation = YOffset; // B2020-121: Account for Header on Caution or Note
// Adjust the starting point for the Macro if the LPI is 7 // Adjust the starting point for the Macro if the LPI is 7
if (MyPageHelper.YMultiplier != 1) yLocation += SixLinesPerInch - _SevenLinesPerInch; if (MyPageHelper.YMultiplier != 1) yLocation += SixLinesPerInch - _SevenLinesPerInch;
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
MyContentByte = cb; MyContentByte = cb;
System.Drawing.Color push = PrintOverride.SvgColor; System.Drawing.Color push = PrintOverride.SvgColor;
File diff suppressed because it is too large Load Diff
+34 -138
View File
@@ -1,14 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using Itenso.Rtf; using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support; using Itenso.Rtf.Support;
using Volian.Controls.Library;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -24,21 +20,13 @@ namespace Volian.Print.Library
get { return _UniqueDebugId++; } get { return _UniqueDebugId++; }
set { _UniqueDebugId = value; } set { _UniqueDebugId = value; }
} }
private int _DebugId = UniqueDebugId;
public int DebugId public int DebugId { get; set; } = UniqueDebugId;
{
get { return _DebugId; }
set { _DebugId = value; }
}
protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3. protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3.
protected static float _WidthAdjustBox = 6; protected static float _WidthAdjustBox = 6;
private static float _SixLinesPerInch = 12; // twips
public static float SixLinesPerInch public static float SixLinesPerInch { get; set; } = 12;
{
get { return vlnPrintObject._SixLinesPerInch; }
set { vlnPrintObject._SixLinesPerInch = value; }
}
protected static float _SevenLinesPerInch = 10.1F;//72F / 7F; protected static float _SevenLinesPerInch = 10.1F;//72F / 7F;
protected float _XOffset; protected float _XOffset;
@@ -64,30 +52,12 @@ namespace Volian.Print.Library
set set
{ {
_MyParent = value; _MyParent = value;
if (_MyParent != null) }
{ }
} public bool HasIndent { get; set; } = false;
} public bool IsCompressed { get; set; } = false;
} public string ImageText { get; set; }
private bool _HasIndent = false;
public bool HasIndent
{
get { return _HasIndent; }
set { _HasIndent = value; }
}
private bool _IsCompressed = false;
public bool IsCompressed
{
get { return _IsCompressed; }
set { _IsCompressed = value; }
}
private string _ImageText; // ro definition, value part of #Link in case of image/figure
public string ImageText
{
get { return _ImageText; }
set { _ImageText = value; }
}
protected string _Rtf; // may become iTextSharp paragraph protected string _Rtf; // may become iTextSharp paragraph
public virtual string Rtf public virtual string Rtf
{ {
@@ -96,14 +66,8 @@ namespace Volian.Print.Library
} }
public class VlnSplitCharacter : ISplitCharacter public class VlnSplitCharacter : ISplitCharacter
{ {
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
{ public bool IsSplitCharacter(char c) => (c == ' ');
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
} }
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
// B2018-034 Attributes were being lost when the IsCompressed flag was true. // B2018-034 Attributes were being lost when the IsCompressed flag was true.
@@ -114,6 +78,7 @@ namespace Volian.Print.Library
{ {
get get
{ {
//For Debugging:
// If the paragraph iscompressed, it may have been created as not compressed since compression // If the paragraph iscompressed, it may have been created as not compressed since compression
// is not set when paragraph is initially created, it is set during pagination tests. // is not set when paragraph is initially created, it is set during pagination tests.
//if (_IParagraph == null || IsCompressed) //if (_IParagraph == null || IsCompressed)
@@ -186,48 +151,9 @@ namespace Volian.Print.Library
} }
set { _Height = value; } set { _Height = value; }
} }
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width) public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width) => GetParagraphHeight(cb, iParagraph, suffix, width, true);
{ public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) => (float)GetHeight(cb, iParagraph, suffix, width, throwException);
return GetParagraphHeight(cb, iParagraph, suffix, width, true);
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{
float heightAll = GetHeight(cb, iParagraph, suffix, width, throwException);
return heightAll;
}
private static void RestoreLastCharacter(Paragraph iParagraph, Chunk chk)
{
iParagraph.RemoveAt(iParagraph.Count - 1);
iParagraph.Add(chk);
}
private static Chunk RemoveLastCharacter(Paragraph iParagraph)
{
if (iParagraph.Count == 0)
return null;
object obj = iParagraph[iParagraph.Count-1];
Chunk chk = obj as Chunk;
if (chk == null)
return null;
string s = chk.Content;
if (s.Length > 1 || iParagraph.Count > 1) // don't remove last character if it's the only one
{
iParagraph.RemoveAt(iParagraph.Count - 1);
if (s.Length > 0)
{
if (s == "\xA0") // If this is a space at the end put it back
{
iParagraph.Add(chk);
return null;
}
else
{
s = s.Substring(0, s.Length - 1);
iParagraph.Add(new Chunk(s, chk.Font));
}
}
}
return chk;
}
public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{ {
ColumnText myColumnText = new ColumnText(cb); ColumnText myColumnText = new ColumnText(cb);
@@ -243,7 +169,6 @@ namespace Volian.Print.Library
{ {
myColumnText.AddElement(iParagraph); myColumnText.AddElement(iParagraph);
} }
//myColumnText.UseAscender = true;// Adjusts to the top of the text box.
int status = myColumnText.Go(true); // Check to see if it will fit on the page. int status = myColumnText.Go(true); // Check to see if it will fit on the page.
if (ColumnText.HasMoreText(status) && throwException) if (ColumnText.HasMoreText(status) && throwException)
{ {
@@ -255,7 +180,6 @@ namespace Volian.Print.Library
iParagraph.IndentationLeft = 0; iParagraph.IndentationLeft = 0;
return GetHeight(cb, iParagraph, suffix, width, throwException); return GetHeight(cb, iParagraph, suffix, width, throwException);
} }
//throw (new Exception("Paragraph longer than a page"));
Console.WriteLine("Paragraph longer than a page"); Console.WriteLine("Paragraph longer than a page");
} }
return pgHeight - myColumnText.YLine; // This gives the height of the Paragraph // C2020-002 paper size is now set in the format files return pgHeight - myColumnText.YLine; // This gives the height of the Paragraph // C2020-002 paper size is now set in the format files
@@ -266,22 +190,18 @@ namespace Volian.Print.Library
float h = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth); float h = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth);
int iWidthMax = iWidth; // maximum width in Characters int iWidthMax = iWidth; // maximum width in Characters
int iDelta = iWidth / 2; int iDelta = iWidth / 2;
iWidth = iWidth / 2; iWidth /= 2;
while (iDelta > 0) while (iDelta > 0)
{ {
float h2 = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth,false); float h2 = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth,false);
iDelta = iDelta / 2; iDelta /= 2;
if (h2 == h) iWidthMax = iWidth; if (h2 == h) iWidthMax = iWidth;
iWidth += (h2>h ? 1: -1) * iDelta; iWidth += (h2>h ? 1: -1) * iDelta;
} }
return (float) iWidthMax; return (float) iWidthMax;
} }
private PdfContentByte _MyContentByte;
public PdfContentByte MyContentByte public PdfContentByte MyContentByte { get; set; }
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
private VlnSvgPageHelper _MyPageHelper; private VlnSvgPageHelper _MyPageHelper;
public VlnSvgPageHelper MyPageHelper public VlnSvgPageHelper MyPageHelper
{ {
@@ -301,45 +221,29 @@ namespace Volian.Print.Library
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(int value) public static int ToInt(int value) => value;
{
return value;
}
/// <summary> /// <summary>
/// No conversion necessary: int? twips -> int twips /// No conversion necessary: int? twips -> int twips
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(int? value) public static int ToInt(int? value) => ToInt((int)value);
{
return ToInt((int)value);
}
/// <summary> /// <summary>
/// No conversion necessary: string twips -> int twips /// No conversion necessary: string twips -> int twips
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(string value) public static int ToInt(string value) => ToInt((int)Convert.ToSingle(value));
{
return ToInt((int)Convert.ToSingle(value));
}
/// <summary> /// <summary>
/// No conversion necessary: value from a list in a string, twips -> int twips /// No conversion necessary: value from a list in a string, twips -> int twips
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
public static int ToInt(string value, int i) public static int ToInt(string value, int i) => ToInt((value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value);
{
string s = (value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value;
return ToInt(s);
}
public static string GetRtf(string text, VE_Font vFont) public static string GetRtf(string text, VE_Font vFont)
{ {
StringBuilder rtfSB = new StringBuilder(); StringBuilder rtfSB = new StringBuilder();
//DisplayText vlntxt = new DisplayText(text.TrimStart(" ".ToCharArray()), vFont, false);
DisplayText vlntxt = new DisplayText(text, vFont, false); DisplayText vlntxt = new DisplayText(text, vFont, false);
//rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont));
//rtfSB.Append(AddFontTable(vFont.WindowsFont));
rtfSB.Append(AddFontTable(vFont)); rtfSB.Append(AddFontTable(vFont));
rtfSB.Append(vlntxt.StartText); rtfSB.Append(vlntxt.StartText);
rtfSB.Append("}"); rtfSB.Append("}");
@@ -413,10 +317,7 @@ namespace Volian.Print.Library
float fE = iFont.BaseFont.GetWidthPointKerned("!", 12); float fE = iFont.BaseFont.GetWidthPointKerned("!", 12);
return fW == fE; return fW == fE;
} }
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf) public static iTextSharp.text.Paragraph RtfToParagraph(string rtf) => RtfToParagraph(rtf, false, false);
{
return RtfToParagraph(rtf, false, false);
}
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks) public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks)
{ {
if (hasIndent) if (hasIndent)
@@ -427,11 +328,13 @@ namespace Volian.Print.Library
} }
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc)
rtf2IText.DoPdfLinks = doPdfLinks; {
rtf2IText.HasIndent = hasIndent; DoPdfLinks = doPdfLinks,
HasIndent = hasIndent
};
iTextSharp.text.Paragraph para = rtf2IText.Convert(); iTextSharp.text.Paragraph para = rtf2IText.Convert();
para.SetLeading(_SixLinesPerInch, 0); para.SetLeading(SixLinesPerInch, 0);
if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015. if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015.
{ {
// if there is a hanging indent, the iTextSharp paragraph properties must be set // if there is a hanging indent, the iTextSharp paragraph properties must be set
@@ -459,8 +362,7 @@ namespace Volian.Print.Library
// Change the chunks to only split on spaces rather than spaces and hyphens // Change the chunks to only split on spaces rather than spaces and hyphens
foreach (object obj in para)//Fix the code to check for chunks before assuming chunks foreach (object obj in para)//Fix the code to check for chunks before assuming chunks
{ {
Chunk chk = obj as Chunk; if (obj is Chunk chk && (chk.Attributes == null || !chk.Attributes.ContainsKey("NoSplit")))
if (chk != null && (chk.Attributes==null || !chk.Attributes.ContainsKey("NoSplit")))
{ {
if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable(); if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable();
chk.SetSplitCharacter(mySplitter); chk.SetSplitCharacter(mySplitter);
@@ -469,11 +371,7 @@ namespace Volian.Print.Library
} }
return para; return para;
} }
private static string FixNumber(string num) private static string FixNumber(string num) => num == "" ? "0" : num;
{
if (num == "") return ("0");
return num;
}
public static float CalculateHangingIndent(string rtf) public static float CalculateHangingIndent(string rtf)
{ {
float chkW=0; float chkW=0;
@@ -515,8 +413,7 @@ namespace Volian.Print.Library
} }
public void DebugPdf(PdfContentByte cb, float left, float top) public void DebugPdf(PdfContentByte cb, float left, float top)
{ {
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return; if (debugLayer == null) return;
cb.SaveState(); cb.SaveState();
cb.BeginLayer(debugLayer); cb.BeginLayer(debugLayer);
@@ -531,8 +428,7 @@ namespace Volian.Print.Library
cb.EndLayer(); cb.EndLayer();
cb.RestoreState(); cb.RestoreState();
} }
public virtual float YBottom public virtual float YBottom => YOffset + Height;
{ get { return YOffset + Height;} }
} }
public partial class vlnPrintObjects : List<vlnPrintObject> public partial class vlnPrintObjects : List<vlnPrintObject>
{ {
+5 -26
View File
@@ -1,40 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public partial class vlnRNOSeparator : vlnPrintObject public partial class vlnRNOSeparator : vlnPrintObject
{ {
private VE_Font _MyFont; public VE_Font MyFont { get; set; }
public VE_Font MyFont public bool ExtendChangeBar { get; set; }
{ public float XLength { get; set; } = 0;
get { return _MyFont; }
set { _MyFont = value; }
}
private bool _ExtendChangeBar;
public bool ExtendChangeBar
{
get { return _ExtendChangeBar; }
set { _ExtendChangeBar = value; }
}
private float _XLength = 0;
public float XLength
{
get { return _XLength; }
set { _XLength = value; }
}
/* if flag set and separator defined then output separator */ /* if flag set and separator defined then output separator */
/*if separator is a control-A use RNOSepLine*/ /*if separator is a control-A use RNOSepLine*/
public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, FormatInfo formatInfo, bool extendChangeBar) public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, FormatInfo formatInfo, bool extendChangeBar)
{ {
MyContentByte = cb; // B2019-091: crash when printing (note moved from the 'ToPdf' method) MyContentByte = cb; // B2019-091: crash when printing (note moved from the 'ToPdf' method)
ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep ? extendChangeBar : false; ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep && extendChangeBar;
YOffset = yoffset; YOffset = yoffset;
XOffset = xoffset; XOffset = xoffset;
XLength = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepLineLength??0; XLength = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepLineLength??0;
@@ -60,8 +40,7 @@ namespace Volian.Print.Library
if (XLength != 0) if (XLength != 0)
{ {
cb.SaveState(); cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideChangeBarColor(System.Drawing.Color.Black)); iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideChangeBarColor(System.Drawing.Color.Black));
cb.SetColorStroke(lineColor); cb.SetColorStroke(lineColor);
+11 -70
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
@@ -59,35 +55,21 @@ namespace Volian.Print.Library
return (float)_TabOffset * MyFont.CharsToTwips; return (float)_TabOffset * MyFont.CharsToTwips;
} }
} }
private vlnMacro _MyMacro;
public vlnMacro MyMacro
{
get { return _MyMacro; }
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab public vlnMacro MyMacro { get; set; }
private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed // add symbol characters as needed
// "\u25CF" - solid bullet // "\u25CF" - solid bullet
// \u0394 - delta // \u0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f) private System.Drawing.FontStyle GetSysFontStyle(VE_Font f) => f.Style == E_Style.Italics ? System.Drawing.FontStyle.Italic : FontStyle.Regular;
{ public float GetTextWidth(VE_Font vefont, string txt) => GetTextWidth(vefont, txt, SymbolFontName);
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
public float GetTextWidth(VE_Font vefont, string txt)
{
return GetTextWidth(vefont, txt, SymbolFontName);
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{ {
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
//System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size); System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
@@ -101,29 +83,13 @@ namespace Volian.Print.Library
else else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
} }
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w; return w;
} }
bool _ScriptCaution = false;
public bool ScriptCaution public bool ScriptCaution { get; set; } = false;
{
get { return _ScriptCaution; }
set { _ScriptCaution = value; }
}
bool _SeparateBullet = false;
public bool SeparateBullet public bool SeparateBullet { get; set; } = false;
{ public string SymbolFontName { get; set; }
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
private string _SymbolFontName;
public string SymbolFontName
{
get { return _SymbolFontName; }
set { _SymbolFontName = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline) public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{ {
SymbolFontName = symblFontName; SymbolFontName = symblFontName;
@@ -149,20 +115,14 @@ namespace Volian.Print.Library
Width = 90; Width = 90;
} }
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0) else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
//if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth; Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs) else if (CCCs != IIIs)
{ {
float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6; float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6;
Width = (tPtPerChar == 0 ? 6 : tPtPerChar) * origTab.Length; Width = (tPtPerChar == 0 ? 6 : tPtPerChar) * origTab.Length;
// Check the following, it may be needed for FPL:
//origTab1 = origTab1.TrimStart(" ".ToCharArray());
// 6 = number of points per character. 4 characters between end of tab and beginning of text
// origTab1.Trim... is number of non-space characters of the tab string.
//Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length);
} }
else else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); Width = GetTextWidth(MyFont, (Text ?? origTab), symblFontName);
// Pairie Island (NSP) Caution and Note tabs use a larger font // Pairie Island (NSP) Caution and Note tabs use a larger font
// When using a bullet, we need to use the font size of the Caution/Note text instead of the tab. // When using a bullet, we need to use the font size of the Caution/Note text instead of the tab.
@@ -195,7 +155,7 @@ namespace Volian.Print.Library
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth; Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else else
{ {
origTab = origTab + " "; origTab += " ";
origTab = origTab.TrimStart(" ".ToCharArray()); origTab = origTab.TrimStart(" ".ToCharArray());
if (mindx > 2) // ouch! if (mindx > 2) // ouch!
Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output! Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output!
@@ -204,7 +164,7 @@ namespace Volian.Print.Library
} }
} }
else else
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length); Width = GetTextWidth(MyFont, (cleanTab ?? origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
} }
else else
{ {
@@ -219,8 +179,6 @@ namespace Volian.Print.Library
int sep = origTab.IndexOfAny(". ".ToCharArray()); int sep = origTab.IndexOfAny(". ".ToCharArray());
string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul "; string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul ";
string suffix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b0\ulnone " : @"\ulnone "; string suffix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b0\ulnone " : @"\ulnone ";
//origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
//origTab = @"\ul " + origTab.Substring(0, sep) + @"\ulnone" + origTab.Substring(sep);
origTab = prefix + origTab.Substring(0, sep) + suffix + origTab.Substring(sep); origTab = prefix + origTab.Substring(0, sep) + suffix + origTab.Substring(sep);
} }
@@ -238,7 +196,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style); vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(":"); int indxC = origTab.IndexOf(":");
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC); origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC);
@@ -255,7 +212,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style); vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(ut.Text); int indxC = origTab.IndexOf(ut.Text);
string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul "; string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul ";
@@ -294,7 +250,6 @@ namespace Volian.Print.Library
(myparent.MyItemInfo.MyPrevious.MyContent.Type == myparent.MyItemInfo.MyContent.Type))) (myparent.MyItemInfo.MyPrevious.MyContent.Type == myparent.MyItemInfo.MyContent.Type)))
{ {
//if (scriptCaution) //if (scriptCaution)
// Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
Rtf = Rtf.Replace("Caution:", " "); Rtf = Rtf.Replace("Caution:", " ");
Rtf = Rtf.Replace("Note:", " "); Rtf = Rtf.Replace("Note:", " ");
Rtf = Rtf.Replace("CAUTION:", " "); Rtf = Rtf.Replace("CAUTION:", " ");
@@ -305,19 +260,6 @@ namespace Volian.Print.Library
Rtf = Rtf.Replace("NOTE", " "); Rtf = Rtf.Replace("NOTE", " ");
} }
} }
//if (ScriptCaution && Rtf.Contains("Caution"))
//{
// // NSP script caution
// iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK);
// if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
// {
// //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12);
// // Capital 'C' exists as Symbol
// Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
// }
//}
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat // do positioning based on whether format has locations for section 'header'. If it's not centered, treat
// it's location more like a 'tab'. // it's location more like a 'tab'.
@@ -343,7 +285,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if // follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another // we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117 // window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(MyFont.Family, (float)MyFont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(MyFont.Family, (float)MyFont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(MyFont.Family, (float)MyFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size); float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size);
+2 -21
View File
@@ -1,31 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
public partial class vlnText : vlnPrintObject public partial class vlnText : vlnPrintObject
{ {
//public float Width public string Text { get; set; }
//{ public VE_Font MyFont { get; set; }
// get { return _CharsToTwips * Text.Length; }
//}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
private VE_Font _MyFont;
public VE_Font MyFont
{
get { return _MyFont; }
set { _MyFont = value; }
}
public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont) public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont)
{ {
MyContentByte = cb; MyContentByte = cb;
-30
View File
@@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Win32;
namespace Volian.Svg.Library
{
//public static class FontFind
//{
// public static string FileName(string fontName)
// {
// string baseFont = string.Empty;
// Regex find = new Regex(fontName + @".* ?\(.*\)", RegexOptions.IgnoreCase);
// RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Fonts");
// string[] values = regKey.GetValueNames();
// baseFont = regKey.GetValue(values[0]).ToString();
// foreach (string valueName in regKey.GetValueNames())
// {
// if (find.IsMatch(valueName))
// return regKey.GetValue(valueName).ToString();
// }
// return baseFont;
// }
// public static string FullFileName(string fontName)
// {
// return @"c:\windows\fonts\" + FileName(fontName);
// }
//}
}
+3 -32
View File
@@ -17,13 +17,6 @@ namespace Volian.Svg.Library
} }
public partial class Svg : SvgGroup public partial class Svg : SvgGroup
{ {
public void Draw(Graphics graphics)
{
//SetupInheritance();
//Console.WriteLine("{0}, DPI {1}", graphics.VisibleClipBounds, graphics.DpiX);
SvgParts.Draw(graphics, new SvgScale(DeviceDPI(graphics), graphics.VisibleClipBounds, _Width, _Height, _ViewBox), this, this);
//SvgParts.Draw(graphics, new SvgScale(100, graphics.VisibleClipBounds, _Width, _Height, _ViewBox));
}
public static float DeviceDPI(Graphics g) public static float DeviceDPI(Graphics g)
{ {
PointF[] tmp = { new PointF(g.DpiX, g.DpiY) }; PointF[] tmp = { new PointF(g.DpiX, g.DpiY) };
@@ -36,7 +29,6 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
//_MyLineSettings.Scale = scale.M(1F);
if (FillColor != Color.Transparent) if (FillColor != Color.Transparent)
using (Brush brush = new SolidBrush(FillColor)) using (Brush brush = new SolidBrush(FillColor))
graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2)); graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2));
@@ -50,7 +42,6 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
//_MyLineSettings.Scale = scale.M(1F);
if (FillColor != Color.Transparent) if (FillColor != Color.Transparent)
using (Brush brush = new SolidBrush(FillColor)) using (Brush brush = new SolidBrush(FillColor))
graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2)); graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2));
@@ -64,7 +55,6 @@ namespace Volian.Svg.Library
public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{ {
// Don't draw // Don't draw
//_SvgParts.Draw(graphics, myScale);
} }
} }
public partial class SvgEllipse : SvgShapePart public partial class SvgEllipse : SvgShapePart
@@ -85,7 +75,7 @@ namespace Volian.Svg.Library
public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
_SvgParts.Draw(graphics, myScale, mySvg, this); SvgParts.Draw(graphics, myScale, mySvg, this);
} }
} }
public partial class SvgImage : SvgPart public partial class SvgImage : SvgPart
@@ -130,26 +120,9 @@ namespace Volian.Svg.Library
graphics.DrawRectangle(pen, scale.X(X),scale.Y(Y), scale.M(Width), scale.M(Height)); graphics.DrawRectangle(pen, scale.X(X),scale.Y(Y), scale.M(Width), scale.M(Height));
} }
} }
//public partial class SvgRtf : SvgShapePart
//{
// //private static float _Factor = 1.085F; // 20 point Arial Font
// public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
// {
// SetupInheritance(myParent.MyInheritedSettings);
// _MyFontSettings.Scale = scale.M(1F);
// }
// private float YAdjustment(Graphics gr, Font fnt)
// {
// int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style);
// int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style);
// float gth = fnt.GetHeight(gr);
// float fAsc = (yAsc * gth) / yLS;
// return -fAsc;
// }
//}
public partial class SvgText : SvgShapePart public partial class SvgText : SvgShapePart
{ {
//private static float _Factor = 1.085F; // 20 point Arial Font
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
@@ -175,8 +148,6 @@ namespace Volian.Svg.Library
private float YAdjustment(Graphics gr, Font fnt) private float YAdjustment(Graphics gr, Font fnt)
{ {
int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style); int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style);
//int yDesc = fnt.FontFamily.GetCellDescent(fnt.Style);
//int yEm = fnt.FontFamily.GetEmHeight(fnt.Style);
int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style); int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style);
float gth = fnt.GetHeight(gr); float gth = fnt.GetHeight(gr);
float fh = fnt.Size; float fh = fnt.Size;
@@ -189,7 +160,7 @@ namespace Volian.Svg.Library
public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
mySvg[_UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this); mySvg[UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this);
} }
} }
} }
+9 -49
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
@@ -39,82 +37,44 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region Width #region Width
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Width public SvgMeasurement Width { get; set; } = new SvgMeasurement();
{
get { return _Width; }
set { _Width = value; }
}
[System.ComponentModel.DefaultValueAttribute("0")] [System.ComponentModel.DefaultValueAttribute("0")]
[XmlAttribute("width")] [XmlAttribute("width")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Width_XmlSurrogate public string Width_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
//private string _Watermark="";
//[XmlAttribute("watermark")]
//public string Watermark
//{
// get { return _Watermark; }
// set { _Watermark = value; }
//}
//public void SetValidWaterMark(string token, string watermark)
//{
// if (token == "{" + watermark.ToUpper() + "PAGE}" )
// _Watermark = watermark;
//}
#endregion #endregion
#region Height #region Height
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Height public SvgMeasurement Height { get; set; } = new SvgMeasurement();
{
get { return _Height; }
set { _Height = value; }
}
[System.ComponentModel.DefaultValueAttribute("0")] [System.ComponentModel.DefaultValueAttribute("0")]
[XmlAttribute("height")] [XmlAttribute("height")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate public string Height_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region ViewBox #region ViewBox
private SvgViewBox _ViewBox = new SvgViewBox("0 0 0 0");
[XmlIgnore] [XmlIgnore]
public SvgViewBox ViewBox public SvgViewBox ViewBox { get; set; } = new SvgViewBox("0 0 0 0");
{
get { return _ViewBox; }
set { _ViewBox = value; }
}
[System.ComponentModel.DefaultValueAttribute("0 0 0 0")] [System.ComponentModel.DefaultValueAttribute("0 0 0 0")]
[XmlAttribute("viewBox")] [XmlAttribute("viewBox")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string SVGViewBox_XmlSurrogate public string SVGViewBox_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgViewBox>.GetString(_ViewBox); } get { return SvgXmlConverter<SvgViewBox>.GetString(ViewBox); }
set { _ViewBox = SvgXmlConverter<SvgViewBox>.GetObject(value); } set { ViewBox = SvgXmlConverter<SvgViewBox>.GetObject(value); }
} }
#endregion #endregion
//#region Setup Inheritance
//private void SetupInheritance()
//{
// SvgParts.SetupInheritance(_MyInheritedSettings);
//}
////override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
////{
//// _MyInheritedSettings.MyParentsSettings = myParentsSettings;
//// SvgParts.SetupInheritance(_MyInheritedSettings);
////}
//#endregion
#region Part Lookup #region Part Lookup
private Dictionary<string, SvgPart> _LookUp; private Dictionary<string, SvgPart> _LookUp;
[XmlIgnore] [XmlIgnore]
+13 -33
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,65 +10,48 @@ namespace Volian.Svg.Library
public SvgArc() { ;} public SvgArc() { ;}
public SvgArc(PointF location, float radius, float startAngle, float endAngle, Color fillColor, Color lineColor, float lineWidth) public SvgArc(PointF location, float radius, float startAngle, float endAngle, Color fillColor, Color lineColor, float lineWidth)
{ {
_CX.Value = location.X; CX.Value = location.X;
_CY.Value = location.Y; CY.Value = location.Y;
_Radius.Value = radius; Radius.Value = radius;
FillColor = fillColor; FillColor = fillColor;
LineColor = lineColor; LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth); LineWidth = new SvgMeasurement(lineWidth);
} }
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion #endregion
#region Location #region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CX public SvgMeasurement CX { get; set; } = new SvgMeasurement();
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")] [XmlAttribute("cx")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate public string CX_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CY public SvgMeasurement CY { get; set; } = new SvgMeasurement();
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")] [XmlAttribute("cy")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate public string CY_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Radius #region Radius
private SvgMeasurement _Radius = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Radius public SvgMeasurement Radius { get; set; } = new SvgMeasurement();
{
get { return _Radius; }
set { _Radius = value; }
}
[XmlAttribute("r")] [XmlAttribute("r")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Radius); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Radius); }
set { _Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Angles
#endregion
} }
} }
+13 -31
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,62 +10,47 @@ namespace Volian.Svg.Library
public SvgCircle() { ;} public SvgCircle() { ;}
public SvgCircle(PointF location, float radius, Color fillColor, Color lineColor, float lineWidth) public SvgCircle(PointF location, float radius, Color fillColor, Color lineColor, float lineWidth)
{ {
_CX.Value = location.X; CX.Value = location.X;
_CY.Value = location.Y; CY.Value = location.Y;
_Radius.Value = radius; Radius.Value = radius;
FillColor = fillColor; FillColor = fillColor;
LineColor = lineColor; LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth); LineWidth = new SvgMeasurement(lineWidth);
} }
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion #endregion
#region Location #region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CX public SvgMeasurement CX { get; set; } = new SvgMeasurement();
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")] [XmlAttribute("cx")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate public string CX_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CY public SvgMeasurement CY { get; set; } = new SvgMeasurement();
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")] [XmlAttribute("cy")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate public string CY_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Radius #region Radius
private SvgMeasurement _Radius = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Radius public SvgMeasurement Radius { get; set; } = new SvgMeasurement();
{
get { return _Radius; }
set { _Radius = value; }
}
[XmlAttribute("r")] [XmlAttribute("r")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Radius); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Radius); }
set { _Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Radius = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
} }
-7
View File
@@ -1,10 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
public partial class SvgDefine : SvgGroup public partial class SvgDefine : SvgGroup
+18 -40
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,78 +10,59 @@ namespace Volian.Svg.Library
public SvgEllipse() { ;} public SvgEllipse() { ;}
public SvgEllipse(PointF location, float radiusX, float radiusY, Color fillColor, Color lineColor, float lineWidth) public SvgEllipse(PointF location, float radiusX, float radiusY, Color fillColor, Color lineColor, float lineWidth)
{ {
_CX.Value = location.X; CX.Value = location.X;
_CY.Value = location.Y; CY.Value = location.Y;
_RX.Value = radiusX; RX.Value = radiusX;
_RY.Value = radiusY; RY.Value = radiusY;
FillColor = fillColor; FillColor = fillColor;
LineColor = lineColor; LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth); LineWidth = new SvgMeasurement(lineWidth);
} }
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion #endregion
#region Location #region Location
private SvgMeasurement _CX = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CX public SvgMeasurement CX { get; set; } = new SvgMeasurement();
{
get { return _CX; }
set { _CX = value; }
}
[XmlAttribute("cx")] [XmlAttribute("cx")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CX_XmlSurrogate public string CX_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CX); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CX); }
set { _CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _CY = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement CY public SvgMeasurement CY { get; set; } = new SvgMeasurement();
{
get { return _CY; }
set { _CY = value; }
}
[XmlAttribute("cy")] [XmlAttribute("cy")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string CY_XmlSurrogate public string CY_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_CY); } get { return SvgXmlConverter<SvgMeasurement>.GetString(CY); }
set { _CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { CY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Size #region Size
private SvgMeasurement _RX = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement RX public SvgMeasurement RX { get; set; } = new SvgMeasurement();
{
get { return _RX; }
set { _RX = value; }
}
[XmlAttribute("rx")] [XmlAttribute("rx")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string RX_RXmlSurrogate public string RX_RXmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_RX); } get { return SvgXmlConverter<SvgMeasurement>.GetString(RX); }
set { _RX = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { RX = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _RY = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement RY public SvgMeasurement RY { get; set; } = new SvgMeasurement();
{
get { return _RY; }
set { _RY = value; }
}
[XmlAttribute("ry")] [XmlAttribute("ry")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string RY_XmlSurrogate public string RY_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_RY); } get { return SvgXmlConverter<SvgMeasurement>.GetString(RY); }
set { _RY = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { RY = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
} }
+6 -33
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
@@ -9,34 +6,18 @@ namespace Volian.Svg.Library
{ {
#region ctor #region ctor
public SvgFillSettings() { ;} public SvgFillSettings() { ;}
public SvgFillSettings(Color myColor) public SvgFillSettings(Color myColor) => Fill = ColorTranslator.ToHtml(myColor);
{
_Fill = ColorTranslator.ToHtml(myColor);
}
//public SvgFillSettings(string myFill)
//{
// _Fill = myFill;
//}
#endregion #endregion
#region Inheritance #region Inheritance
private SvgFillSettings _MyParentsSettings = null; public SvgFillSettings MyParentsSettings { get; set; } = null;
public SvgFillSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion #endregion
#region Internal Inherited Properties #region Internal Inherited Properties
protected string InheritedFill protected string InheritedFill
{ {
get get
{ {
// Fill = "", "0" - Default, otherwise the value if (Fill != "" && Fill != "0" && Fill.ToLower() != "empty") return Fill; // Current Value
if (_Fill != "" && _Fill != "0" && _Fill.ToLower() != "empty") return _Fill; // Current Value if (MyParentsSettings != null) return MyParentsSettings.InheritedFill; // Inherited
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFill; // Inherited
return "Black"; // Default return "Black"; // Default
} }
} }
@@ -54,20 +35,12 @@ namespace Volian.Svg.Library
} }
set set
{ {
if (value == Color.Transparent || value == Color.Empty) Fill = value == Color.Transparent || value == Color.Empty ? "none" : ColorTranslator.ToHtml(value);
_Fill = "none";
else
_Fill = ColorTranslator.ToHtml(value);
} }
} }
#endregion #endregion
#region Properties #region Properties
private string _Fill = string.Empty; // Default value is None public string Fill { get; set; } = string.Empty;
public string Fill
{
get { return _Fill; }
set { _Fill = value; }
}
#endregion #endregion
} }
} }
+6 -32
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
@@ -17,25 +14,9 @@ namespace Volian.Svg.Library
_FontWeight = ((myFont.Style & FontStyle.Bold) == FontStyle.Bold ? "bold" : "normal"); _FontWeight = ((myFont.Style & FontStyle.Bold) == FontStyle.Bold ? "bold" : "normal");
_TextDecoration = ((myFont.Style & FontStyle.Underline) == FontStyle.Underline ? "underline" : "normal"); _TextDecoration = ((myFont.Style & FontStyle.Underline) == FontStyle.Underline ? "underline" : "normal");
} }
//public SvgFontSettings(string myFontFamily, string myFontSize, string mySvgStyle, string myFontWeight, string myTextDecoration)
//{
// _FontFamilyName = myFontFamily;
// _FontSize = myFontSize;
// _SVGFontStyle = mySvgStyle;
// _FontWeight = myFontWeight;
// _TextDecoration = myTextDecoration;
//}
#endregion #endregion
#region Inheritance #region Inheritance
private SvgFontSettings _MyParentsSettings = null; public SvgFontSettings MyParentsSettings { get; set; } = null;
public SvgFontSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion #endregion
#region Internal Inherited Properties #region Internal Inherited Properties
protected string InheritedFontFamily protected string InheritedFontFamily
@@ -43,7 +24,7 @@ namespace Volian.Svg.Library
get get
{ {
if (_FontFamily != "") return _FontFamily; if (_FontFamily != "") return _FontFamily;
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontFamily; // Default if (MyParentsSettings != null) return MyParentsSettings.InheritedFontFamily; // Default
return "Arial"; // Absolute Default return "Arial"; // Absolute Default
} }
} }
@@ -52,7 +33,7 @@ namespace Volian.Svg.Library
get get
{ {
if (_FontSize != "") return _FontSize; // Current Value if (_FontSize != "") return _FontSize; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontSize; // Default if (MyParentsSettings != null) return MyParentsSettings.InheritedFontSize; // Default
return "9PT"; // Absolute Default return "9PT"; // Absolute Default
} }
} }
@@ -61,7 +42,7 @@ namespace Volian.Svg.Library
get get
{ {
if (_SVGFontStyle != "") return _SVGFontStyle; // Current Value if (_SVGFontStyle != "") return _SVGFontStyle; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontStyle;// Default if (MyParentsSettings != null) return MyParentsSettings.InheritedFontStyle;// Default
return "normal"; // Absolute Default return "normal"; // Absolute Default
} }
} }
@@ -70,7 +51,7 @@ namespace Volian.Svg.Library
get get
{ {
if (_FontWeight != "") return _FontWeight;// Current Value if (_FontWeight != "") return _FontWeight;// Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontWeight;// Default if (MyParentsSettings != null) return MyParentsSettings.InheritedFontWeight;// Default
return "normal"; // Absolute Default return "normal"; // Absolute Default
} }
} }
@@ -79,7 +60,7 @@ namespace Volian.Svg.Library
get get
{ {
if (_TextDecoration != "") return _TextDecoration;// Current Value if (_TextDecoration != "") return _TextDecoration;// Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedTextDecoration;// Default if (MyParentsSettings != null) return MyParentsSettings.InheritedTextDecoration;// Default
return "normal"; // Absolute Default return "normal"; // Absolute Default
} }
} }
@@ -110,13 +91,6 @@ namespace Volian.Svg.Library
} }
set set
{ {
// This was disposing fonts that are saved in our static dictionary.
// caused problems with the step editor display after printing (found with Wolf Creek Chem procedure RW-G02 Step 6.1.17) - jsj 7/14/2017
//if (_Font != null)
//{
// Console.WriteLine("font dispose {0}, {1}", _Font, _Font.Style);
// //_Font.Dispose();
//}
if (value != null) if (value != null)
{ {
_FontFamily = value.FontFamily.Name; _FontFamily = value.FontFamily.Name;
+7 -34
View File
@@ -1,38 +1,22 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
public partial class SvgGroup : SvgPartInheritance public partial class SvgGroup : SvgPartInheritance
{ {
#region Description #region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")] [XmlElement("desc")]
public string Description public string Description { get; set; } = string.Empty;
{
get { return _Description; }
set { _Description = value; }
}
#endregion #endregion
#region Title #region Title
private string _Title = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("title")] [XmlElement("title")]
public string Title public string Title { get; set; } = string.Empty;
{
get { return _Title; }
set { _Title = value; }
}
#endregion #endregion
#region Parts #region Parts
// SVG Parts // SVG Parts
SvgParts _SvgParts = new SvgParts();
//[XmlElement("foreignObject", typeof(SvgRtf))]
[XmlElement("use", typeof(SvgUse))] [XmlElement("use", typeof(SvgUse))]
[XmlElement("image", typeof(SvgImage))] [XmlElement("image", typeof(SvgImage))]
[XmlElement("text", typeof(SvgText))] [XmlElement("text", typeof(SvgText))]
@@ -43,22 +27,14 @@ namespace Volian.Svg.Library
[XmlElement("svg", typeof(Svg))] [XmlElement("svg", typeof(Svg))]
[XmlElement("g", typeof(SvgGroup))] [XmlElement("g", typeof(SvgGroup))]
[XmlElement("defs", typeof(SvgDefine))] [XmlElement("defs", typeof(SvgDefine))]
public SvgParts SvgParts public SvgParts SvgParts { get; set; } = new SvgParts();
{
get { return _SvgParts; }
set { _SvgParts = value; }
}
public SvgPart Add(SvgPart svgPart) public SvgPart Add(SvgPart svgPart)
{ {
_SvgParts.Add(svgPart); SvgParts.Add(svgPart);
return svgPart; return svgPart;
} }
public void RemoveAt(int i) public void RemoveAt(int i) => SvgParts.RemoveAt(i);
{ public int Count => SvgParts.Count;
_SvgParts.RemoveAt(i);
}
public int Count
{ get { return _SvgParts.Count; } }
#endregion #endregion
#region Dictionary of Parts #region Dictionary of Parts
internal override void AddLookup(Dictionary<string, SvgPart> lookUp) internal override void AddLookup(Dictionary<string, SvgPart> lookUp)
@@ -67,9 +43,6 @@ namespace Volian.Svg.Library
SvgParts.AddLookup(lookUp); SvgParts.AddLookup(lookUp);
} }
#endregion #endregion
public override string ToString() public override string ToString() => ID;
{
return ID;
}
} }
} }
+20 -46
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,87 +10,64 @@ namespace Volian.Svg.Library
public SvgImage() { ;} public SvgImage() { ;}
public SvgImage(PointF location, SizeF size, string path) public SvgImage(PointF location, SizeF size, string path)
{ {
_X.Value = location.X; X.Value = location.X;
_Y.Value = location.Y; Y.Value = location.Y;
_Width.Value = size.Width; Width.Value = size.Width;
_Height.Value = size.Height; Height.Value = size.Height;
_ImagePath = path; ImagePath = path;
} }
#endregion #endregion
#region Location #region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X public SvgMeasurement X { get; set; } = new SvgMeasurement();
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")] [XmlAttribute("x")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y public SvgMeasurement Y { get; set; } = new SvgMeasurement();
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")] [XmlAttribute("y")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate public string Y_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Size #region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Width public SvgMeasurement Width { get; set; } = new SvgMeasurement();
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")] [XmlAttribute("width")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate public string Width_WidthmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Height public SvgMeasurement Height { get; set; } = new SvgMeasurement();
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")] [XmlAttribute("height")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate public string Height_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Path to Image File #region Path to Image File
private string _ImagePath = null;
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string ImagePath public string ImagePath { get; set; } = null;
{
get { return _ImagePath; }
set { _ImagePath = value; }
}
#endregion #endregion
} }
} }
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
internal class SvgInheritedSettings internal class SvgInheritedSettings
@@ -21,67 +17,52 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region Line Settings #region Line Settings
private SvgLineSettings _MyLineSettings = new SvgLineSettings(); public SvgLineSettings MyLineSettings { get; set; } = new SvgLineSettings();
public SvgLineSettings MyLineSettings
{
get { return _MyLineSettings; }
set { _MyLineSettings = value; }
}
public string Stroke public string Stroke
{ {
get { return _MyLineSettings.Stroke; } get { return MyLineSettings.Stroke; }
set { _MyLineSettings.Stroke = value; } set { MyLineSettings.Stroke = value; }
} }
public string StrokeWidth public string StrokeWidth
{ {
get { return _MyLineSettings.StrokeWidth; } get { return MyLineSettings.StrokeWidth; }
set { _MyLineSettings.StrokeWidth = value; } set { MyLineSettings.StrokeWidth = value; }
} }
#endregion #endregion
#region Fill Settings #region Fill Settings
private SvgFillSettings _MyFillSettings = new SvgFillSettings(); internal SvgFillSettings MyFillSettings { get; set; } = new SvgFillSettings();
internal SvgFillSettings MyFillSettings
{
get { return _MyFillSettings; }
set { _MyFillSettings = value; }
}
public string Fill public string Fill
{ {
get { return _MyFillSettings.Fill; } get { return MyFillSettings.Fill; }
set { _MyFillSettings.Fill = value; } set { MyFillSettings.Fill = value; }
} }
#endregion #endregion
#region Font Settings #region Font Settings
private SvgFontSettings _MyFontSettings = new SvgFontSettings(); internal SvgFontSettings MyFontSettings { get; set; } = new SvgFontSettings();
internal SvgFontSettings MyFontSettings
{
get { return _MyFontSettings; }
set { _MyFontSettings = value; }
}
public string FontFamily public string FontFamily
{ {
get { return _MyFontSettings.FontFamily; } get { return MyFontSettings.FontFamily; }
set { _MyFontSettings.FontFamily = value; } set { MyFontSettings.FontFamily = value; }
} }
public string FontSize public string FontSize
{ {
get { return _MyFontSettings.FontSize; } get { return MyFontSettings.FontSize; }
set { _MyFontSettings.FontSize = value; } set { MyFontSettings.FontSize = value; }
} }
public string SVGFontStyle public string SVGFontStyle
{ {
get { return _MyFontSettings.SVGFontStyle; } get { return MyFontSettings.SVGFontStyle; }
set { _MyFontSettings.SVGFontStyle = value; } set { MyFontSettings.SVGFontStyle = value; }
} }
public string FontWeight public string FontWeight
{ {
get { return _MyFontSettings.FontWeight; } get { return MyFontSettings.FontWeight; }
set { _MyFontSettings.FontWeight = value; } set { MyFontSettings.FontWeight = value; }
} }
public string TextDecoration public string TextDecoration
{ {
get { return _MyFontSettings.TextDecoration; } get { return MyFontSettings.TextDecoration; }
set { _MyFontSettings.TextDecoration = value; } set { MyFontSettings.TextDecoration = value; }
} }
#endregion #endregion
} }
+19 -95
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,146 +11,72 @@ namespace Volian.Svg.Library
public SvgLine() { ;} public SvgLine() { ;}
public SvgLine(PointF location1, PointF location2, Color lineColor, float lineWidth) public SvgLine(PointF location1, PointF location2, Color lineColor, float lineWidth)
{ {
_X1.Value = location1.X; X1.Value = location1.X;
_Y1.Value = location1.Y; Y1.Value = location1.Y;
_X2.Value = location2.X; X2.Value = location2.X;
_Y2.Value = location2.Y; Y2.Value = location2.Y;
LineColor = lineColor; LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth); LineWidth = new SvgMeasurement(lineWidth);
} }
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion #endregion
#region Location1 #region Location1
private SvgMeasurement _X1 = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X1 public SvgMeasurement X1 { get; set; } = new SvgMeasurement();
{
get { return _X1; }
set { _X1 = value; }
}
[XmlAttribute("x1")] [XmlAttribute("x1")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X1_XmlSurrogate public string X1_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X1); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X1); }
set { _X1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y1 = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y1 public SvgMeasurement Y1 { get; set; } = new SvgMeasurement();
{
get { return _Y1; }
set { _Y1 = value; }
}
[XmlAttribute("y1")] [XmlAttribute("y1")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y1_XmlSurrogate public string Y1_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y1); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y1); }
set { _Y1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y1 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Location2 #region Location2
private SvgMeasurement _X2 = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X2 public SvgMeasurement X2 { get; set; } = new SvgMeasurement();
{
get { return _X2; }
set { _X2 = value; }
}
[XmlAttribute("x2")] [XmlAttribute("x2")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X2_XmlSurrogate public string X2_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X2); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X2); }
set { _X2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y2 = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y2 public SvgMeasurement Y2 { get; set; } = new SvgMeasurement();
{
get { return _Y2; }
set { _Y2 = value; }
}
[XmlAttribute("y2")] [XmlAttribute("y2")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate public string Y_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y2); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y2); }
set { _Y2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y2 = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Description #region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")] [XmlElement("desc")]
public string Description public string Description { get; set; } = string.Empty;
{
get { return _Description; }
set { _Description = value; }
}
#endregion #endregion
#region LineColor #region LineColor
//protected Color _LineColor = Color.Empty;
//[XmlIgnoreAttribute()]
//public Color LineColor
//{
// get { return _LineWidth.Value == 0 ? Color.LightGray : _LineColor == Color.Empty ? Color.Gray : _LineColor; }
// set { _LineColor = value; }
//}
private Color AdjustColorForWidth(Color myColor, float myWidth) private Color AdjustColorForWidth(Color myColor, float myWidth)
{ {
if (myWidth > 1F) return myColor; if (myWidth > 1F) return myColor;
//Console.WriteLine("Line Width = {0}, Alpha = {1}", myWidth, Convert.ToInt32(myWidth * 255)); //Console.WriteLine("Line Width = {0}, Alpha = {1}", myWidth, Convert.ToInt32(myWidth * 255));
return Color.FromArgb(Convert.ToInt32(myWidth * 255), myColor); return Color.FromArgb(Convert.ToInt32(myWidth * 255), myColor);
} }
// Serializes the 'BackgroundColor' Color to XML.
//[System.ComponentModel.DefaultValueAttribute("none")]
//[XmlAttribute("stroke")]
//public string Stroke
//{
// get { return _LineColor == Color.Empty ? "none" : _LineColor == Color.Black ? "" : ColorTranslator.ToHtml(_LineColor); }
// set { _LineColor = (value == "none" ? Color.Empty : (value == "" ? Color.Empty : ColorTranslator.FromHtml(value))); }
//}
#endregion
#region LineWidth
//private SvgMeasurement GetLineWidth()
//{
// if (_LineWidth.Value == -1) return new SvgMeasurement(1F);// Minimum Strokewidth
// if (_LineWidth.Value == 0) return new SvgMeasurement(.01F);// Minimum Strokewidth
// if (_LineColor == Color.Empty) return new SvgMeasurement( .01F);// No Color - Minimum Strokewidth
// return _LineWidth;
//}
//private SvgMeasurement _LineWidth = new SvgMeasurement();
//[XmlIgnore]
//public SvgMeasurement LineWidth
//{
// get { return _LineWidth; }
// set { _LineWidth = value; }
//}
//[XmlAttribute("stroke-width")]
//[Browsable(false)]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public string LineWidth_XmlSurrogate
//{
// get
// {
// if (_LineWidth.Value == -1)
// return "none";
// return VolianXmlConverter<SvgMeasurement>.GetString(_LineWidth);
// }
// set
// {
// if (value == "none")
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject("-1");
// else
// _LineWidth = VolianXmlConverter<SvgMeasurement>.GetObject(value);
// }
//}
#endregion #endregion
} }
} }
+1 -7
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
@@ -52,10 +49,7 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region Setup Inheritance #region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings;
{
_MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings;
}
#endregion #endregion
} }
} }
+15 -68
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
@@ -13,34 +8,20 @@ namespace Volian.Svg.Library
public SvgLineSettings() { ;} public SvgLineSettings() { ;}
public SvgLineSettings(Color myColor, SvgMeasurement myWidth) public SvgLineSettings(Color myColor, SvgMeasurement myWidth)
{ {
_Stroke = ColorTranslator.ToHtml(myColor); Stroke = ColorTranslator.ToHtml(myColor);
_StrokeWidth = myWidth.ToString(); StrokeWidth = myWidth.ToString();
} }
//public SvgLineSettings(string myStroke, string myStrokeWidth)
//{
// _Stroke = myStroke;
// _StrokeWidth = myStrokeWidth;
//}
#endregion #endregion
#region Inheritance #region Inheritance
private SvgLineSettings _MyParentsSettings = null; public SvgLineSettings MyParentsSettings { get; set; } = null;
public SvgLineSettings MyParentsSettings
{
get { return _MyParentsSettings; }
set
{
_MyParentsSettings = value;
}
}
#endregion #endregion
#region Internal Inherited Properties #region Internal Inherited Properties
protected string InheritedStroke protected string InheritedStroke
{ {
get get
{ {
// Stroke = "", "0" - Default, otherwise the value if (Stroke != "" && Stroke != "0") return Stroke; // Current Value
if (_Stroke != "" && _Stroke != "0") return _Stroke; // Current Value if (MyParentsSettings != null) return MyParentsSettings.InheritedStroke;// Inherited
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedStroke;// Inherited
return "None"; // Default return "None"; // Default
} }
} }
@@ -49,68 +30,47 @@ namespace Volian.Svg.Library
get get
{ {
// StrokeWidth = "", "none" - Default, otherwise the value // StrokeWidth = "", "none" - Default, otherwise the value
if (_StrokeWidth != "" && _StrokeWidth != "none") return _StrokeWidth; // Current Value if (StrokeWidth != "" && StrokeWidth != "none") return StrokeWidth; // Current Value
if (_MyParentsSettings != null) return _MyParentsSettings.InheritedLineWidth; // Inherited if (MyParentsSettings != null) return MyParentsSettings.InheritedLineWidth; // Inherited
return "1PX"; // Default return "1PX"; // Default
} }
} }
//protected string InheritedOutlineWidth
//{
// get
// {
// // StrokeWidth = "", "none" - Default, otherwise the value
// if (_StrokeWidth != "" && _StrokeWidth.ToLower() != "none") return _StrokeWidth; // Current Value
// if (_MyParent != null) return _MyParent.InheritedLineWidth; // Inherited
// return "1PX"; // Default
// }
//}
#endregion #endregion
#region Inherited Values #region Inherited Values
public SvgMeasurement LineWidth public SvgMeasurement LineWidth
{ {
get get
{ {
// Stroke = "None" - Light, otherwise the value
// StrokeWidth = "None" Light, otherwise the value
string myStroke = InheritedStroke; string myStroke = InheritedStroke;
string myWidth = InheritedLineWidth; string myWidth = InheritedLineWidth;
//if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none") // Light
// return new SvgMeasurement(.001F, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement; return myMeasurement;
} }
set set
{ {
_StrokeWidth = value.ToString(); StrokeWidth = value.ToString();
} }
} }
public SvgMeasurement OutlineWidth public SvgMeasurement OutlineWidth
{ {
get get
{ {
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke; string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
string myWidth = InheritedLineWidth; string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate
return new SvgMeasurement(0, E_MeasurementUnits.PX); return new SvgMeasurement(0, E_MeasurementUnits.PX);
SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); SvgMeasurement myMeasurement = new SvgMeasurement(myWidth);
//myMeasurement.Value *= _Scale;
return myMeasurement; return myMeasurement;
} }
set set
{ {
_StrokeWidth = value.ToString(); StrokeWidth = value.ToString();
} }
} }
public Color LineColor public Color LineColor
{ {
get get
{ {
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "None" Eliminate, otherwise the value
string myStroke = InheritedStroke; string myStroke = InheritedStroke;
string myWidth = InheritedLineWidth; string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none" || myWidth == "0") // Light if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none" || myWidth == "0") // Light
@@ -120,9 +80,9 @@ namespace Volian.Svg.Library
set set
{ {
if (value == Color.Empty) if (value == Color.Empty)
_Stroke = "none"; Stroke = "none";
else else
_Stroke = ColorTranslator.ToHtml(value); Stroke = ColorTranslator.ToHtml(value);
} }
} }
@@ -130,10 +90,7 @@ namespace Volian.Svg.Library
{ {
get get
{ {
// Stroke = "None" - Eliminate, otherwise the value
// StrokeWidth = "0" Eliminate, otherwise the value
string myStroke = InheritedStroke; string myStroke = InheritedStroke;
//string myWidth = InheritedOutlineWidth;
string myWidth = InheritedLineWidth; string myWidth = InheritedLineWidth;
if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate
return Color.Empty; return Color.Empty;
@@ -142,26 +99,16 @@ namespace Volian.Svg.Library
set set
{ {
if (value == Color.Empty) if (value == Color.Empty)
_Stroke = "none"; Stroke = "none";
else else
_Stroke = ColorTranslator.ToHtml(value); Stroke = ColorTranslator.ToHtml(value);
} }
} }
#endregion #endregion
#region Properties #region Properties
private string _Stroke = string.Empty; // Default value is None public string Stroke { get; set; } = string.Empty;
public string Stroke public string StrokeWidth { get; set; } = string.Empty;
{
get { return _Stroke; }
set { _Stroke = value; }
}
private string _StrokeWidth = string.Empty; // Default value is 1PX
public string StrokeWidth
{
get { return _StrokeWidth; }
set { _StrokeWidth = value; }
}
#endregion #endregion
} }
} }
+30 -104
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Volian.Svg.Library namespace Volian.Svg.Library
@@ -57,24 +53,24 @@ namespace Volian.Svg.Library
public SvgMeasurement() { ;} public SvgMeasurement() { ;}
public SvgMeasurement(int value) public SvgMeasurement(int value)
{ {
_Value = Convert.ToSingle(value); Value = Convert.ToSingle(value);
_Units = E_MeasurementUnits.PX; _Units = E_MeasurementUnits.PX;
} }
public SvgMeasurement(float value) public SvgMeasurement(float value)
{ {
_Value = value; Value = value;
_Units = E_MeasurementUnits.PX; _Units = E_MeasurementUnits.PX;
} }
public SvgMeasurement(float value, E_MeasurementUnits units) public SvgMeasurement(float value, E_MeasurementUnits units)
{ {
_Value = value; Value = value;
_Units = units; _Units = units;
} }
public SvgMeasurement(string val) public SvgMeasurement(string val)
{ {
val = val.Replace("{size}", "10");// B2020-145 BWD SAMG TSG-6 Fix for Base Format {size} parameter rather than font size val = val.Replace("{size}", "10");// B2020-145 BWD SAMG TSG-6 Fix for Base Format {size} parameter rather than font size
MatchCollection mc = Regex.Matches(val.ToLower(), "([+-]?[.0-9]+)|(in|cm|mm|em|ex|pc|pt|px|percentage)"); MatchCollection mc = Regex.Matches(val.ToLower(), "([+-]?[.0-9]+)|(in|cm|mm|em|ex|pc|pt|px|percentage)");
_Value = Convert.ToSingle(mc[0].Value); Value = Convert.ToSingle(mc[0].Value);
if (mc.Count == 2) if (mc.Count == 2)
{ {
//Console.WriteLine("{0} - '{1}'", val, mc[1].Value.ToUpper()); //Console.WriteLine("{0} - '{1}'", val, mc[1].Value.ToUpper());
@@ -93,15 +89,11 @@ namespace Volian.Svg.Library
{ {
float tmp = GetSizeInPoints(DPI); float tmp = GetSizeInPoints(DPI);
_Units = value; _Units = value;
_Value *= (tmp / GetSizeInPoints(DPI)); Value *= (tmp / GetSizeInPoints(DPI));
} }
} }
private float _Value;
public float Value public float Value { get; set; }
{
get { return _Value; }
set { _Value = value; }
}
#endregion #endregion
#region ToString #region ToString
public override string ToString() public override string ToString()
@@ -109,92 +101,43 @@ namespace Volian.Svg.Library
switch (_Units) switch (_Units)
{ {
case E_MeasurementUnits.PX: // Default case E_MeasurementUnits.PX: // Default
return string.Format("{0}", _Value); return string.Format("{0}", Value);
case E_MeasurementUnits.PERCENTAGE: // Precentage is preceded by a space case E_MeasurementUnits.PERCENTAGE: // Precentage is preceded by a space
return string.Format("{0} {1}", _Value, _Units); return string.Format("{0} {1}", Value, _Units);
} }
return string.Format("{0}{1}", _Value, _Units); return string.Format("{0}{1}", Value, _Units);
} }
#endregion #endregion
//public float SizeInPixels
//{
// get
// {
// switch (_Units)
// {
// case E_MeasurementUnits.PT: //Points - 72 per inch
// return _Value * DPI / 72F;
// case E_MeasurementUnits.PC: //Picas - 6 per inch
// return _Value * DPI / 6F;
// case E_MeasurementUnits.IN: //inches
// return _Value * DPI;
// case E_MeasurementUnits.CM: // Centimeter
// return _Value * DPI / 2.54F;
// case E_MeasurementUnits.MM: // Millimeter
// return _Value * DPI / 25.4F;
// case E_MeasurementUnits.EM: // EMs
// return _Value * DPI / 8;
// case E_MeasurementUnits.EX: // EXs
// return _Value * DPI / 16;
// default:
// return _Value;
// }
// }
//}
public float GetSizeInPoints(float myDPI) public float GetSizeInPoints(float myDPI)
{ {
switch (_Units) switch (_Units)
{ {
case E_MeasurementUnits.PX: //Pixels myDPI per inch case E_MeasurementUnits.PX: //Pixels myDPI per inch
return _Value * 72F / myDPI; return Value * 72F / myDPI;
case E_MeasurementUnits.PC: //Picas - 6 per inch case E_MeasurementUnits.PC: //Picas - 6 per inch
return _Value * 72F / 6F; return Value * 72F / 6F;
case E_MeasurementUnits.IN: //inches case E_MeasurementUnits.IN: //inches
return _Value * 72F; return Value * 72F;
case E_MeasurementUnits.CM: // Centimeter case E_MeasurementUnits.CM: // Centimeter
return _Value * 72F / 2.54F; return Value * 72F / 2.54F;
case E_MeasurementUnits.MM: // Millimeter case E_MeasurementUnits.MM: // Millimeter
return _Value * 72F / 25.4F; return Value * 72F / 25.4F;
case E_MeasurementUnits.EM: // EMs case E_MeasurementUnits.EM: // EMs
return _Value * 72F / 8; return Value * 72F / 8;
case E_MeasurementUnits.EX: // EXs case E_MeasurementUnits.EX: // EXs
return _Value * 72F / 16; return Value * 72F / 16;
default: // Points default: // Points
return _Value; return Value;
} }
} }
//public float SizeInPoints public float GetSizeInPixels(float myDPI) => GetSizeInPoints(myDPI) * myDPI / 72F;
//{ get { return SizeInPixels * 72 / DPI; } } public float GetSizeInInches(float myDPI) => GetSizeInPoints(myDPI) / 72F;
//public float SizeInInches public float GetSizeInCentimeters(float myDPI) => GetSizeInPoints(myDPI) * 2.54F / 72F;
//{ get { return SizeInPixels / DPI; } } public float GetSizeInMillimeters(float myDPI) => GetSizeInPoints(myDPI) * 25.4F / 72F;
//public float SizeInCentimeters public float GetSizeInEms(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F);
//{ get { return SizeInPixels * 2.54F / DPI; } } public float GetSizeInExs(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F);
//public float SizeInMillimeters public float GetSizeInPicas(float myDPI) => GetSizeInPoints(myDPI) * 6 / 72F;
//{ get { return SizeInPixels * 25.4F / DPI; } }
//public float SizeInEms
//{ get { return SizeInPixels * 5 / (6 * DPI); } }
//public float SizeInExs
//{ get { return SizeInPixels * 5 / (6 * DPI); } }
//public float SizeInPicas
//{ get { return SizeInPixels * 6 / DPI; } }
//public Unit SizeInUnits
//{ get { return new Unit((double)SizeInPoints, UnitTypeEnum.Point); } }
public float GetSizeInPixels(float myDPI)
{ return GetSizeInPoints(myDPI) * myDPI / 72F;}
public float GetSizeInInches(float myDPI)
{ return GetSizeInPoints(myDPI) / 72F; }
public float GetSizeInCentimeters(float myDPI)
{ return GetSizeInPoints(myDPI) * 2.54F / 72F; }
public float GetSizeInMillimeters(float myDPI)
{ return GetSizeInPoints(myDPI) * 25.4F / 72F; }
public float GetSizeInEms(float myDPI)
{ return GetSizeInPoints(myDPI) * 5 / (6 * 72F); }
public float GetSizeInExs(float myDPI)
{ return GetSizeInPoints(myDPI) * 5 / (6 * 72F); }
public float GetSizeInPicas(float myDPI)
{ return GetSizeInPoints(myDPI) * 6 / 72F; }
//public Unit GetSizeInUnits(float myDPI)
//{ return new Unit((double)GetSizeInPoints(myDPI), UnitTypeEnum.Point); }
public static float StringToPoints(string value) public static float StringToPoints(string value)
{ {
SvgMeasurement tmp = new SvgMeasurement(value); SvgMeasurement tmp = new SvgMeasurement(value);
@@ -226,26 +169,9 @@ namespace Volian.Svg.Library
} }
public class MeasurementTypeConverter : ExpandableObjectConverter public class MeasurementTypeConverter : ExpandableObjectConverter
{ {
public override bool CanConvertTo(ITypeDescriptorContext context, Type t) public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(String);
{ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgMeasurement ? value.ToString() : base.ConvertTo(context, culture, value, destType);
return t == typeof(String); public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(String);
} public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) => new SvgMeasurement((string)val);
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SvgMeasurement)
{
return value.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
{
SvgMeasurement measurement = new SvgMeasurement((string)val);
return measurement;
}
} }
} }
-25
View File
@@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Drawing;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
@@ -21,28 +18,6 @@ namespace Volian.Svg.Library
set { _ID = value; } set { _ID = value; }
} }
#endregion #endregion
//#region Parent and Containing Svg
//// ToDo: MyParent
//private SvgPartGrouping _MyParent;
//[XmlIgnore()]
//public SvgPartGrouping MyParent
//{
// get { return _MyParent; }
// set { _MyParent = value; }
//}
//// ToDo: MySvg
//private Svg _MySvg;
//public Svg MySvg
//{
// get { return _MySvg; }
// set { _MySvg = value; }
//}
//internal void SetParent(SvgPartGrouping myParent)
//{
// _MyParent = myParent;
// _MySvg = myParent.MySvg == null? MyParent : myParent.MySvg;
//}
//#endregion
#region Setup Inheritance #region Setup Inheritance
virtual internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { ; } virtual internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { ; }
#endregion #endregion
+1 -10
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel;
using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
@@ -81,11 +76,7 @@ namespace Volian.Svg.Library
#endregion #endregion
#endregion #endregion
#region Setup Inheritance #region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings;
{
_MyInheritedSettings.MyParentsSettings = myParentsSettings;
//_SvgParts.SetupInheritance(_MyInheritedSettings);
}
#endregion #endregion
} }
} }
+21 -72
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel; using System.ComponentModel;
using System.Text; using System.Text;
@@ -46,10 +45,7 @@ namespace Volian.Svg.Library
/// <param name='value'> /// <param name='value'>
/// A <see cref='SVGPart'/> from which the contents are copied /// A <see cref='SVGPart'/> from which the contents are copied
/// </param> /// </param>
public SvgParts(SvgParts value) public SvgParts(SvgParts value) => this.AddRange(value);
{
this.AddRange(value);
}
/// <summary> /// <summary>
/// <para> /// <para>
@@ -59,10 +55,7 @@ namespace Volian.Svg.Library
/// <param name='value'> /// <param name='value'>
/// A array of <see cref='SVGPart'/> objects with which to intialize the collection /// A array of <see cref='SVGPart'/> objects with which to intialize the collection
/// </param> /// </param>
public SvgParts(SvgPart[] value) public SvgParts(SvgPart[] value) => this.AddRange(value);
{
this.AddRange(value);
}
/// <summary> /// <summary>
/// <para>Represents the entry at the specified index of the <see cref='SVGPart'/>.</para> /// <para>Represents the entry at the specified index of the <see cref='SVGPart'/>.</para>
@@ -77,13 +70,6 @@ namespace Volian.Svg.Library
get { return ((SvgPart)(List[index])); } get { return ((SvgPart)(List[index])); }
set { List[index] = value; } set { List[index] = value; }
} }
//#region SetupInheritance
//internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
//{
// foreach (SvgPart svgPart in List)
// svgPart.SetupInheritance(myParentsSettings);
//}
//#endregion
#region Dictionary of Parts #region Dictionary of Parts
internal void AddLookup(Dictionary<string, SvgPart> lookUp) internal void AddLookup(Dictionary<string, SvgPart> lookUp)
{ {
@@ -204,10 +190,7 @@ namespace Volian.Svg.Library
/// <see cref='SVGPart'/>, if found; otherwise, -1.</para> /// <see cref='SVGPart'/>, if found; otherwise, -1.</para>
/// </returns> /// </returns>
/// <seealso cref='SVGParts.Contains'/> /// <seealso cref='SVGParts.Contains'/>
public int IndexOf(SvgPart value) public int IndexOf(SvgPart value) => List.IndexOf(value);
{
return List.IndexOf(value);
}
/// <summary> /// <summary>
/// <para>Inserts a <see cref='SVGPart'/> into the <see cref='SVGParts'/> at the specified index.</para> /// <para>Inserts a <see cref='SVGPart'/> into the <see cref='SVGParts'/> at the specified index.</para>
@@ -288,44 +271,24 @@ namespace Volian.Svg.Library
/// Event arguments for the SVGParts collection class. /// Event arguments for the SVGParts collection class.
public class SVGPartArgs : EventArgs public class SVGPartArgs : EventArgs
{ {
private SvgParts t;
/// Default constructor. /// Default constructor.
public SVGPartArgs() public SVGPartArgs() => SVGParts = new SvgParts();
{
t = new SvgParts();
}
/// Initializes with a SVGPart. /// Initializes with a SVGPart.
/// Data object. /// Data object.
public SVGPartArgs(SvgPart t) public SVGPartArgs(SvgPart t) : this() => this.SVGParts.Add(t);
: this()
{
this.t.Add(t);
}
/// Initializes with a collection of SVGPart objects. /// Initializes with a collection of SVGPart objects.
/// Collection of data. /// Collection of data.
public SVGPartArgs(SvgParts ts) public SVGPartArgs(SvgParts ts) : this() => this.SVGParts.AddRange(ts);
: this()
{
this.t.AddRange(ts);
}
/// Initializes with an array of SVGPart objects. /// Initializes with an array of SVGPart objects.
/// Array of data. /// Array of data.
public SVGPartArgs(SvgPart[] ts) public SVGPartArgs(SvgPart[] ts) : this() => this.SVGParts.AddRange(ts);
: this()
{
this.t.AddRange(ts);
}
/// Gets or sets the data of this argument. /// Gets or sets the data of this argument.
public SvgParts SVGParts public SvgParts SVGParts { get; set; }
{
get { return t; }
set { t = value; }
}
} }
/// SVGParts event handler. /// SVGParts event handler.
@@ -338,8 +301,7 @@ namespace Volian.Svg.Library
{ {
private SvgPart Item { get { return (SvgPart)_Item; } } private SvgPart Item { get { return (SvgPart)_Item; } }
public SvgPartsPropertyDescriptor(SvgParts collection, int index) : base(collection, index) { ;} public SvgPartsPropertyDescriptor(SvgParts collection, int index) : base(collection, index) { ;}
public override string DisplayName public override string DisplayName => Item.GetType().Name;
{ get { return Item.GetType().Name; } }
} }
#endregion #endregion
[Serializable()] [Serializable()]
@@ -347,32 +309,19 @@ namespace Volian.Svg.Library
{ {
protected object _Item = null; protected object _Item = null;
public vlnListPropertyDescriptor(System.Collections.IList collection, int index) public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
: base("#" + index.ToString(), null) : base($"#{index}", null) => _Item = collection[index];
{ _Item = collection[index]; } public override bool CanResetValue(object component) => true;
public override bool CanResetValue(object component) public override Type ComponentType => _Item.GetType();
{ return true; } public override object GetValue(object component) => _Item;
public override Type ComponentType public override bool IsReadOnly => false;
{ get { return _Item.GetType(); } } public override Type PropertyType => _Item.GetType();
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return false; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component) public override void ResetValue(object component)
{ ;} { ;}
public override bool ShouldSerializeValue(object component) public override bool ShouldSerializeValue(object component) => true;
{ return true; } public override void SetValue(object component, object value) { /*_Item = value*/; }
public override void SetValue(object component, object value) public override string DisplayName => _Item.ToString();
{ /*_Item = value*/;} public override string Description => _Item.ToString();
//public override AttributeCollection Attributes public override string Name => _Item.ToString();
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.ToString(); } }
public override string Description
{ get { return _Item.ToString(); } }
public override string Name
{ get { return _Item.ToString(); } }
} // Class } // Class
#region Converter #region Converter
@@ -383,7 +332,7 @@ namespace Volian.Svg.Library
if (destType == typeof(string) && value is SvgParts) if (destType == typeof(string) && value is SvgParts)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((SvgParts)value).List.Count.ToString() + " SVG Drawing Parts"; return $"{((SvgParts)value).List.Count} SVG Drawing Parts";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
+19 -46
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,88 +10,64 @@ namespace Volian.Svg.Library
public SvgRectangle() { ;} public SvgRectangle() { ;}
public SvgRectangle(PointF location, SizeF size, Color fillColor, Color lineColor, float lineWidth) public SvgRectangle(PointF location, SizeF size, Color fillColor, Color lineColor, float lineWidth)
{ {
_X.Value = location.X; X.Value = location.X;
_Y.Value = location.Y; Y.Value = location.Y;
_Width.Value = size.Width; Width.Value = size.Width;
_Height.Value = size.Height; Height.Value = size.Height;
FillColor = fillColor; FillColor = fillColor;
LineColor = lineColor; LineColor = lineColor;
LineWidth = new SvgMeasurement(lineWidth); LineWidth = new SvgMeasurement(lineWidth);
} }
//XMLElementAttribute(ElementName = "PREFIX", IsNullable = false)
#endregion #endregion
#region Description #region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")] [XmlElement("desc")]
public string Description public string Description { get; set; } = string.Empty;
{
get { return _Description; }
set { _Description = value; }
}
#endregion #endregion
#region Location #region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X public SvgMeasurement X { get; set; } = new SvgMeasurement();
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")] [XmlAttribute("x")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y public SvgMeasurement Y { get; set; } = new SvgMeasurement();
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")] [XmlAttribute("y")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate public string Y_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Size #region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Width public SvgMeasurement Width { get; set; } = new SvgMeasurement();
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")] [XmlAttribute("width")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate public string Width_WidthmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Height public SvgMeasurement Height { get; set; } = new SvgMeasurement();
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")] [XmlAttribute("height")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate public string Height_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
} }
+21 -67
View File
@@ -1,48 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
public class SvgScale public class SvgScale
{ {
private float _XLowerLimit; public float XLowerLimit { get; set; }
public float XLowerLimit public float YLowerLimit { get; set; }
{
get { return _XLowerLimit; }
set { _XLowerLimit = value; }
}
private float _YLowerLimit;
public float YLowerLimit
{
get { return _YLowerLimit; }
set { _YLowerLimit = value; }
}
private float _Scale; // Scale from Logical to Physical private float _Scale; // Scale from Logical to Physical
public float Scale public float Scale => _Scale;
{ get { return _Scale; } }
private float _Width; // Physical Width private float _Width; // Physical Width
public float Width public float Width => _Width;
{ get { return _Width; } }
private float _Height; // Physical Height private float _Height; // Physical Height
public float Height public float Height => _Height;
{ get { return _Height; } } public float XUpperLimit => _Width * _Scale + XLowerLimit;
public float XUpperLimit public float YUpperLimit => _Height * _Scale + YLowerLimit;
{ get { return _Width * _Scale + _XLowerLimit; } }
public float YUpperLimit
{ get { return _Height * _Scale + _YLowerLimit; } }
private float _DPI; private float _DPI;
public float DPI public float DPI => _DPI;
{ get { return _DPI; } }
private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY) private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY)
{ {
_DPI = tmp.DPI; _DPI = tmp.DPI;
_Scale = tmp.Scale; _Scale = tmp.Scale;
_Width = tmp.Width; _Width = tmp.Width;
_Height = tmp.Height; _Height = tmp.Height;
_XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI); XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI);
_YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI); YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI);
} }
public SvgScale(float myDPI, RectangleF bounds,SvgMeasurement width, SvgMeasurement height, SvgViewBox myViewBox) public SvgScale(float myDPI, RectangleF bounds,SvgMeasurement width, SvgMeasurement height, SvgViewBox myViewBox)
{ {
@@ -62,27 +43,15 @@ namespace Volian.Svg.Library
//Console.WriteLine("'Scale',{0}",_Scale); //Console.WriteLine("'Scale',{0}",_Scale);
_Width = outputWidth / _Scale; _Width = outputWidth / _Scale;
_Height = outputHeight / _Scale; _Height = outputHeight / _Scale;
_XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2; XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2;
_YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2; YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2;
//if (myDPI != 96) Console.WriteLine("DPI {0}", myDPI); //if (myDPI != 96) Console.WriteLine("DPI {0}", myDPI);
//Console.WriteLine("Scale,{0},{1},{2},{3},{4},{5},{6}", Scale, Width, Height, XLowerLimit, XUpperLimit, YLowerLimit, YUpperLimit); //Console.WriteLine("Scale,{0},{1},{2},{3},{4},{5},{6}", Scale, Width, Height, XLowerLimit, XUpperLimit, YLowerLimit, YUpperLimit);
} }
public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) => new SvgScale(this, newX, newY);
{ public float X(float x) => _Scale * (x - XLowerLimit);
return new SvgScale(this, newX, newY); public float Y(float y) => _Scale * (y - YLowerLimit);
} public float AbsX(SvgMeasurement x) => x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
public float X(float x)
{
return _Scale * (x - XLowerLimit);
}
public float Y(float y)
{
return _Scale * (y - YLowerLimit);
}
public float AbsX(SvgMeasurement x)
{
return x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X;
}
public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
{ {
// the following line of code is 'taken' from the 16bit code: \promsnt\exe\wined\togdi.cpp // the following line of code is 'taken' from the 16bit code: \promsnt\exe\wined\togdi.cpp
@@ -91,36 +60,21 @@ namespace Volian.Svg.Library
yOffset = yOffset / 20; // convert from twips to points (point = 1/72 inch) yOffset = yOffset / 20; // convert from twips to points (point = 1/72 inch)
return cb.PdfDocument.PageSize.Height - y.GetSizeInPixels(DPI) + yOffset + Svg.AbsoluteOffset.Y; return cb.PdfDocument.PageSize.Height - y.GetSizeInPixels(DPI) + yOffset + Svg.AbsoluteOffset.Y;
} }
public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) => cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
{ public float M(float m) => _Scale * m;
return cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit);
}
public float M(float m)
{
return _Scale * m;
}
public float X(SvgMeasurement x) public float X(SvgMeasurement x)
{ {
float retval = _Scale * (x.GetSizeInPixels(DPI) - XLowerLimit); float retval = _Scale * (x.GetSizeInPixels(DPI) - XLowerLimit);
return retval; return retval;
} }
public float Y(SvgMeasurement y) public float Y(SvgMeasurement y) => _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
{
return _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
}
public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y)
{ {
float yOffset = 0; // = (cb.PdfWriter.CurrentPageNumber -1) * .8F * cb.PdfDocument.PageSize.Height; float yOffset = 0; // = (cb.PdfWriter.CurrentPageNumber -1) * .8F * cb.PdfDocument.PageSize.Height;
float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit); float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit);
return myY; return myY;
} }
public float YY(SvgMeasurement y) public float YY(SvgMeasurement y) => -_Scale * y.GetSizeInPixels(DPI);
{ public float M(SvgMeasurement m) => _Scale * m.GetSizeInPixels(DPI);
return -_Scale * y.GetSizeInPixels(DPI);
}
public float M(SvgMeasurement m)
{
return _Scale * m.GetSizeInPixels(DPI);
}
} }
} }
+1 -4
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Xml; using System.Xml;
@@ -61,9 +60,7 @@ namespace Volian.Svg.Library
public class NonXsiTextWriter : XmlTextWriter public class NonXsiTextWriter : XmlTextWriter
{ {
public NonXsiTextWriter( TextWriter w ) : base( w ) {} public NonXsiTextWriter( TextWriter w ) : base( w ) {}
public NonXsiTextWriter( Stream w, Encoding encoding ) : base( w, encoding ) { public NonXsiTextWriter(Stream w, Encoding encoding) : base(w, encoding) => this.Formatting = Formatting.Indented;
this.Formatting = Formatting.Indented;
}
public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {} public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {}
bool _skip = false; bool _skip = false;
public override void WriteStartAttribute( string prefix, string localName, string ns ) public override void WriteStartAttribute( string prefix, string localName, string ns )
-2
View File
@@ -1,5 +1,3 @@
using System;
using System.IO;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Drawing; using System.Drawing;
using System.ComponentModel; using System.ComponentModel;
-3
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Drawing; using System.Drawing;
+11 -34
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
@@ -14,8 +10,8 @@ namespace Volian.Svg.Library
public SvgText() { ;} public SvgText() { ;}
public SvgText(PointF location, string text, Font font, Color fillColor) public SvgText(PointF location, string text, Font font, Color fillColor)
{ {
_X.Value = location.X; X.Value = location.X;
_Y.Value = location.Y; Y.Value = location.Y;
Text = text; Text = text;
Font = font; Font = font;
FillColor = fillColor; FillColor = fillColor;
@@ -24,42 +20,28 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region Location #region Location
private SvgJustify _Justify = SvgJustify.Left;
[XmlAttribute("Justify")] [XmlAttribute("Justify")]
public SvgJustify Justify public SvgJustify Justify { get; set; } = SvgJustify.Left;
{
get { return _Justify; }
set { _Justify = value; }
}
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X public SvgMeasurement X { get; set; } = new SvgMeasurement();
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")] [XmlAttribute("x")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y public SvgMeasurement Y { get; set; } = new SvgMeasurement();
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")] [XmlAttribute("y")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate public string Y_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Text #region Text
@@ -126,14 +108,9 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region Description #region Description
private string _Description = string.Empty;
[System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.DefaultValueAttribute("")]
[XmlElement("desc")] [XmlElement("desc")]
public string Description public string Description { get; set; } = string.Empty;
{
get { return _Description; }
set { _Description = value; }
}
#endregion #endregion
#region Setup Inheritance #region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) override internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
+21 -53
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
@@ -13,95 +10,66 @@ namespace Volian.Svg.Library
public SvgUse() { ;} public SvgUse() { ;}
public SvgUse(PointF location, SizeF size, string id) public SvgUse(PointF location, SizeF size, string id)
{ {
_X.Value = location.X; X.Value = location.X;
_Y.Value = location.Y; Y.Value = location.Y;
_Width.Value = size.Width; Width.Value = size.Width;
_Height.Value = size.Height; Height.Value = size.Height;
_ID = id; _ID = id;
} }
#endregion #endregion
#region Location #region Location
private SvgMeasurement _X = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement X public SvgMeasurement X { get; set; } = new SvgMeasurement();
{
get { return _X; }
set { _X = value; }
}
[XmlAttribute("x")] [XmlAttribute("x")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string X_XmlSurrogate public string X_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_X); } get { return SvgXmlConverter<SvgMeasurement>.GetString(X); }
set { _X = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { X = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Y = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Y public SvgMeasurement Y { get; set; } = new SvgMeasurement();
{
get { return _Y; }
set { _Y = value; }
}
[XmlAttribute("y")] [XmlAttribute("y")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Y_XmlSurrogate public string Y_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Y); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Y); }
set { _Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Y = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region Size #region Size
private SvgMeasurement _Width = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Width public SvgMeasurement Width { get; set; } = new SvgMeasurement();
{
get { return _Width; }
set { _Width = value; }
}
[XmlAttribute("width")] [XmlAttribute("width")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Width_WidthmlSurrogate public string Width_WidthmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Width); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Width); }
set { _Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Width = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
private SvgMeasurement _Height = new SvgMeasurement();
[XmlIgnore] [XmlIgnore]
public SvgMeasurement Height public SvgMeasurement Height { get; set; } = new SvgMeasurement();
{
get { return _Height; }
set { _Height = value; }
}
[XmlAttribute("height")] [XmlAttribute("height")]
[Browsable(false)] [Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public string Height_XmlSurrogate public string Height_XmlSurrogate
{ {
get { return SvgXmlConverter<SvgMeasurement>.GetString(_Height); } get { return SvgXmlConverter<SvgMeasurement>.GetString(Height); }
set { _Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); } set { Height = SvgXmlConverter<SvgMeasurement>.GetObject(value); }
} }
#endregion #endregion
#region ID to be used #region ID to be used
private string _UseID = null;
[XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")]
public string UseID public string UseID { get; set; } = null;
{
get { return _UseID; }
set { _UseID = value; }
}
#endregion #endregion
#region Setup Inheritance #region Setup Inheritance
override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings;
{
_MyInheritedSettings.MyParentsSettings = myParentsSettings;
}
#endregion #endregion
public override string ToString() public override string ToString() => string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID);
{
return string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID);
}
} }
} }
+8 -29
View File
@@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Drawing;
using System.Text; using System.ComponentModel;
using System.Drawing;
using System.ComponentModel;
namespace Volian.Svg.Library namespace Volian.Svg.Library
{ {
@@ -11,10 +9,7 @@ namespace Volian.Svg.Library
{ {
#region ctor #region ctor
public SvgViewBox() { ;} public SvgViewBox() { ;}
public SvgViewBox(float x, float y, float width, float height) public SvgViewBox(float x, float y, float width, float height) => _MyRectangleF = new RectangleF(x, y, width, height);
{
_MyRectangleF = new RectangleF(x, y, width, height);
}
public SvgViewBox(string val) public SvgViewBox(string val)
{ {
string[] parms = ((string)val).Split(' '); string[] parms = ((string)val).Split(' ');
@@ -45,30 +40,14 @@ namespace Volian.Svg.Library
} }
#endregion #endregion
#region ToString #region ToString
public override string ToString() public override string ToString() => string.Format("{0} {1} {2} {3}", X, Y, Width, Height);
{
return string.Format("{0} {1} {2} {3}", X, Y, Width, Height);
}
#endregion #endregion
} }
public class ViewBoxTypeConverter : ExpandableObjectConverter public class ViewBoxTypeConverter : ExpandableObjectConverter
{ {
public override bool CanConvertTo(ITypeDescriptorContext context, Type t) public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(string);
{ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgViewBox ? value.ToString() : base.ConvertTo(context, culture, value, destType);
return t == typeof(String); public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(string);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SvgViewBox)
{
return value.ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
{
return t == typeof(String);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
{ {
string[] parms = ((string)val).Split(' '); string[] parms = ((string)val).Split(' ');
+1 -8
View File
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel; using System.ComponentModel;
namespace Volian.Svg.Library namespace Volian.Svg.Library
@@ -13,10 +10,6 @@ namespace Volian.Svg.Library
TypeConverter FontConverter = TypeDescriptor.GetConverter(typeof(T)); TypeConverter FontConverter = TypeDescriptor.GetConverter(typeof(T));
return FontConverter.ConvertToInvariantString(myObject); return FontConverter.ConvertToInvariantString(myObject);
} }
public static T GetObject(string value) public static T GetObject(string value) => (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(value);
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
return (T)converter.ConvertFromInvariantString(value);
}
} }
} }
@@ -89,7 +89,6 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FontFind.cs" />
<Compile Include="Graphics.cs" /> <Compile Include="Graphics.cs" />
<Compile Include="iTextSharp.cs" /> <Compile Include="iTextSharp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
+65 -434
View File
@@ -1,18 +1,10 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Serialization; using System.Xml.Serialization;
using iTextSharp.text; using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Microsoft.Win32;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml;
using System.IO; using System.IO;
using Volian.Base.Library; using Volian.Base.Library;
@@ -97,23 +89,14 @@ namespace Volian.Svg.Library
{ {
get { return _MyText; } get { return _MyText; }
} }
private SvgText _MySvgText;
public SvgText MySvgText public SvgText MySvgText { get; set; }
{ public SvgScale MySvgScale { get; set; }
get { return _MySvgText; }
set { _MySvgText = value; }
}
private SvgScale _MySvgScale;
public SvgScale MySvgScale
{
get { return _MySvgScale; }
set { _MySvgScale = value; }
}
public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale) public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale)
{ {
_MyText = myText; _MyText = myText;
_MySvgText = mySvgText; MySvgText = mySvgText;
_MySvgScale = mySvgScale; MySvgScale = mySvgScale;
} }
} }
public partial class Svg : SvgGroup public partial class Svg : SvgGroup
@@ -121,7 +104,7 @@ namespace Volian.Svg.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void DrawMacro(string macroDef, float x, float y, PdfContentByte cb) public void DrawMacro(string macroDef, float x, float y, PdfContentByte cb)
{ {
_MyContentByte = cb; MyContentByte = cb;
SvgMeasurement X = new SvgMeasurement(x, E_MeasurementUnits.PT); SvgMeasurement X = new SvgMeasurement(x, E_MeasurementUnits.PT);
SvgMeasurement Y = new SvgMeasurement(Height.GetSizeInPoints(72) - y, E_MeasurementUnits.PT); SvgMeasurement Y = new SvgMeasurement(Height.GetSizeInPoints(72) - y, E_MeasurementUnits.PT);
if (!this.LookUp.ContainsKey(macroDef)) return; // AEP - DU1 (missing C22 macro for AEP) if (!this.LookUp.ContainsKey(macroDef)) return; // AEP - DU1 (missing C22 macro for AEP)
@@ -157,25 +140,13 @@ namespace Volian.Svg.Library
top = (yll > yul ? (yll > top ? yll : top) : (yul > top ? yul : top)); top = (yll > yul ? (yll > top ? yll : top) : (yul > top ? yul : top));
tmp.BoundingBox = new iTextSharp.text.Rectangle(xll, yll, xul, yul); tmp.BoundingBox = new iTextSharp.text.Rectangle(xll, yll, xul, yul);
} }
private PdfContentByte _MyContentByte;
[XmlIgnore] [XmlIgnore]
public PdfContentByte MyContentByte public PdfContentByte MyContentByte { get; set; }
{
get { return _MyContentByte; } public float LeftMargin { get; set; } = 0;
set { _MyContentByte = value; }
} public float TopMargin { get; set; } = 0;
private float _LeftMargin = 0;
public float LeftMargin
{
get { return _LeftMargin; }
set { _LeftMargin = value; }
}
private float _TopMargin = 0;
public float TopMargin
{
get { return _TopMargin; }
set { _TopMargin = value; }
}
private SvgScale _MyScale; private SvgScale _MyScale;
public SvgScale MyScale public SvgScale MyScale
{ {
@@ -183,19 +154,17 @@ namespace Volian.Svg.Library
{ {
if (_MyScale == null) if (_MyScale == null)
{ {
_MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, _MyContentByte.PdfWriter.PageSize.Width, _MyContentByte.PdfWriter.PageSize.Height), _Width, _Height, _ViewBox); _MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, MyContentByte.PdfWriter.PageSize.Width, MyContentByte.PdfWriter.PageSize.Height), Width, Height, ViewBox);
_MyScale.XLowerLimit -= _LeftMargin; _MyScale.XLowerLimit -= LeftMargin;
_MyScale.YLowerLimit -= _TopMargin; _MyScale.YLowerLimit -= TopMargin;
} }
return _MyScale; return _MyScale;
} }
} }
public void Draw(PdfContentByte cb) public void Draw(PdfContentByte cb)
{ {
//myPdf.Clear(); MyContentByte = cb;
_MyContentByte = cb;
_Templates = new Dictionary<string, PdfTemplate>(); _Templates = new Dictionary<string, PdfTemplate>();
//RegisterFonts();
SvgParts.Draw(cb, MyScale, this, this); //72 - Points SvgParts.Draw(cb, MyScale, this, this); //72 - Points
} }
public static iTextSharp.text.Font GetFont(string fontName) public static iTextSharp.text.Font GetFont(string fontName)
@@ -214,36 +183,6 @@ namespace Volian.Svg.Library
VlnItextFont.RegisterFont(fontName); VlnItextFont.RegisterFont(fontName);
return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, new iTextSharp.text.Color(color)); return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, new iTextSharp.text.Color(color));
} }
//private static string _FontFolder = null;
//public static string FontFolder
//{
// get
// {
// if (_FontFolder == null)
// {
// _FontFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);
// if (_FontFolder == null) _FontFolder = (String)Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Explorer").OpenSubKey("Shell Folders").GetValue("Fontz");
// _MyLog.WarnFormat("FontFolder set to {0}", _FontFolder);
// }
// return _FontFolder;
// }
//}
private static int _StackTraceSkip = 1;
private static DateTime _LastTime = DateTime.Now;
private static DateTime _StartTime = DateTime.Now;
public static void ResetWhen()
{
_StartTime = _LastTime = DateTime.Now;
}
public static void WhenAndWhere()
{
DateTime thisTime = DateTime.Now;
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(_StackTraceSkip, true);
Console.WriteLine("{0:000000},{1:000000},'{2}',{3},'{4}'", TimeSpan.FromTicks(thisTime.Ticks - _StartTime.Ticks).TotalMilliseconds,
TimeSpan.FromTicks(thisTime.Ticks - _LastTime.Ticks).TotalMilliseconds, sf.GetMethod().Name, sf.GetFileLineNumber()
,sf.GetFileName());
_LastTime = thisTime;
}
} }
public partial class SvgArc : SvgShapePart public partial class SvgArc : SvgShapePart
{ {
@@ -326,18 +265,13 @@ namespace Volian.Svg.Library
{ {
// TODO: Could I try creating a template // TODO: Could I try creating a template
// Don't draw // Don't draw
// SvgParts.Draw(cb, myScale, mySvg, myParent);
PdfTemplate tmp = null; PdfTemplate tmp = null;
if (ID != "") tmp = mySvg.GetTemplate(ID, cb); // the size will be adjusted as items are added. if (ID != "") tmp = mySvg.GetTemplate(ID, cb); // the size will be adjusted as items are added.
SvgParts.Draw(tmp, myScale, mySvg, myParent); SvgParts.Draw(tmp, myScale, mySvg, myParent);
} }
public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{ {
// TODO: Could I try creating a template
// Don't draw // Don't draw
// SvgParts.Draw(cb, myScale, mySvg, myParent);
//PdfTemplate tmp2 = mySvg.GetTemplate(ID); // the size will be adjusted as items are added.
//SvgParts.Draw(tmp2, myScale, mySvg, myParent);
} }
} }
public partial class SvgUse : SvgPartInheritance public partial class SvgUse : SvgPartInheritance
@@ -348,24 +282,22 @@ namespace Volian.Svg.Library
{ {
// TODO: Could I use the template // TODO: Could I use the template
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
if (mySvg.LookUp.ContainsKey(_UseID)) if (mySvg.LookUp.ContainsKey(UseID))
mySvg[_UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this); mySvg[UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this);
else else
{ {
if (!_MissingMacros.Contains(_UseID)) if (!_MissingMacros.Contains(UseID))
{ {
_MissingMacros.Add(_UseID); _MissingMacros.Add(UseID);
_MyLog.WarnFormat("Missing Macro '{0}'", _UseID); _MyLog.WarnFormat("Missing Macro '{0}'", UseID);
} }
} }
//cb.AddTemplate(mySvg.GetTemplate(_UseID.Substring(1),cb), scale.X(X), scale.Y(cb, Y));
} }
public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
{ {
// TODO: Could I use the template // TODO: Could I use the template
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
//mySvg[_UseID.Substring(1)].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this); mySvg[UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this);
mySvg[_UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this);
} }
} }
public partial class SvgEllipse : SvgShapePart public partial class SvgEllipse : SvgShapePart
@@ -410,7 +342,7 @@ namespace Volian.Svg.Library
public override void Draw(PdfContentByte cb, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(PdfContentByte cb, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
_SvgParts.Draw(cb, myScale, mySvg, this); SvgParts.Draw(cb, myScale, mySvg, this);
} }
public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent)
{ {
@@ -443,6 +375,7 @@ namespace Volian.Svg.Library
{ {
SetupInheritance(myParent.MyInheritedSettings); SetupInheritance(myParent.MyInheritedSettings);
tmp.SaveState(); tmp.SaveState();
#pragma warning disable CS0168 // Variable is declared but never used - ex kept for debugging
try try
{ {
if (ImagePath != null) if (ImagePath != null)
@@ -457,6 +390,7 @@ namespace Volian.Svg.Library
{ {
//_MyLog.WarnFormat("SvgImage.Draw '{0}' {1} - {2}", ImagePath, ex.GetType().Name, ex.Message); //_MyLog.WarnFormat("SvgImage.Draw '{0}' {1} - {2}", ImagePath, ex.GetType().Name, ex.Message);
} }
#pragma warning restore CS0168 // Variable is declared but never used
tmp.RestoreState(); tmp.RestoreState();
} }
} }
@@ -581,27 +515,18 @@ namespace Volian.Svg.Library
{ {
case SvgJustify.Left: case SvgJustify.Left:
return Element.ALIGN_LEFT; return Element.ALIGN_LEFT;
break;
case SvgJustify.Center: case SvgJustify.Center:
return Element.ALIGN_CENTER; return Element.ALIGN_CENTER;
break;
case SvgJustify.Right: case SvgJustify.Right:
return Element.ALIGN_RIGHT; return Element.ALIGN_RIGHT;
break;
} }
return Element.ALIGN_LEFT; return Element.ALIGN_LEFT;
} }
} }
public class VlnSplitCharacter : ISplitCharacter public class VlnSplitCharacter : ISplitCharacter
{ {
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
{ public bool IsSplitCharacter(char c) => (c == ' ');
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
} }
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
// Draw's using PdfContentByte are for drawing PageList items. // Draw's using PdfContentByte are for drawing PageList items.
@@ -654,9 +579,6 @@ namespace Volian.Svg.Library
} }
switch (Justify) switch (Justify)
{ {
//case SvgJustify.Left:
// x = x;
// break;
case SvgJustify.Center: case SvgJustify.Center:
x-=w/2; x-=w/2;
break; break;
@@ -687,12 +609,6 @@ namespace Volian.Svg.Library
public static bool CompressPropSubSup = false; public static bool CompressPropSubSup = false;
private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font) private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font)
{ {
//if (text == "Caution")
//{
// if (iTextSharp.text.FontFactory.IsRegistered("VolianScript"))
// Console.WriteLine("Is Registered");
// Console.WriteLine("stop");
//}
bool fontUnderline = false; bool fontUnderline = false;
float fontTextRise = 0; float fontTextRise = 0;
@@ -700,8 +616,6 @@ namespace Volian.Svg.Library
text = Regex.Replace(text, @"\\'[0-9a-fA-F][0-9a-fA-F]", new MatchEvaluator(ReplaceHexCharacter)); text = Regex.Replace(text, @"\\'[0-9a-fA-F][0-9a-fA-F]", new MatchEvaluator(ReplaceHexCharacter));
text += " "; text += " ";
//if (text.Contains("\\")) -- these 2 lines made \ul and \ulnone in page list text not get resolved and would then print
//text = text.Replace("\\", ((char)9586).ToString()); // B2016-155 convert backslash char to the unicode symbol - to allow processing rtf commands \ul, \up, \dn, etc.
// B2016-167: handle backslashes but don't do if the backslash is an underline rtf command // B2016-167: handle backslashes but don't do if the backslash is an underline rtf command
int stindx = text.IndexOf("\\"); int stindx = text.IndexOf("\\");
while (stindx != -1) while (stindx != -1)
@@ -892,170 +806,38 @@ namespace Volian.Svg.Library
tmp.RestoreState(); tmp.RestoreState();
} }
} }
public class SvgPageTotal
{
public SvgPageTotal(System.Drawing.Font myFont, PdfContentByte cb)
{
_MyFont = myFont;
_MyTemplate = cb.CreateTemplate(100, 100);
_MyTemplate.BoundingBox= new Rectangle(-20, -20, 100, 100);
}
private int _PageCount=1;
private System.Drawing.Font _MyFont;
private PdfTemplate _MyTemplate;
public PdfTemplate MyTemplate
{
get { return _MyTemplate; }
}
public void Draw()
{
// Output Page Count
_MyTemplate.BeginText();
iTextSharp.text.Font font = Svg.GetFont(_MyFont.Name);
BaseFont baseFont = font.BaseFont;
_MyTemplate.SetFontAndSize(baseFont,_MyFont.Size);
_MyTemplate.SetTextMatrix(0, 0);
_MyTemplate.ShowText(_PageCount.ToString());
_MyTemplate.EndText();
}
}
public class SvgPageHelper : PdfPageEventHelper public class SvgPageHelper : PdfPageEventHelper
{ {
private bool _SpecialCAS; // B2023-005: CAS page, rotate watermark public bool SpecialCAS { get; set; }
public bool SpecialCAS public bool IsLandscape { get; set; }
{ public bool IsWatermarkLandscape { get; set; }
get { return _SpecialCAS; } public Svg MySvg { get; set; }
set { _SpecialCAS = value; } public PdfLayer PageListLayer { get; set; }
} public PdfLayer WatermarkLayer { get; set; }
private bool _IsLandscape; public string Watermark { get; set; } = string.Empty;
public bool IsLandscape public string WatermarkColor { get; set; } = "BLUE";
{ public PdfLayer PROMSVersionLayer { get; set; }
get { return _IsLandscape; } public string PROMSVersion { get; set; } = string.Empty;
set { _IsLandscape = value; } public bool DoZoomOMatic { get; set; } = false;
} public int CurrentPageNumber { get; set; } = 0;
// B2019-145: added the following property so that the code would know that an adjustment should be made to print the watermark public int CurrentPageNumberNoFoldouts { get; set; } = 0;
// in landscape mode. Note that 'IsLandscape' could not be used because it also does the pagelist items. public int CurrentTOCPageNumber { get; set; } = 0;
private bool _IsWatermarkLandscape; public bool OnFoldoutPage { get; set; } = false;
public bool IsWatermarkLandscape public bool CreatingFoldoutPage { get; set; } = false;
{ public bool CreatingSupInfoPage { get; set; } = false;
get { return _IsWatermarkLandscape; }
set { _IsWatermarkLandscape = value; }
}
// B2018-124 we no longer need is list was not hanling "Information Only" water mark
//private List<string> _AllowedWatermarks = new List<string>();
//public List<string> AllowedWatermarks
//{
// get { return _AllowedWatermarks; }
// set { _AllowedWatermarks = value; }
//}
private Svg _MySvg;
public Svg MySvg
{
get { return _MySvg; }
set { _MySvg = value; }
}
private PdfLayer _PageListLayer;
public PdfLayer PageListLayer
{
get { return _PageListLayer; }
set { _PageListLayer = value; }
}
private PdfLayer _WatermarkLayer;
public PdfLayer WatermarkLayer
{
get { return _WatermarkLayer; }
set { _WatermarkLayer = value; }
}
private string _Watermark=string.Empty;
public string Watermark
{
get { return _Watermark; }
set { _Watermark = value; }
}
private string _WatermarkColor = "BLUE";
public string WatermarkColor
{
get { return _WatermarkColor; }
set { _WatermarkColor = value; }
}
private PdfLayer _PROMSVersionLayer; //C2018-009 print PROMS version
public PdfLayer PROMSVersionLayer
{
get { return _PROMSVersionLayer; }
set { _PROMSVersionLayer = value; }
}
private string _PROMSVersion = string.Empty;
public string PROMSVersion
{
get { return _PROMSVersion; }
set { _PROMSVersion = value; }
}
private bool _DoZoomOMatic = false;
public bool DoZoomOMatic
{
get { return _DoZoomOMatic; }
set { _DoZoomOMatic = value; }
}
private int _CurrentPageNumber = 0;
public int CurrentPageNumber
{
get { return _CurrentPageNumber; }
set { _CurrentPageNumber = value; }
}
private int _CurrentPageNumberNoFoldouts = 0;
public int CurrentPageNumberNoFoldouts
{
get { return _CurrentPageNumberNoFoldouts; }
set { _CurrentPageNumberNoFoldouts = value; }
}
private int _CurrentTOCPageNumber = 0;
public int CurrentTOCPageNumber
{
get { return _CurrentTOCPageNumber; }
set { _CurrentTOCPageNumber = value; }
}
private bool _OnFoldoutPage = false;
public bool OnFoldoutPage
{
get { return _OnFoldoutPage; }
set { _OnFoldoutPage = value; }
}
private bool _CreatingFoldoutPage = false;
public bool CreatingFoldoutPage
{
get { return _CreatingFoldoutPage; }
set { _CreatingFoldoutPage = value; }
}
private bool _CreatingSupInfoPage = false;
public bool CreatingSupInfoPage
{
get { return _CreatingSupInfoPage; }
set { _CreatingSupInfoPage = value; }
}
public SvgPageHelper(Svg mySvg) public SvgPageHelper(Svg mySvg)
{ {
_MySvg = mySvg; MySvg = mySvg;
} }
public SvgPageHelper() public SvgPageHelper()
{ {
} }
private int _BGPageOffset = 0;
public int BackgroundPageOffset public int BackgroundPageOffset { get; set; } = 0;
{ protected virtual string ReplacePageListToken(Match match) => string.Empty;
get { return _BGPageOffset; }
set { _BGPageOffset = value; }
}
protected virtual string ReplacePageListToken(Match match)
{
return string.Empty;
}
public override void OnOpenDocument(PdfWriter writer, Document document) public override void OnOpenDocument(PdfWriter writer, Document document)
{ {
//base.OnOpenDocument(writer, document);
//tmpTotal = writer.DirectContent.CreateTemplate(100, 100);
//tmpTotal.BoundingBox = new Rectangle(-20, -20, 100, 100);
//PdfContentByte cb = writer.DirectContent;
} }
public override void OnEndPage(PdfWriter writer, Document document) public override void OnEndPage(PdfWriter writer, Document document)
{ {
@@ -1093,8 +875,8 @@ namespace Volian.Svg.Library
{ {
get get
{ {
if (_BackgroundReader == null && _BackgroundFile != null && File.Exists(_BackgroundFile)) if (_BackgroundReader == null && BackgroundFile != null && File.Exists(BackgroundFile))
_BackgroundReader = new PdfReader(_BackgroundFile); _BackgroundReader = new PdfReader(BackgroundFile);
return _BackgroundReader; return _BackgroundReader;
} }
} }
@@ -1106,28 +888,16 @@ namespace Volian.Svg.Library
return BackgroundReader.Info["Producer"].ToString().StartsWith("iTextSharp"); return BackgroundReader.Info["Producer"].ToString().StartsWith("iTextSharp");
} }
} }
private string _BackgroundFile = null;
public string BackgroundFile public string BackgroundFile { get; set; } = null;
{ public PdfLayer BackgroundLayer { get; set; } = null;
get { return _BackgroundFile; }
set { _BackgroundFile = value; }
}
private PdfLayer _BackgroundLayer = null;
public PdfLayer BackgroundLayer
{
get { return _BackgroundLayer; }
set { _BackgroundLayer = value; }
}
private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0); private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0);
public System.Drawing.PointF BackgroundOffset public System.Drawing.PointF BackgroundOffset
{ {
get { return _BackgroundOffset; } get { return _BackgroundOffset; }
set { _BackgroundOffset = value; } set { _BackgroundOffset = value; }
} }
public int BackgroundPageCount public int BackgroundPageCount => BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages;
{
get { return BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages; }
}
private PdfImportedPage GetBackgroundPage(PdfContentByte cb) private PdfImportedPage GetBackgroundPage(PdfContentByte cb)
{ {
if (BackgroundReader == null) return null; if (BackgroundReader == null) return null;
@@ -1151,12 +921,8 @@ namespace Volian.Svg.Library
ZoomOMatic(cb, 36); ZoomOMatic(cb, 36);
cb.RestoreState(); cb.RestoreState();
} }
private bool _AllowAllWatermarks = false;
public bool AllowAllWatermarks public bool AllowAllWatermarks { get; set; } = false;
{
get { return _AllowAllWatermarks; }
set { _AllowAllWatermarks = value; }
}
//C2022-004 This will return the system drawing color from either the color name or ARGB values //C2022-004 This will return the system drawing color from either the color name or ARGB values
public System.Drawing.Color GetWatermarkColor(string colorDescription) public System.Drawing.Color GetWatermarkColor(string colorDescription)
{ {
@@ -1192,9 +958,8 @@ namespace Volian.Svg.Library
private void DrawWatermark(PdfContentByte cb) private void DrawWatermark(PdfContentByte cb)
{ {
if (Watermark == null || Watermark.ToLower().Contains("none") || Watermark == "") return; if (Watermark == null || Watermark.ToLower().Contains("none") || Watermark == "") return;
//if (!AllowAllWatermarks && !AllowedWatermarks.Contains(Watermark)) return; -- B2018-124 not needed anymore with above if statement - this does not hanle "Information Only"
cb.SaveState(); cb.SaveState();
if (_WatermarkLayer != null) cb.BeginLayer(_WatermarkLayer); if (WatermarkLayer != null) cb.BeginLayer(WatermarkLayer);
// B2023-005: Beaver Valley, second page of CAS page is a 'foldout' on large paper - need to rotate the // B2023-005: Beaver Valley, second page of CAS page is a 'foldout' on large paper - need to rotate the
// watermark // watermark
if (SpecialCAS) if (SpecialCAS)
@@ -1207,16 +972,13 @@ namespace Volian.Svg.Library
else if (IsLandscape || IsWatermarkLandscape) // B2019-145: Added for printing landscape watermark on step section pages. else if (IsLandscape || IsWatermarkLandscape) // B2019-145: Added for printing landscape watermark on step section pages.
{ {
// The watermark needs to be rotated back for landscape pagelist - B2016-191 // The watermark needs to be rotated back for landscape pagelist - B2016-191
//double a = -33 * (Math.PI / 180);
//System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), -60, 320);
double a = -90 * (Math.PI / 180); double a = -90 * (Math.PI / 180);
System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), 0, cb.PdfDocument.PageSize.Height); System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), 0, cb.PdfDocument.PageSize.Height);
cb.Transform(myMatrix); cb.Transform(myMatrix);
} }
SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, GetWatermarkColor(WatermarkColor), .15F); SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, GetWatermarkColor(WatermarkColor), .15F);
//myWatermark.SetSquareDotPattern(.7F);
myWatermark.Draw(); myWatermark.Draw();
if (_WatermarkLayer != null) cb.EndLayer(); if (WatermarkLayer != null) cb.EndLayer();
cb.RestoreState(); cb.RestoreState();
} }
//C2018-009 print PROMS version //C2018-009 print PROMS version
@@ -1226,32 +988,22 @@ namespace Volian.Svg.Library
string text = PROMSVersion; string text = PROMSVersion;
float textBase =cb.PdfDocument.Top + 19; float textBase =cb.PdfDocument.Top + 19;
float textLeft = cb.PdfDocument.Right - 15; float textLeft = cb.PdfDocument.Right - 15;
if (_PROMSVersionLayer != null) cb.BeginLayer(_PROMSVersionLayer); if (PROMSVersionLayer != null) cb.BeginLayer(PROMSVersionLayer);
cb.BeginText(); cb.BeginText();
cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 6f); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 6f);
cb.SetTextMatrix(textLeft, textBase); cb.SetTextMatrix(textLeft, textBase);
cb.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.Indigo)); cb.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.Indigo));
cb.ShowText(text); cb.ShowText(text);
cb.EndText(); cb.EndText();
if (_PROMSVersionLayer != null) cb.EndLayer(); if (PROMSVersionLayer != null) cb.EndLayer();
cb.RestoreState(); cb.RestoreState();
} }
private void DrawPageList(PdfContentByte cb) private void DrawPageList(PdfContentByte cb)
{ {
if (_MySvg != null) if (MySvg != null)
{ {
cb.SaveState(); cb.SaveState();
if (_PageListLayer != null) cb.BeginLayer(_PageListLayer); if (PageListLayer != null) cb.BeginLayer(PageListLayer);
// Do anything needed to finish off the page
//System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix();
//myMatrix.Rotate(90); // Rotate the Pagelist items by 90 Degrees.
//// Translate by the Height of the page.
//myMatrix.Translate(cb.PdfDocument.PageSize.Height, 0, System.Drawing.Drawing2D.MatrixOrder.Append);
//// This was for fun
//// myMatrix.Scale(.75F, .75F, System.Drawing.Drawing2D.MatrixOrder.Append);
//cb.Transform(myMatrix);
//// You can look at the value of the Matrix at this point, to create the matrix directly like I did below
//OR
// Rotate 90 Degrees and Translate by the Height of the Page // Rotate 90 Degrees and Translate by the Height of the Page
if (IsLandscape) if (IsLandscape)
@@ -1259,8 +1011,8 @@ namespace Volian.Svg.Library
System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0);
cb.Transform(myMatrix); cb.Transform(myMatrix);
} }
_MySvg.Draw(cb); MySvg.Draw(cb);
if (_PageListLayer != null) cb.EndLayer(); if (PageListLayer != null) cb.EndLayer();
cb.RestoreState(); cb.RestoreState();
} }
} }
@@ -1277,7 +1029,7 @@ namespace Volian.Svg.Library
} }
public override void OnStartPage(PdfWriter writer, Document document) public override void OnStartPage(PdfWriter writer, Document document)
{ {
//base.OnStartPage(writer, document);
} }
public override void OnCloseDocument(PdfWriter writer, Document document) public override void OnCloseDocument(PdfWriter writer, Document document)
{ {
@@ -1289,137 +1041,24 @@ namespace Volian.Svg.Library
private PdfContentByte _ContentByte; private PdfContentByte _ContentByte;
private string _Text; private string _Text;
private System.Drawing.Color _Color; private System.Drawing.Color _Color;
private PdfPatternPainter _PatternPainter;
private BaseFont _Basefont;
private float _Fontsize;
private float _XOffset;
private float _YOffset;
private float _TextAngle;
private float _Opacity; private float _Opacity;
public SvgWatermark(PdfContentByte contentByte, string text, System.Drawing.Color color, float opacity) public SvgWatermark(PdfContentByte contentByte, string text, System.Drawing.Color color, float opacity)
{ {
_ContentByte = contentByte; _ContentByte = contentByte;
_Text = text; _Text = text;
//float radius = .5F;
//float space = 3;
// B2021-081: Blue was too intense with an alpha of 255 Read was too light with an alpha of 96 // B2021-081: Blue was too intense with an alpha of 255 Read was too light with an alpha of 96
if (color != System.Drawing.Color.Red) if (color != System.Drawing.Color.Red)
_Color = System.Drawing.Color.FromArgb(96, color); _Color = System.Drawing.Color.FromArgb(96, color);
else else
_Color = color; // C2021-019: save color for color override _Color = color; // C2021-019: save color for color override
_Opacity = opacity; _Opacity = opacity;
//SetDotPattern(radius, space);
//SetTextLayout();
} }
#region commentedout
//private void SetTextLayout()
//{
// Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
// _Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont.GetAscentPoint(_Text, 12);
// //float hgtD = basefont.GetDescentPoint(text,20);
// float wid = _Basefont.GetWidthPointKerned(_Text, 12);
// //Console.WriteLine("{0} {1} {2}",hgtA,hgtD,wid);
// float rho = wid / hgtA;
// float x2 = (rho * pageSize.Height - pageSize.Width) / (rho * rho - 1);
// float y1 = x2 * rho;
// float y2 = pageSize.Height - y1;
// float x1 = pageSize.Width - x2;
// _XOffset = x2 + x1 / 2;
// _YOffset = y1 / 2;
// _TextAngle = CalcAngle(y1, x1);
// _Fontsize = (float)(10 * Math.Sqrt(x2 * x2 + y2 * y2) / hgtA);
//}
//public void SetDotPattern(float radius, float space)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 2, radius * 2, radius * 2 + space, radius * 2 + space);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Circle(radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetSquareDotPattern(float radius)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = .5f * _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Rectangle(0, 0, radius, radius);
// _PatternPainter.Rectangle(radius * 2, radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetHashPattern(float thickness, float size)
//{
// _PatternPainter = _ContentByte.CreatePattern(size, size, size, size);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// gState.StrokeOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetLineWidth(.01F);
// _PatternPainter.SetColorStroke(_Color); // Set color
// _PatternPainter.MoveTo(0, 0);
// _PatternPainter.LineTo(size, size);
// _PatternPainter.MoveTo(size, 0);
// _PatternPainter.LineTo(0, size);
// _PatternPainter.Stroke();
//}
//public void SetTextPattern(float fontSize, float space)
//{
// float hgtA = _Basefont.GetAscentPoint(_Text, fontSize) + _Basefont.GetDescentPoint(_Text, fontSize);
// float wid = _Basefont.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid, hgtA, wid + space, hgtA + space);
// _PatternPainter.SetFontAndSize(_Basefont, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.EndText();
//}
//public void SetTextPattern2(float fontSize)
//{
// BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
// float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
// _PatternPainter.SetFontAndSize(_Basefont2, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0);
// _PatternPainter.EndText();
//}
#endregion
public void Draw() public void Draw()
{ {
_ContentByte.SaveState(); _ContentByte.SaveState();
//_ContentByte.BeginText();
//_ContentByte.SetPatternFill(_PatternPainter);
//_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
//_ContentByte.SetLineWidth(.5F);
//_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size
//_ContentByte.SetColorStroke(_Color);
//PdfGState gs2 = new PdfGState();
//gs2.StrokeOpacity = _Opacity;
//_ContentByte.SetGState(gs2);
//_ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, _Text, _XOffset, _YOffset, _TextAngle);// Draw the text
//_ContentByte.EndText();
_ContentByte.AddImage(WatermarkImage); _ContentByte.AddImage(WatermarkImage);
_ContentByte.RestoreState(); _ContentByte.RestoreState();
} }
//private float CalcAngle(float opposite, float adjacent)
//{
// return (float)(Math.Atan2(opposite, adjacent) * (180 / Math.PI));
//}
private Image _WatermarkImage; private Image _WatermarkImage;
public Image WatermarkImage public Image WatermarkImage
{ {
@@ -1452,7 +1091,6 @@ namespace Volian.Svg.Library
_Color, System.Drawing.Color.Transparent); _Color, System.Drawing.Color.Transparent);
g.FillPath(aHatchBrush, gp); g.FillPath(aHatchBrush, gp);
g.DrawPath(new System.Drawing.Pen(_Color), gp); g.DrawPath(new System.Drawing.Pen(_Color), gp);
//g.DrawRectangle(System.Drawing.Pens.Cyan, 0, 0, bnds.Width, bnds.Height);
} }
_WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png); _WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png);
_WatermarkImage.SetAbsolutePosition(72, 72); _WatermarkImage.SetAbsolutePosition(72, 72);
@@ -1481,11 +1119,4 @@ namespace Volian.Svg.Library
} }
} }
public enum SvgWatermarkFill
{
Dots = 1,
Text1 = 2,
Text2 = 3,
Hash = 4
}
} }
+1 -107
View File
@@ -1,108 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using LBWordLibrary;
namespace Volian.MSWord namespace Volian.MSWord
{ {
public class WordDoc public class WordDoc
{ {
private static LBApplicationClass _MyWordApp;
public static LBApplicationClass MyWordApp
{
get
{
if (_MyWordApp == null)
_MyWordApp = new LBApplicationClass();
return WordDoc._MyWordApp;
}
}
private LBDocumentClass _MyWordDoc;
public LBDocumentClass MyWordDoc
{
get
{ return _MyWordDoc; }
}
private string _DocName;
public string DocName
{
get { return _DocName; }
set { _DocName = value; }
}
public WordDoc(string docName)
{
DocName = docName;
_MyWordDoc = MyWordApp.Documents.Open(_DocName, false);
}
public string Save()
{
try
{
MyWordDoc.SaveAs(DocName, LBWdSaveFormat.wdFormatDocument);
return "Successful Save";
}
catch (Exception ex)
{
return string.Format("Error during Doc save - {0}", ex.Message);
}
}
public string Save(string docName)
{
DocName = docName;
return Save();
}
public void Close()
{
MyWordDoc.Close(false);
}
public float SetLineSpacing(float linesPerInch) // if need landscape set too: , bool landscape)
{
float retval = 0;
LBSelection selection = MyWordApp.Selection;
selection.WholeStory();
retval = selection.ParagraphFormat.LineSpacing;
selection.ParagraphFormat.SpaceBefore = 0;
selection.ParagraphFormat.SpaceAfter = 0;
selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly;
selection.ParagraphFormat.LineSpacing = 72 / linesPerInch;
return retval;
}
public float Length
{
get
{
try
{
return MyWordDoc.Length;
}
catch (Exception ex)
{
Console.WriteLine("Error Getting Length, {0}", ex.Message);
}
return 0;
}
}
public static void CloseApp()
{
if(_MyWordApp != null)
{
TryToQuit();
KillWordApps();
}
}
private static void TryToQuit()
{
try
{
_MyWordApp.Quit(false);
}
catch (Exception ex)
{
Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message);
}
_MyWordApp=null;
}
public static void KillWordApps() public static void KillWordApps()
{ {
try try
@@ -124,15 +25,8 @@ namespace Volian.MSWord
if(proc.MainWindowTitle=="") if(proc.MainWindowTitle=="")
proc.Kill(); proc.Kill();
} }
_MyWordApp = null;
}
public static System.Diagnostics.Process[] WordProcesses
{
get
{
return System.Diagnostics.Process.GetProcessesByName("WINWORD");
}
} }
public static System.Diagnostics.Process[] WordProcesses => System.Diagnostics.Process.GetProcessesByName("WINWORD");
} }
} }
@@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Xml; using System.Xml;
using System.Xml.Schema; using System.Xml.Schema;
using System.Collections;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -21,10 +19,7 @@ namespace vlnObjectLibrary
/* See if I need to do anything */ /* See if I need to do anything */
} }
#region XML Serialization #region XML Serialization
public void WriteXml(XmlWriter w) public void WriteXml(XmlWriter w) => WriteXml(w, true);
{
WriteXml(w, true);
}
public void WriteXml(XmlWriter w,bool bSaveParent) public void WriteXml(XmlWriter w,bool bSaveParent)
{ {
w.WriteAttributeString("title", Title); w.WriteAttributeString("title", Title);
@@ -74,10 +69,7 @@ namespace vlnObjectLibrary
xr.Close(); xr.Close();
} }
public XmlSchema GetSchema() public XmlSchema GetSchema() => (null);
{
return (null);
}
#endregion #endregion
#region Constructors #region Constructors
public vlnObject(vlnObject parent, string type, string title, string path) public vlnObject(vlnObject parent, string type, string title, string path)
@@ -148,10 +140,7 @@ namespace vlnObjectLibrary
vlnObject b = new vlnObject(this, type, title, path); vlnObject b = new vlnObject(this, type, title, path);
return b; return b;
} }
public void AddProp(string name, string value) public void AddProp(string name, string value) => PropArray[name.ToUpper()] = value;
{
PropArray[name.ToUpper()] = value;
}
public void AddProp(XmlReader xr) public void AddProp(XmlReader xr)
{ {
SkipToElement(xr); SkipToElement(xr);
@@ -182,10 +171,7 @@ namespace vlnObjectLibrary
m_Children = value; m_Children = value;
} }
} }
public void LoadChildren(string sXml) public void LoadChildren(string sXml) => LoadChildren(new XmlTextReader(new StringReader(sXml)));
{
LoadChildren(new XmlTextReader(new StringReader(sXml)));
}
public void LoadChildren(XmlReader xr) public void LoadChildren(XmlReader xr)
{ {
m_Children = new List<vlnObject>(); m_Children = new List<vlnObject>();
@@ -212,8 +198,6 @@ namespace vlnObjectLibrary
} }
public string ProcessString(string s) public string ProcessString(string s)
{ {
//string retval=s;
//string retval = Regex.Replace(s, "{[.]*}", new MatchEvaluator(ReplaceKey));
string retval = Regex.Replace(s, "{{.*?}}", new MatchEvaluator(ReplaceRow)); string retval = Regex.Replace(s, "{{.*?}}", new MatchEvaluator(ReplaceRow));
retval = Regex.Replace(retval, "{.*?}", new MatchEvaluator(ReplaceDrv)); retval = Regex.Replace(retval, "{.*?}", new MatchEvaluator(ReplaceDrv));
return retval; return retval;
@@ -1,12 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using vlnObjectLibrary; using vlnObjectLibrary;
using System.Xml; using System.Xml;
using System.IO; using System.IO;
using System.Data; using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
using System.Reflection;
namespace vlnServerLibrary namespace vlnServerLibrary
{ {
@@ -16,16 +14,8 @@ namespace vlnServerLibrary
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Static Properties #region Static Properties
private static string m_XmlControlPath = "vlnControl.xml";
private static XmlDocument m_XmlControl; private static XmlDocument m_XmlControl;
public static string XMLControlPath public static string XMLControlPath { get; set; } = "vlnControl.xml";
{
get { return m_XmlControlPath; }
set
{
m_XmlControlPath = value;
}
}
public static XmlDocument XMLControl public static XmlDocument XMLControl
{ {
get get
@@ -35,7 +25,7 @@ namespace vlnServerLibrary
m_XmlControl = new XmlDocument(); m_XmlControl = new XmlDocument();
lock (m_XmlControl) lock (m_XmlControl)
{ {
m_XmlControl.Load(m_XmlControlPath); m_XmlControl.Load(XMLControlPath);
} }
} }
return m_XmlControl; return m_XmlControl;
@@ -75,10 +65,7 @@ namespace vlnServerLibrary
string xPath = string.Format(".//dbObject[@type='{0}']/@{1}", o.Parent.Type, s); string xPath = string.Format(".//dbObject[@type='{0}']/@{1}", o.Parent.Type, s);
return LookUpX(o,xPath); return LookUpX(o,xPath);
} }
protected string LookUpX(vlnObject o,string xPath) protected string LookUpX(vlnObject o, string xPath) => LookUpX(o, xPath, XMLControl);
{
return LookUpX(o,xPath, XMLControl);
}
private void LoadChildrenFromDB(vlnObject o,string sSelect) private void LoadChildrenFromDB(vlnObject o,string sSelect)
{ {
if (sSelect != "") if (sSelect != "")
@@ -89,7 +76,6 @@ namespace vlnServerLibrary
OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder(s); OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder(s);
OleDbConnection dbConn = new OleDbConnection(csb.ConnectionString); OleDbConnection dbConn = new OleDbConnection(csb.ConnectionString);
string sTable = LookUp(o,"table"); string sTable = LookUp(o,"table");
//if (dbConn.State != ConnectionState.Open) dbConn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(sSelect, dbConn); OleDbDataAdapter da = new OleDbDataAdapter(sSelect, dbConn);
DataSet ds = new DataSet(); DataSet ds = new DataSet();
da.Fill(ds, sTable); da.Fill(ds, sTable);
@@ -222,7 +208,7 @@ namespace vlnServerLibrary
string sRetval = sDefault; string sRetval = sDefault;
if (sRetval[0] == '~') if (sRetval[0] == '~')
{ {
string sTitlePath = sPath + "\\title"; string sTitlePath = $"{sPath}\\title";
if (File.Exists(sTitlePath)) if (File.Exists(sTitlePath))
{ {
StreamReader sr = File.OpenText(sTitlePath); StreamReader sr = File.OpenText(sTitlePath);
+34 -137
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@@ -19,34 +18,17 @@ namespace XYPlots
// C2018-035 Added error Handling to provide more useful information when a plot fails // C2018-035 Added error Handling to provide more useful information when a plot fails
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
static string _MyFontFamily = "Letter Gothic Tall"; public static string MyFontFamily { get; set; } = "Letter Gothic Tall";
public static string MyFontFamily
{
get { return _MyFontFamily; }
set { _MyFontFamily = value; }
}
private static Color _BlackColor = Color.Red; private static Color _BlackColor = Color.Red;
public static Color BlackColor public static Color BlackColor
{ {
get { return VG.VG.BlackColor; } get { return VG.VG.BlackColor; }
set { VG.VG.BlackColor = value; } set { VG.VG.BlackColor = value; }
} }
public float Width public float Width => 72 * (LeftMargin + RightMargin) + printerunits[0] * .05F;
{ public float Height => 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F;
get { return 72 * (LeftMargin + RightMargin) + printerunits[0] * .05F; } public float PlotWidth => (float)userunits[X];
} public float PlotHeight => (float)userunits[Y];
public float Height
{
get { return 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F; }
}
public float PlotWidth
{
get { return (float) userunits[X]; }
}
public float PlotHeight
{
get { return (float) userunits[Y]; }
}
private double ConvertToTwips = 4.8; private double ConvertToTwips = 4.8;
static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */ static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */
static int DPI = 1440; //300; static int DPI = 1440; //300;
@@ -146,7 +128,7 @@ namespace XYPlots
private bool[,] doLOG10 = { { false, false }, { false, false } }; private bool[,] doLOG10 = { { false, false }, { false, false } };
public struct point public struct point
{ {
public int[] xyValue; //new int[Dimensions]; public int[] xyValue;
} }
public struct XyBox public struct XyBox
{ {
@@ -162,22 +144,16 @@ namespace XYPlots
private XyBoxes ActiveBoxes = new XyBoxes(); private XyBoxes ActiveBoxes = new XyBoxes();
public class DataPoint public class DataPoint
{ {
public override string ToString() // Make it easier to Debug // Make it easier to Debug
{ public override string ToString() => string.Format("{0},{1}", APoint.xyValue[X], APoint.xyValue[Y]);
return string.Format("{0},{1}", APoint.xyValue[X],APoint.xyValue[Y]);
}
private point m_APoint; private point m_APoint;
public point APoint public point APoint
{ {
get { return m_APoint; } get { return m_APoint; }
set { m_APoint = value; } set { m_APoint = value; }
} }
private double m_slope; // slope of tangent to circle at this point
public double slope public double slope { get; set; }
{
get { return m_slope; }
set { m_slope = value; }
}
} }
public class DataPoints : List<DataPoint> public class DataPoints : List<DataPoint>
{ {
@@ -211,40 +187,19 @@ namespace XYPlots
result = (double)(val * val); result = (double)(val * val);
return result; return result;
} }
private double FMin(double f1, double f2) private double FMin(double f1, double f2) => ((f1 >= f2) ? f2 : f1);
{ private double FMax(double f1, double f2) => ((f1 >= f2) ? f1 : f2);
return ((f1 >= f2) ? f2 : f1); private double atan_deg(double x) => (Math.Atan(x) * 180.0 / PI);
} private double cos_deg(double x) => (Math.Cos(x * PI / 180.0));
private double FMax(double f1, double f2) private double tan_deg(double x) => (Math.Tan(x * PI / 180.0));
{ private double sin_deg(double x) => (Math.Sin(x * PI / 180.0));
return ((f1 >= f2) ? f1 : f2);
}
private double atan_deg(double x)
{
return (Math.Atan(x) * 180.0 / PI);
}
private double cos_deg(double x)
{
return (Math.Cos(x * PI / 180.0));
}
private double tan_deg(double x)
{
return (Math.Tan(x * PI / 180.0));
}
private double sin_deg(double x)
{
return (Math.Sin(x * PI / 180.0));
}
/// <summary> /// <summary>
/// the following function is pointed to by a function pointer /// the following function is pointed to by a function pointer
/// and is provided for compatibility with log10() function usage /// and is provided for compatibility with log10() function usage
/// </summary> /// </summary>
/// <param name="x"></param> /// <param name="x"></param>
/// <returns></returns> /// <returns></returns>
private double linear(double x) private double linear(double x) => x;
{
return x;
}
private bool isWhiteSpace(char cptr) private bool isWhiteSpace(char cptr)
{ {
bool rtnval = false; bool rtnval = false;
@@ -332,10 +287,7 @@ namespace XYPlots
BuffPtr = 0; BuffPtr = 0;
return true; return true;
} }
private void LoadBuffFromString(string str) private void LoadBuffFromString(string str) => Buff = str;
{
Buff = str;
}
private int getint() private int getint()
{ {
int retval; int retval;
@@ -381,25 +333,14 @@ namespace XYPlots
retval = Convert.ToDouble(NextPiece()); retval = Convert.ToDouble(NextPiece());
return retval; return retval;
} }
private char NextChar() private char NextChar() => Buff[BuffPtr++];
{
return Buff[BuffPtr++];
}
private char getchr() private char getchr()
{ {
string nxtstring = NextPiece(); string nxtstring = NextPiece();
if (nxtstring.Equals("")) return nxtstring.Equals("") ? '\0' : nxtstring[0];
return '\0';
else
return nxtstring[0];
}
// C2018-035 Added error Handling to provide more useful information when a plot fails
private string _XYPlotIssue;
public string XYPlotIssue
{
get { return _XYPlotIssue; }
set { _XYPlotIssue = value; }
} }
public string XYPlotIssue { get; set; }
private point GetPair(int flag) private point GetPair(int flag)
{ {
point retval = new point(); point retval = new point();
@@ -489,7 +430,6 @@ namespace XYPlots
Buff = Buff.Substring(4); Buff = Buff.Substring(4);
} }
// remove an extra spaces between >< // remove an extra spaces between ><
//Buff = Regex.Replace(Buff, @"[ ]+<", "<");
Buff = Buff.Replace(">\r ", ">\r\n "); Buff = Buff.Replace(">\r ", ">\r\n ");
Buff = Buff.Replace(">\n ", ">\r\n "); // C2022-003 if RO has symbols Buff = Buff.Replace(">\n ", ">\r\n "); // C2022-003 if RO has symbols
Buff = Regex.Replace(Buff, @"[ ]+<", "<"); Buff = Regex.Replace(Buff, @"[ ]+<", "<");
@@ -595,10 +535,7 @@ namespace XYPlots
Offset[PLOT, Y] = -Scale[PLOT, Y] * Math.Log10(minimum[Y]); Offset[PLOT, Y] = -Scale[PLOT, Y] * Math.Log10(minimum[Y]);
} }
} }
private void GetAxisTitle(int flag) private void GetAxisTitle(int flag) => AxisTitles[flag] = GetString();
{
AxisTitles[flag] = GetString();
}
private string stripSuperSub(string instr) private string stripSuperSub(string instr)
{ {
StringBuilder sb = new StringBuilder(instr); StringBuilder sb = new StringBuilder(instr);
@@ -749,27 +686,14 @@ namespace XYPlots
SetPenDiameter(5); SetPenDiameter(5);
BoxRelative(printerunits[X], printerunits[Y], CurPenWidth, pg, vgOutput); BoxRelative(printerunits[X], printerunits[Y], CurPenWidth, pg, vgOutput);
if (GridOnFlag == 0) Visible = 0; if (GridOnFlag == 0) Visible = 0;
//if (vgOutput is VGOut_Graphics)
//{
DoGrid(X, pg, vgOutput, 1); DoGrid(X, pg, vgOutput, 1);
DoGrid(Y, pg, vgOutput, 1); DoGrid(Y, pg, vgOutput, 1);
DoGrid(X, pg, vgOutput, 2); DoGrid(X, pg, vgOutput, 2);
DoGrid(Y, pg, vgOutput, 2); DoGrid(Y, pg, vgOutput, 2);
DoGrid(X, pg, vgOutput, 3); DoGrid(X, pg, vgOutput, 3);
DoGrid(Y, pg, vgOutput, 3); DoGrid(Y, pg, vgOutput, 3);
//}
//else if (vgOutput is VGOut_C1PDF)
//{
// DrawDirection = Y;
// DoGrid(X, pg, vgOutput);
// DrawDirection = X;
// DoGrid(Y, pg, vgOutput);
//}
Visible = 1; Visible = 1;
RecallPosition(); RecallPosition();
// Draw outline last to overlap any grid lines.
//SetPenDiameter(5);
//BoxRelative(printerunits[X], printerunits[Y], CurPenWidth, pg, vgOutput);
} }
private void DoGrid(int flag, VG.Page pg, IVGOutput vgOutput) private void DoGrid(int flag, VG.Page pg, IVGOutput vgOutput)
{ {
@@ -890,7 +814,7 @@ namespace XYPlots
{ {
if (!SubLogValue) if (!SubLogValue)
DrawGridRelative((int)(-30 * ConvertToTwips), 0, pg, vgOutput); DrawGridRelative((int)(-30 * ConvertToTwips), 0, pg, vgOutput);
// OLD: MoveRelative((int)(-(15 + 300 * size / (int)FontPitch) * ConvertToTwips), (int)(-15 * ConvertToTwips));
MoveRelative((int)(-(14 + 250 * size / (int)FontPitch) * ConvertToTwips), (int)(-16 * ConvertToTwips)); MoveRelative((int)(-(14 + 250 * size / (int)FontPitch) * ConvertToTwips), (int)(-16 * ConvertToTwips));
if ((AxisLabel[1]) != 0) if ((AxisLabel[1]) != 0)
{ {
@@ -1438,10 +1362,7 @@ namespace XYPlots
CurPenWidth = (int)(pd * ConvertToTwips); CurPenWidth = (int)(pd * ConvertToTwips);
} }
} }
private void PrintStackError(string relation, int limit) private void PrintStackError(string relation, int limit) => MessageBox.Show(String.Format("Position Stack Pointer {0} {1}", relation, limit.ToString()), "Print Stack Error");
{
MessageBox.Show(String.Format("Position Stack Pointer {0} {1}", relation, limit.ToString()), "Print Stack Error");
}
private void SavePosition() private void SavePosition()
{ {
if (stack >= MAX_XY_STACK) PrintStackError(">=", MAX_XY_STACK); if (stack >= MAX_XY_STACK) PrintStackError(">=", MAX_XY_STACK);
@@ -1454,14 +1375,8 @@ namespace XYPlots
Position[X] = SavedX[--stack]; Position[X] = SavedX[--stack];
Position[Y] = SavedY[stack]; Position[Y] = SavedY[stack];
} }
private void MoveTo(point pnt) private void MoveTo(point pnt) => MoveAbsolute(pnt.xyValue[X], pnt.xyValue[Y]);
{ private void DrawTo(point pnt, VG.Page pg, IVGOutput vgOutput) => DrawAbsolute(pnt.xyValue[X], pnt.xyValue[Y], pg, vgOutput);
MoveAbsolute(pnt.xyValue[X], pnt.xyValue[Y]);
}
private void DrawTo(point pnt, VG.Page pg, IVGOutput vgOutput)
{
DrawAbsolute(pnt.xyValue[X], pnt.xyValue[Y], pg, vgOutput);
}
private void MoveAbsolute(int ptx, int pty) private void MoveAbsolute(int ptx, int pty)
{ {
int x, y; int x, y;
@@ -1483,10 +1398,7 @@ namespace XYPlots
y = Position[Y] - pty; y = Position[Y] - pty;
DrawGridRelative(x, y, pg, vgOutput); DrawGridRelative(x, y, pg, vgOutput);
} }
private void relval(string ptr, int i) private void relval(string ptr, int i) => ptr = string.Format("+{0}", i.ToString());
{
ptr = string.Format("+{0}", i.ToString());
}
private void MoveRelative(int x, int y) private void MoveRelative(int x, int y)
{ {
Position[X] += x; Position[X] += x;
@@ -1760,14 +1672,8 @@ namespace XYPlots
GraphText(tstr.ToString(), pg, vgOutput); GraphText(tstr.ToString(), pg, vgOutput);
RecallPosition(); RecallPosition();
} }
private void FreeBoxList() private void FreeBoxList() => AllBoxes.Clear();
{ private void FreeLineList() => AllPlots.Clear();
AllBoxes.Clear();
}
private void FreeLineList()
{
AllPlots.Clear();
}
private void Init_Graphic_Vars() private void Init_Graphic_Vars()
{ {
int i; int i;
@@ -1923,18 +1829,9 @@ namespace XYPlots
//VG.VG_Arc.iColor = 0; //VG.VG_Arc.iColor = 0;
//#endif //#endif
} }
private int _OffsetX = 0;
public int OffsetX public int OffsetX { get; set; } = 0;
{ public int OffsetY { get; set; } = 0;
get { return _OffsetX; }
set { _OffsetX = value; }
}
private int _OffsetY = 0;
public int OffsetY
{
get { return _OffsetY; }
set { _OffsetY = value; }
}
public void Setup() public void Setup()
{ {
char Command, PrevCommand = ' '; char Command, PrevCommand = ' ';
@@ -2014,7 +1911,7 @@ namespace XYPlots
step = "FreeLineList";FreeLineList(); step = "FreeLineList";FreeLineList();
step = "CloseGraph";CloseGraph(); step = "CloseGraph";CloseGraph();
} }
catch (Exception ex) catch (Exception)
{ {
_MyLog.WarnFormat("X/Y Plot Error - {0} - {1} - {2}", step, XYPlotIssue ?? "Unknown Issue"); _MyLog.WarnFormat("X/Y Plot Error - {0} - {1} - {2}", step, XYPlotIssue ?? "Unknown Issue");
throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue")); throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue"));
-9
View File
@@ -1,17 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using VG; using VG;
//using XYPlots;
namespace XYPlots namespace XYPlots
{ {