Fix possible symbol font discrepancy in tables
Allow options for handling foldout page if first page.
This commit is contained in:
parent
e47df68f83
commit
89965f1278
@ -212,7 +212,7 @@ namespace Volian.Controls.Library
|
|||||||
public static FontFamily MyFontFamily
|
public static FontFamily MyFontFamily
|
||||||
{
|
{
|
||||||
get { return StepRTB._MyFontFamily; }
|
get { return StepRTB._MyFontFamily; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_MyFontFamily = value;
|
_MyFontFamily = value;
|
||||||
if (value != null)
|
if (value != null)
|
||||||
@ -226,12 +226,16 @@ namespace Volian.Controls.Library
|
|||||||
font = new Font(value, 10, FontStyle.Italic);
|
font = new Font(value, 10, FontStyle.Italic);
|
||||||
using (StepRTB srtb = new StepRTB())
|
using (StepRTB srtb = new StepRTB())
|
||||||
{
|
{
|
||||||
if (srtb.FontIsFixed(font)) _MySymbolFontName = "VESymbFix";
|
if (srtb.FontIsFixed(font)) MySymbolFontName = "VESymbFix";
|
||||||
else _MySymbolFontName = "Arial Unicode MS";
|
else MySymbolFontName = "Arial Unicode MS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MySymbolFontName = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// use newer rich text box....
|
// use newer rich text box....
|
||||||
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
//static extern IntPtr LoadLibrary(string lpFileName);
|
//static extern IntPtr LoadLibrary(string lpFileName);
|
||||||
|
@ -796,17 +796,45 @@ namespace Volian.Controls.Library
|
|||||||
private static Regex _ReplaceVESymbFix = new Regex(@"({\\f[0-9]+[^ ]* )(VESymbFix)(;})");
|
private static Regex _ReplaceVESymbFix = new Regex(@"({\\f[0-9]+[^ ]* )(VESymbFix)(;})");
|
||||||
private static Regex _ReplaceArialUnicodeMS = new Regex(@"({\\f[0-9]+[^ ]* )(Arial Unicode MS)(;})");
|
private static Regex _ReplaceArialUnicodeMS = new Regex(@"({\\f[0-9]+[^ ]* )(Arial Unicode MS)(;})");
|
||||||
private static Regex _ReplaceTextFont = new Regex(@"({\\f[0-9]+[^ ]* )(?((?!VESymbFix)(?!Arial Unicode MS))([^;]*)|(!!!!))(;})");
|
private static Regex _ReplaceTextFont = new Regex(@"({\\f[0-9]+[^ ]* )(?((?!VESymbFix)(?!Arial Unicode MS))([^;]*)|(!!!!))(;})");
|
||||||
|
private bool FontIsFixed(Font myFont)
|
||||||
|
{
|
||||||
|
Graphics grph = Graphics.FromHwnd(this.Handle);
|
||||||
|
SizeF sfW = grph.MeasureString("W", myFont);
|
||||||
|
SizeF sfE = grph.MeasureString("!", myFont);
|
||||||
|
if (sfW.Width == sfE.Width) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public void LoadGrid(ItemInfo itemInfo)
|
public void LoadGrid(ItemInfo itemInfo)
|
||||||
{
|
{
|
||||||
_MyItemInfo = itemInfo;
|
_MyItemInfo = itemInfo;
|
||||||
string str = itemInfo.MyContent.MyGrid.Data;
|
string str = itemInfo.MyContent.MyGrid.Data;
|
||||||
VE_Font vefont = _MyItemInfo.GetItemFont();
|
VE_Font vefont = _MyItemInfo.GetItemFont();
|
||||||
FontFamily ff = StepRTB.MyFontFamily ?? vefont.WindowsFont.FontFamily; // TODO: Does not change fixed font.
|
|
||||||
if (StepRTB.MySymbolFontName != "VESymbFix")
|
// the following code is used to be sure that the font used for symbols is the correct font
|
||||||
str = _ReplaceVESymbFix.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
|
// based on whether the font for non-symbol text is fixed or proportional. Each steprtb has
|
||||||
if (StepRTB.MySymbolFontName != "Arial Unicode MS")
|
// a font for the non-symbol AND the symbol text, and these must be the correct association, i.e.
|
||||||
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
|
// for fixed fonts, the symbol font is 'VESymbFix', for proportional fonts, the symbol font is
|
||||||
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
|
// 'Arial Unicode MS'. The underlying flexgrid stores the fonts, and if the table font was
|
||||||
|
// reset for some reason (for example from the drop-down font selection in the user interface),
|
||||||
|
// this code 'cleans' up if there is a mismatch.
|
||||||
|
if (StepRTB.MyFontFamily != null)
|
||||||
|
{
|
||||||
|
FontFamily ff = StepRTB.MyFontFamily;
|
||||||
|
if (StepRTB.MySymbolFontName != "VESymbFix")
|
||||||
|
str = _ReplaceVESymbFix.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
|
||||||
|
if (StepRTB.MySymbolFontName != "Arial Unicode MS")
|
||||||
|
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
|
||||||
|
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FontFamily ff = vefont.WindowsFont.FontFamily;
|
||||||
|
if (FontIsFixed(vefont.WindowsFont))
|
||||||
|
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + "VESymbFix" + "$3");
|
||||||
|
else
|
||||||
|
str = _ReplaceVESymbFix.Replace(str, "$1" + "Arial Unicode MS" + "$3");
|
||||||
|
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
|
||||||
|
}
|
||||||
// To prevent scroll bars from being flashed on/off
|
// To prevent scroll bars from being flashed on/off
|
||||||
// - save an image of the current grid
|
// - save an image of the current grid
|
||||||
// - set Visible to false
|
// - set Visible to false
|
||||||
|
@ -462,7 +462,7 @@ namespace Volian.Print.Library
|
|||||||
PdfReader readerWord = null;
|
PdfReader readerWord = null;
|
||||||
string myPdfFile = null;
|
string myPdfFile = null;
|
||||||
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
||||||
//SectionConfig sc = mySection.MyConfig as SectionConfig;
|
|
||||||
if (mySection.IsAutoTOCSection)
|
if (mySection.IsAutoTOCSection)
|
||||||
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
||||||
else
|
else
|
||||||
@ -471,10 +471,10 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
if (mySection.Steps != null && mySection.Steps.Count > 0)
|
if (mySection.Steps != null && mySection.Steps.Count > 0)
|
||||||
{
|
{
|
||||||
// get first step to send to floading foldout indx.&& MyItemInfo.FoldoutIndex>-1)
|
// get first step to send to floating foldout indx.&& MyItemInfo.FoldoutIndex>-1)
|
||||||
ItemInfo firstStep = mySection.Steps[0];
|
ItemInfo firstStep = mySection.Steps[0];
|
||||||
if (firstStep.FoldoutIndex() > -1)
|
if (firstStep.FoldoutIndex() > -1)
|
||||||
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex());
|
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), InsertBlankPages);
|
||||||
else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages)
|
else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages)
|
||||||
{
|
{
|
||||||
// only insert a blank page if this section does not have a foldout (but the procedure as a whole does)
|
// only insert a blank page if this section does not have a foldout (but the procedure as a whole does)
|
||||||
@ -554,7 +554,7 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
int pageNumber = 1 + ii;
|
int pageNumber = 1 + ii;
|
||||||
if (((mySection.MyDocStyle.StructureStyle.Style ?? 0) & E_DocStructStyle.UseSectionFoldout) != 0)
|
if (((mySection.MyDocStyle.StructureStyle.Style ?? 0) & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||||
DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper, 0);
|
DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper, 0, false);
|
||||||
if (readerWord != null)
|
if (readerWord != null)
|
||||||
{
|
{
|
||||||
bool doimport2 = true;
|
bool doimport2 = true;
|
||||||
@ -876,9 +876,27 @@ namespace Volian.Print.Library
|
|||||||
cb.PdfDocument.NewPage(); // Temporary for foldout/16bit-32bit page alignment
|
cb.PdfDocument.NewPage(); // Temporary for foldout/16bit-32bit page alignment
|
||||||
//_MyLog.InfoFormat("NewPage 7 {0}", cb.PdfWriter.CurrentPageNumber);
|
//_MyLog.InfoFormat("NewPage 7 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||||
}
|
}
|
||||||
public static void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx)
|
public static void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx, bool insertBlankPages)
|
||||||
{
|
{
|
||||||
if (_MyFoldoutSection == null || _MyFoldoutSection.Count==0) return;
|
if (_MyFoldoutSection == null || _MyFoldoutSection.Count==0) return;
|
||||||
|
|
||||||
|
// if the very first page to be output is a 'foldout', treat this as a special case, since
|
||||||
|
// if duplex printing is on, the foldout should always be on the left side, i.e. or behind
|
||||||
|
// the document text. The option PROMS provides is to either:
|
||||||
|
// 1) Skip doing the foldout before the first page, if the 'InsertBlankPages' isn't set, by not checking
|
||||||
|
// the checkbox on the print dialog.
|
||||||
|
// 2) Insert a blank page as the first page, if the 'InsertBlankPages' is set.
|
||||||
|
if (!myPageHelper.PrintedAPage && !insertBlankPages) return;
|
||||||
|
if (!myPageHelper.PrintedAPage)
|
||||||
|
{
|
||||||
|
// only insert a blank page if this is the very first page printed & section has a foldout
|
||||||
|
// and the checkbox on the print dialog to add blank pages is checked. This will put out a blank page as
|
||||||
|
// as the first page so that duplex printing is correct for this condition.
|
||||||
|
myPageHelper.OnBlankPage = true;
|
||||||
|
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||||
|
cb.PdfDocument.NewPage();
|
||||||
|
}
|
||||||
|
|
||||||
SectionInfo saveSect = myPageHelper.MySection;
|
SectionInfo saveSect = myPageHelper.MySection;
|
||||||
myPageHelper.MySection = _MyFoldoutSection[foldoutindx];
|
myPageHelper.MySection = _MyFoldoutSection[foldoutindx];
|
||||||
myPageHelper.OnFoldoutPage = true;
|
myPageHelper.OnFoldoutPage = true;
|
||||||
|
@ -98,6 +98,15 @@ namespace Volian.Print.Library
|
|||||||
get { return _OnBlankPage; }
|
get { return _OnBlankPage; }
|
||||||
set { _OnBlankPage = value; }
|
set { _OnBlankPage = value; }
|
||||||
}
|
}
|
||||||
|
// when false, no page has been printed yet (for determining whether a blank page before print
|
||||||
|
// needs done if first section has foldouts)
|
||||||
|
private bool _PrintedAPage = false;
|
||||||
|
public bool PrintedAPage
|
||||||
|
{
|
||||||
|
get { return _PrintedAPage; }
|
||||||
|
set { _PrintedAPage = value; }
|
||||||
|
}
|
||||||
|
|
||||||
private bool _AddBlankPagesForDuplexPrinting = false;
|
private bool _AddBlankPagesForDuplexPrinting = false;
|
||||||
public bool AddBlankPagesForDuplexPrinting // Tells us if a the option to add a blank page is turn on (for procedures with duplex foldouts)
|
public bool AddBlankPagesForDuplexPrinting // Tells us if a the option to add a blank page is turn on (for procedures with duplex foldouts)
|
||||||
{
|
{
|
||||||
@ -140,7 +149,7 @@ namespace Volian.Print.Library
|
|||||||
PageListTopCheckOffHeader = null;
|
PageListTopCheckOffHeader = null;
|
||||||
PageListLastCheckOffHeader = null;
|
PageListLastCheckOffHeader = null;
|
||||||
YMultiplier = 1;
|
YMultiplier = 1;
|
||||||
|
PrintedAPage = true;
|
||||||
}
|
}
|
||||||
private Gaps _MyGaps;
|
private Gaps _MyGaps;
|
||||||
public Gaps MyGaps
|
public Gaps MyGaps
|
||||||
|
@ -690,7 +690,7 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
// Only do foldout page if not done for section break, i.e. check the there's a previous step.
|
// Only do foldout page if not done for section break, i.e. check the there's a previous step.
|
||||||
if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1)
|
if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1)
|
||||||
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex());
|
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||||
{
|
{
|
||||||
// insert a blank page if this step section had a foldout associated and the checkbox
|
// insert a blank page if this step section had a foldout associated and the checkbox
|
||||||
@ -752,7 +752,7 @@ namespace Volian.Print.Library
|
|||||||
ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
|
ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
|
||||||
DebugText.WriteLine("Paginate2");
|
DebugText.WriteLine("Paginate2");
|
||||||
if (MyItemInfo.MyHLS.FoldoutIndex() > -1)
|
if (MyItemInfo.MyHLS.FoldoutIndex() > -1)
|
||||||
PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex()); // temporary foldout
|
PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout
|
||||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||||
{
|
{
|
||||||
MyPageHelper.OnBlankPage = true;
|
MyPageHelper.OnBlankPage = true;
|
||||||
@ -822,7 +822,7 @@ namespace Volian.Print.Library
|
|||||||
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
|
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
|
||||||
}
|
}
|
||||||
if (MyItemInfo.FoldoutIndex() > -1)
|
if (MyItemInfo.FoldoutIndex() > -1)
|
||||||
PromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex());
|
PromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||||
{
|
{
|
||||||
// insert a blank page if this step section had a foldout associated and the checkbox
|
// insert a blank page if this step section had a foldout associated and the checkbox
|
||||||
|
Loading…
x
Reference in New Issue
Block a user