This commit is contained in:
@@ -11,14 +11,54 @@ using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace Volian.Print.Library
|
||||
{
|
||||
|
||||
public class VlnSvgPageHelper:SvgPageHelper
|
||||
{
|
||||
//vlnParagraphs _MyParagraphs = new vlnParagraphs(null);
|
||||
//public vlnParagraphs MyParagraphs
|
||||
//{
|
||||
// get { return _MyParagraphs; }
|
||||
// set { _MyParagraphs = value; }
|
||||
//}
|
||||
Dictionary<int, vlnParagraph> _MyParagraphs = new Dictionary<int, vlnParagraph>();
|
||||
public Dictionary<int, vlnParagraph> MyParagraphs
|
||||
{
|
||||
get { return _MyParagraphs; }
|
||||
set { _MyParagraphs = value; }
|
||||
}
|
||||
float _YMultiplier = 1;
|
||||
public float YMultiplier
|
||||
{
|
||||
get { return _YMultiplier; }
|
||||
set { _YMultiplier = value; }
|
||||
}
|
||||
public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
|
||||
{
|
||||
base.OnEndPage(writer, document);
|
||||
DrawChangeBars(writer.DirectContent);
|
||||
//DrawBackground(writer.DirectContentUnder);
|
||||
//DrawPageList(writer.DirectContent);
|
||||
//DrawWatermark(writer.DirectContentUnder);
|
||||
//DrawZoomOMatic(writer.DirectContent);
|
||||
//CurrentPageNumber++;
|
||||
}
|
||||
private void DrawChangeBars(PdfContentByte cb)
|
||||
{
|
||||
foreach (vlnChangeBar vcb in MyChangeBars)
|
||||
{
|
||||
// TODO: Pass in zeroes because topdf is inherited.
|
||||
vcb.ToPdf(cb, 0, 0, 0);
|
||||
}
|
||||
_MyChangeBars = new List<vlnChangeBar>();
|
||||
}
|
||||
#region SectionLevelData
|
||||
private ChangeBarDefinition _ChangeBarDefinition;
|
||||
public ChangeBarDefinition ChangeBarDefinition
|
||||
public ChangeBarDefinition ChangeBarDefinition
|
||||
{
|
||||
get { return _ChangeBarDefinition; }
|
||||
set { _ChangeBarDefinition = value; }
|
||||
}
|
||||
#endregion
|
||||
private PdfLayer _TextLayer;
|
||||
public PdfLayer TextLayer
|
||||
{
|
||||
@@ -41,6 +81,15 @@ namespace Volian.Print.Library
|
||||
MySvg = BuildSvg(_MySection);
|
||||
}
|
||||
}
|
||||
private int _MaxRNO;
|
||||
public int MaxRNO
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MaxRNO == 0) _MaxRNO = _MySection.ColumnMode;
|
||||
return _MaxRNO;
|
||||
}
|
||||
}
|
||||
private int _CurrentPageOf = 0;
|
||||
public int CurrentPageOf
|
||||
{
|
||||
@@ -59,6 +108,105 @@ namespace Volian.Print.Library
|
||||
get { return _RevDate; }
|
||||
set { _RevDate = value; }
|
||||
}
|
||||
private List<vlnChangeBar> _MyChangeBars = new List<vlnChangeBar>();
|
||||
public List<vlnChangeBar> MyChangeBars
|
||||
{
|
||||
get { return _MyChangeBars; }
|
||||
set { _MyChangeBars = value; }
|
||||
}
|
||||
public void AddChangeBar(vlnChangeBar vcb, string cbmess)
|
||||
{
|
||||
vlnChangeBar prevCB = null;
|
||||
foreach (vlnChangeBar cb in MyChangeBars)
|
||||
{
|
||||
// only look at changebars in same column
|
||||
if (cb.XOffset == vcb.XOffset)
|
||||
{
|
||||
// if the two change bars end at same location, set prevCB which will
|
||||
// adjust the length (top position) of the change bar. This condition
|
||||
// also flags that the change bar texts overlap.
|
||||
if (cb.YChangeBarBottom == vcb.YChangeBarBottom) prevCB = cb;
|
||||
|
||||
// continuous case, if changes bars overlap, adjust size and don't add new one to
|
||||
// the MyChangeBars list.
|
||||
if (MySection.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ContinuousChangeBars)
|
||||
{
|
||||
if (OverlapOrSpan(cb, vcb))
|
||||
{
|
||||
if (prevCB == null) prevCB = cb;
|
||||
else if (prevCB.YChangeBarBottom > cb.YChangeBarBottom) prevCB = cb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if this and the prevCB overlap, adjust yoffset/height/ybottom in the prevCB so that both change bars are
|
||||
// included in this Dictionary item. A new vlnChangeBar is not added to the MyChangeBars list, the current
|
||||
// one that overlaps with the new is adjusted.
|
||||
if (prevCB != null)
|
||||
{
|
||||
// Bottom for both change bars is same, adjust top (YOffset) and height.
|
||||
if (prevCB.YChangeBarBottom == vcb.YChangeBarBottom)
|
||||
{
|
||||
prevCB.YOffset = Math.Max(prevCB.YOffset, vcb.YOffset);
|
||||
float yChangeBarBottomExtend = prevCB.YChangeBarBottomExtend;
|
||||
prevCB.Height = Math.Max(prevCB.Height, vcb.Height);
|
||||
prevCB.YExtendLine = prevCB.YChangeBarBottom - Math.Min(yChangeBarBottomExtend, vcb.YChangeBarBottomExtend); //Math.Max(prevCB.YExtendLine, vcb.YExtendLine);
|
||||
// if a change bar message at this ychangebarbottom exists, see which message is used
|
||||
if (cbmess != null && prevCB.Messages.ContainsKey(prevCB.YChangeBarBottom)) UpdateCbMessage(cbmess, prevCB, vcb.XOffset);
|
||||
return;
|
||||
}
|
||||
// Bottom locations are not the same, but another change bar is not added, i.e. the
|
||||
// length of the line is adjusted.
|
||||
prevCB.YOffset = Math.Max(prevCB.YOffset, vcb.YOffset);
|
||||
float yChangeBarBottomExtend1 = prevCB.YChangeBarBottomExtend;
|
||||
prevCB.YChangeBarBottom = Math.Min(prevCB.YChangeBarBottom, vcb.YChangeBarBottom);
|
||||
prevCB.YExtendLine = prevCB.YChangeBarBottom - Math.Min(yChangeBarBottomExtend1, vcb.YChangeBarBottomExtend); //Math.Max(prevCB.YExtendLine, vcb.YExtendLine);
|
||||
// Two messages at this location, determine which one to use
|
||||
if (cbmess != null && prevCB.Messages.ContainsKey(prevCB.YChangeBarBottom)) UpdateCbMessage(cbmess, prevCB, vcb.XOffset);
|
||||
|
||||
// no message at this location, just add it.
|
||||
else if (cbmess != null)
|
||||
prevCB.Messages.Add(vcb.YChangeBarBottom, new vlnChangeBarMessage(vcb.MyParent.XOffset, cbmess));
|
||||
return;
|
||||
}
|
||||
|
||||
// There was no overlap, add a message if it exists, and then add the change bar to the MyChangeBars list.
|
||||
if (cbmess != null) vcb.Messages.Add(vcb.YChangeBarBottom, new vlnChangeBarMessage(vcb.MyParent.XOffset, cbmess));
|
||||
MyChangeBars.Add(vcb);
|
||||
}
|
||||
|
||||
private static void UpdateCbMessage(string cbmess, vlnChangeBar prevCB, float xoff)
|
||||
{
|
||||
// If there are two messages at the same location, for example an AER change bar & and RNO
|
||||
// change bar, and the messages have different text, see which change bar message should be
|
||||
// added, i.e. use the one in 'rno', the greatest x value.
|
||||
vlnChangeBarMessage tmp = prevCB.Messages[prevCB.YChangeBarBottom];
|
||||
if (cbmess != tmp.Message)
|
||||
{
|
||||
if (xoff > tmp.ParentX)
|
||||
{
|
||||
prevCB.Messages.Remove(prevCB.YChangeBarBottom);
|
||||
prevCB.Messages.Add(prevCB.YChangeBarBottom, new vlnChangeBarMessage(xoff, cbmess));
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool OverlapOrSpan(vlnChangeBar cb, vlnChangeBar vcb)
|
||||
{
|
||||
if (cb.MyParent.MyItemInfo.MyHLS.ItemID != vcb.MyParent.MyItemInfo.MyHLS.ItemID) return false;
|
||||
// cb.Yoffset is within range of vcb:
|
||||
if (cb.YOffset <= vcb.YOffset &&
|
||||
cb.YOffset >= (vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true;
|
||||
// cb.YChangeBarBottom is within range of vcb:
|
||||
if ((cb.YChangeBarBottomExtend-vlnPrintObject._SixLinesPerInch) <= vcb.YOffset &&
|
||||
cb.YChangeBarBottomExtend >= (vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true;
|
||||
// vcb.Yoffset is within range of cb:
|
||||
if (vcb.YOffset <= cb.YOffset &&
|
||||
vcb.YOffset >= (cb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true;
|
||||
// vcb.YChangeBarBottom is within range of cb:
|
||||
if ((vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch) <= cb.YOffset &&
|
||||
vcb.YChangeBarBottomExtend >= (cb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true;
|
||||
return false;
|
||||
}
|
||||
public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection)
|
||||
{
|
||||
MySection = mySection;
|
||||
@@ -286,7 +434,7 @@ namespace Volian.Print.Library
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public class ChangeBarDefinition
|
||||
public class ChangeBarDefinition // anything that is section level should go in here.
|
||||
{
|
||||
private DocVersionConfig.PrintChangeBar _MyChangeBarType;
|
||||
public DocVersionConfig.PrintChangeBar MyChangeBarType
|
||||
@@ -306,18 +454,21 @@ namespace Volian.Print.Library
|
||||
get { return _MyChangeBarText; }
|
||||
set { _MyChangeBarText = value; }
|
||||
}
|
||||
private string _MyChangeBarMessage;
|
||||
private string _MyChangeBarMessage; // user defined change bar message from docconfig
|
||||
public string MyChangeBarMessage
|
||||
{
|
||||
get { return _MyChangeBarMessage; }
|
||||
set { _MyChangeBarMessage = value; }
|
||||
}
|
||||
private int _MyChangeBarColumn; //TODO Should this be two dimensional array
|
||||
private int _MyChangeBarColumn; // two dimensional array, if both on same side, values are =
|
||||
public int MyChangeBarColumn
|
||||
{
|
||||
get { return _MyChangeBarColumn; }
|
||||
set { _MyChangeBarColumn = value; }
|
||||
}
|
||||
/*
|
||||
* could have line thickness (set default from 16-bit), line color (set default as black), line style
|
||||
*/
|
||||
public ChangeBarDefinition()
|
||||
{
|
||||
}
|
||||
@@ -326,7 +477,42 @@ namespace Volian.Print.Library
|
||||
_MyChangeBarType = myCBT;
|
||||
_MyChangeBarLoc = myCBL;
|
||||
_MyChangeBarText = myCBTxt;
|
||||
_MyChangeBarMessage = myCBMsg;
|
||||
}
|
||||
public ChangeBarDefinition(DocVersionConfig docverConfig, FormatInfo formatInfo)
|
||||
{
|
||||
// if there is not overridden data on the docversion, prompt user...
|
||||
ChangeBarData changeBarData = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData;
|
||||
if (docverConfig == null || docverConfig.Print_ChangeBar == DocVersionConfig.PrintChangeBar.SelectBeforePrinting)
|
||||
{
|
||||
// use these for now, i.e. this is what user would have selected from dialog.
|
||||
_MyChangeBarType = DocVersionConfig.PrintChangeBar.WithDefault;
|
||||
_MyChangeBarLoc = DocVersionConfig.PrintChangeBarLoc.OutsideBox;
|
||||
_MyChangeBarText = DocVersionConfig.PrintChangeBarText.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyChangeBarType = docverConfig.Print_ChangeBar;
|
||||
_MyChangeBarLoc = docverConfig.Print_ChangeBarLoc;
|
||||
_MyChangeBarText = docverConfig.Print_ChangeBarText;
|
||||
}
|
||||
if (_MyChangeBarType == DocVersionConfig.PrintChangeBar.WithDefault) // get data from format
|
||||
{
|
||||
_MyChangeBarText = changeBarData.ChangeBarMessage == "ChgID" ? DocVersionConfig.PrintChangeBarText.ChgID :
|
||||
changeBarData.ChangeBarMessage == "DateAndChgID" ? DocVersionConfig.PrintChangeBarText.DateChgID :
|
||||
changeBarData.ChangeBarMessage == "None" ? DocVersionConfig.PrintChangeBarText.None :
|
||||
changeBarData.ChangeBarMessage == "RevNum" ? DocVersionConfig.PrintChangeBarText.RevNum : DocVersionConfig.PrintChangeBarText.UserDef;
|
||||
}
|
||||
if (_MyChangeBarType != DocVersionConfig.PrintChangeBar.Without)
|
||||
{
|
||||
// if the format has the absolutefixedchangecolumn format flag, then always use the fixedchangecolumn from the
|
||||
// format, otherwise, use the default column based on the selected location, stored in the base format.
|
||||
_MyChangeBarColumn = (changeBarData.AbsoluteFixedChangeColumn) ?
|
||||
(int)changeBarData.FixedChangeColumn :
|
||||
System.Convert.ToInt32(changeBarData.DefaultCBLoc.Split(" ".ToCharArray())[System.Convert.ToInt32(_MyChangeBarLoc)]);
|
||||
if (_MyChangeBarText == DocVersionConfig.PrintChangeBarText.UserDef)
|
||||
_MyChangeBarMessage = docverConfig.Print_UserCBMess1 + @"\n" + docverConfig.Print_UserCBMess2;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user