Don’t try to initialize the signoff drop-down if there are no sighoffs
Added logic to support Prerequisite step information and to handle the indent character Logic to pass font information to the Placekeeper logic
This commit is contained in:
parent
78384ce643
commit
76cec2c961
@ -208,7 +208,7 @@ namespace Volian.Controls.Library
|
||||
fmtdata.ProcData.CheckOffData.Menu == "Signoff")
|
||||
{
|
||||
SectionConfig secf = CurItemInfo.ActiveSection.MyConfig as SectionConfig;
|
||||
if (secf.Section_CheckoffListSelection > 0) cmbCheckoff.SelectedIndex = secf.Section_CheckoffListSelection - ((fmtdata.ProcData.CheckOffData.Menu == "Signoff") ? 0 : 1);
|
||||
if (secf.Section_CheckoffListSelection > 0 && cmbCheckoff.Items.Count > 0) cmbCheckoff.SelectedIndex = secf.Section_CheckoffListSelection - ((fmtdata.ProcData.CheckOffData.Menu == "Signoff") ? 0 : 1);
|
||||
cmbCheckoff.Enabled = false;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using LBWordLibrary;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
@ -13,11 +14,13 @@ namespace Volian.Print.Library
|
||||
private LBSelection _WordSel;
|
||||
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 VE_Font _pkFont;
|
||||
public Placekeeper()
|
||||
{
|
||||
_WordApp = new LBApplicationClass();
|
||||
_WordDoc = _WordApp.Documents.Add();
|
||||
_WordSel = _WordApp.Selection;
|
||||
_pkFont = new VE_Font("Arial", 11, E_Style.None, 12); // Calvert uses Arial for their Placekeepers.
|
||||
}
|
||||
//public Placekeeper(pkParagraph myPlacekeeper)
|
||||
//{
|
||||
@ -44,12 +47,13 @@ namespace Volian.Print.Library
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public Placekeeper(pkParagraphs myPlacekeepers)
|
||||
public Placekeeper(pkParagraphs myPlacekeepers, VE_Font pkFont)
|
||||
{
|
||||
_WordApp = new LBApplicationClass();
|
||||
_WordDoc = _WordApp.Documents.Add();
|
||||
_WordSel = _WordApp.Selection;
|
||||
_WordApp.Visible = true;
|
||||
_pkFont = pkFont;
|
||||
AddTable();
|
||||
AddHeader();
|
||||
foreach (pkParagraph myPlacekeeper in myPlacekeepers)
|
||||
@ -168,13 +172,15 @@ namespace Volian.Print.Library
|
||||
LBColumn col = _WordTbl.Columns.First;
|
||||
//col.SetWidth(12F, LBWdRulerStyle.wdAdjustNone);
|
||||
//col = col.Next;
|
||||
col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
|
||||
col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone);
|
||||
col = col.Next;
|
||||
col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone);
|
||||
col = col.Next;
|
||||
col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
|
||||
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
|
||||
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
|
||||
col = col.Next;
|
||||
col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
|
||||
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
|
||||
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
|
||||
_WordTbl.Rows.AllowBreakAcrossPages = 0;
|
||||
}
|
||||
private void AddHeader()
|
||||
@ -202,11 +208,55 @@ namespace Volian.Print.Library
|
||||
WriteCell(" " + title, false, true);
|
||||
Advance();
|
||||
}
|
||||
private float GetTextWidth(string txt)
|
||||
{
|
||||
System.Drawing.Font font = new System.Drawing.Font(_pkFont.Family, (float)_pkFont.Size);
|
||||
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
|
||||
float w = 0;
|
||||
foreach (char c in txt)
|
||||
{
|
||||
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;
|
||||
}
|
||||
private void AddHighLevelStep(string number, string text, string done, string page)
|
||||
{
|
||||
Advance(2);
|
||||
SetIndent(.33F, -.33F);
|
||||
WriteCell(number + "\t" + text, false, true);
|
||||
// if the text contains prerequisite steps,
|
||||
// parse out the step numbers and place them in the first column
|
||||
if (text.Contains(@"\{Prerequisite Step: "))
|
||||
{
|
||||
string prereqToken = @"\{Prerequisite Step: ";
|
||||
string preqStp = "";
|
||||
int idx = text.IndexOf(prereqToken);
|
||||
while (idx >= 0)
|
||||
{
|
||||
int parseStart = idx+prereqToken.Length;
|
||||
int endx = text.IndexOf(@"\}",parseStart);
|
||||
int parseLen = endx - parseStart;
|
||||
preqStp += "("+text.Substring(parseStart, parseLen) + "), ";
|
||||
text = text.Remove(idx, endx+2 - idx);
|
||||
idx = text.IndexOf(prereqToken);
|
||||
}
|
||||
Advance(1);
|
||||
preqStp = preqStp.Substring(0, preqStp.Length - 2); // remove ending ", "
|
||||
WriteCell(preqStp, false, true);
|
||||
}
|
||||
else
|
||||
Advance(2);
|
||||
if (text.Contains("\x05")) // hanging indent character
|
||||
{
|
||||
string[] parts = text.Split("\x05".ToCharArray());
|
||||
float ind = (GetTextWidth(number) + GetTextWidth(parts[0])) / 72f;
|
||||
SetIndent(ind, -ind);
|
||||
WriteCell(number + parts[0] + parts[1], false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetIndent(.33F, -.33F);
|
||||
WriteCell(number + text, false, true);
|
||||
}
|
||||
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
|
||||
WriteCell(done, false, true);
|
||||
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
|
||||
@ -258,7 +308,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private void WriteCell(string text, bool bold, bool advance)
|
||||
{
|
||||
_WordSel.Font.Name = "Arial";
|
||||
_WordSel.Font.Name = _pkFont.Family;//"Arial";
|
||||
_WordSel.Font.Bold = bold ? 1 : 0;
|
||||
_WordSel.TypeText(text);
|
||||
if (advance) Advance();
|
||||
|
@ -589,8 +589,18 @@ namespace Volian.Print.Library
|
||||
CloseDocument(cb, outputFileName);
|
||||
if (_MyHelper != null && makePlacekeeper)
|
||||
{
|
||||
// Setting the default font to Arial since that is what Calvert is currently using for their Placekeeper pages
|
||||
VE_Font pkFont = new VE_Font("Arial",11,E_Style.None,12); // default font info.
|
||||
// Ideally, we should grab the font from the DocStyle used for the Placekeeper.
|
||||
// Note that Calvert has two Placekeeper docSyles (EOPs and AOPs) in the same format.
|
||||
// Both Placekeeper DocStyles use Arial 11 pt font, so there is no need to grab it from the format file.
|
||||
//foreach (DocStyle ds in _MyHelper.MySection.ActiveFormat.PlantFormat.DocStyles.DocStyleList)
|
||||
//{ // note that this will get the last Placekeeper font setting
|
||||
// if (ds.StructureStyle.Style == E_DocStructStyle.Placekeeper)
|
||||
// pkFont = ds.Font;
|
||||
//}
|
||||
if (_MyHelper.MyPlacekeepers.Count > 0)
|
||||
new Placekeeper(_MyHelper.MyPlacekeepers);
|
||||
new Placekeeper(_MyHelper.MyPlacekeepers, pkFont);
|
||||
}
|
||||
_MyHelper = null;
|
||||
return outputFileName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user