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:
@@ -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();
|
||||
|
Reference in New Issue
Block a user