Added a FormattedDisplayText for use on Calvert’s Placekeepers
Will now handle Bold, Underline, and Super/Sub Script
This commit is contained in:
parent
29f3db8605
commit
b27b0ad8bd
@ -1813,6 +1813,19 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return (this.IsProcedure || parent.IsApplicable(apple)) && (cfg.MasterSlave_Applicability.GetFlags().Count == 0 || cfg.MasterSlave_Applicability.GetFlags().Contains(apple));
|
return (this.IsProcedure || parent.IsApplicable(apple)) && (cfg.MasterSlave_Applicability.GetFlags().Count == 0 || cfg.MasterSlave_Applicability.GetFlags().Contains(apple));
|
||||||
}
|
}
|
||||||
//end jcb added inherited applicability
|
//end jcb added inherited applicability
|
||||||
|
public string FormattedDisplayText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string str = MyContent.Text;
|
||||||
|
str = Regex.Replace(str, @"\<[uU]\>", MyDocVersion.DocVersionConfig.Unit_Number);
|
||||||
|
//if (str.Contains("<u>"))
|
||||||
|
// str = str.Replace("<u>", MyDocVersion.DocVersionConfig.Unit_Number);
|
||||||
|
//if (str.Contains("<U>"))
|
||||||
|
// str = str.Replace("<U>", MyDocVersion.DocVersionConfig.Unit_Number);
|
||||||
|
return ConvertToDisplayText(str,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
public string DisplayText
|
public string DisplayText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -1845,9 +1858,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//get { return ConvertToDisplayText(MyContent.Number); }
|
//get { return ConvertToDisplayText(MyContent.Number); }
|
||||||
}
|
}
|
||||||
public static string ConvertToDisplayText(string txt)
|
public static string ConvertToDisplayText(string txt)
|
||||||
|
{
|
||||||
|
return ConvertToDisplayText(txt, true);
|
||||||
|
}
|
||||||
|
public static string ConvertToDisplayText(string txt, bool stripRTF)
|
||||||
{
|
{
|
||||||
string retval = txt;
|
string retval = txt;
|
||||||
retval = StripRtfFormatting(retval);
|
if (stripRTF) retval = StripRtfFormatting(retval);
|
||||||
retval = StripLinks(retval);
|
retval = StripLinks(retval);
|
||||||
retval = ReplaceSpecialCharacters(retval);
|
retval = ReplaceSpecialCharacters(retval);
|
||||||
retval = retval.Replace("\u2011", "-");
|
retval = retval.Replace("\u2011", "-");
|
||||||
|
@ -4,6 +4,7 @@ using System.Text;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using LBWordLibrary;
|
using LBWordLibrary;
|
||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Volian.Print.Library
|
namespace Volian.Print.Library
|
||||||
{
|
{
|
||||||
@ -59,7 +60,7 @@ namespace Volian.Print.Library
|
|||||||
foreach (pkParagraph myPlacekeeper in myPlacekeepers)
|
foreach (pkParagraph myPlacekeeper in myPlacekeepers)
|
||||||
{
|
{
|
||||||
if(myPlacekeepers.Count > 1)
|
if(myPlacekeepers.Count > 1)
|
||||||
AddSectionHeader(myPlacekeeper.MyParagraph.MyItemInfo.DisplayNumber, myPlacekeeper.MyParagraph.MyItemInfo.DisplayText);
|
AddSectionHeader(myPlacekeeper.MyParagraph.MyItemInfo.DisplayNumber, myPlacekeeper.MyParagraph.MyItemInfo.FormattedDisplayText);
|
||||||
foreach (pkParagraph pgh in myPlacekeeper.MyChildren)
|
foreach (pkParagraph pgh in myPlacekeeper.MyChildren)
|
||||||
{
|
{
|
||||||
foreach (pkParagraph pghC in pgh.MyCautionsAndNotes)
|
foreach (pkParagraph pghC in pgh.MyCautionsAndNotes)
|
||||||
@ -68,9 +69,9 @@ namespace Volian.Print.Library
|
|||||||
string doneStr = (sc.Step_Placekeeper.ToUpper() == "C")? "C":"";
|
string doneStr = (sc.Step_Placekeeper.ToUpper() == "C")? "C":"";
|
||||||
string NoteCautionTab = "NOTE: ";
|
string NoteCautionTab = "NOTE: ";
|
||||||
if (pghC.MyParagraph.MyItemInfo.IsCaution) NoteCautionTab = "CAUTION: ";
|
if (pghC.MyParagraph.MyItemInfo.IsCaution) NoteCautionTab = "CAUTION: ";
|
||||||
AddCautionOrNote(NoteCautionTab, pghC.MyParagraph.MyItemInfo.DisplayText, doneStr, (pghC.MyParagraph.MyItemInfo.PageNumber+1).ToString());
|
AddCautionOrNote(NoteCautionTab, pghC.MyParagraph.MyItemInfo.FormattedDisplayText, doneStr, (pghC.MyParagraph.MyItemInfo.PageNumber+1).ToString());
|
||||||
}
|
}
|
||||||
AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.DisplayText, pgh.MyParagraph.MyItemInfo.FormatStepType == 9 ? "C" : "", (pgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
|
AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.FormattedDisplayText, pgh.MyParagraph.MyItemInfo.FormatStepType == 9 ? "C" : "", (pgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
|
||||||
if (pgh.MyChildren.Count > 0)
|
if (pgh.MyChildren.Count > 0)
|
||||||
{
|
{
|
||||||
bool conAct = false;
|
bool conAct = false;
|
||||||
@ -92,7 +93,7 @@ namespace Volian.Print.Library
|
|||||||
AddNotesOrCautions(cpgh,level, ref conAct);
|
AddNotesOrCautions(cpgh,level, ref conAct);
|
||||||
if (!conAct)
|
if (!conAct)
|
||||||
conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
|
conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
|
||||||
ContinueSubStep(cpgh.MyParagraph.MyItemInfo.DisplayText, level);
|
ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level);
|
||||||
AddChildren(cpgh, level+1, ref conAct);
|
AddChildren(cpgh, level+1, ref conAct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ namespace Volian.Print.Library
|
|||||||
if (!_FirstLine) _WordSel.TypeParagraph();
|
if (!_FirstLine) _WordSel.TypeParagraph();
|
||||||
_FirstLine = false;
|
_FirstLine = false;
|
||||||
SetIndent(.33F + (.31F * level), -.31F);
|
SetIndent(.33F + (.31F * level), -.31F);
|
||||||
WriteCell(NoteCautionTab + ii.DisplayText, false, false);
|
WriteCell(NoteCautionTab + ii.FormattedDisplayText, false, false);
|
||||||
}
|
}
|
||||||
public void BuildSample()
|
public void BuildSample()
|
||||||
{
|
{
|
||||||
@ -306,11 +307,55 @@ 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)( |$|(?=\\))");
|
||||||
|
private void WriteRTF(string text)
|
||||||
|
{
|
||||||
|
if (text.Contains("\\"))
|
||||||
|
Console.WriteLine("here");
|
||||||
|
Match m = rgx.Match(text);
|
||||||
|
while (m.Success)
|
||||||
|
{
|
||||||
|
if (m.Index > 0)
|
||||||
|
_WordSel.TypeText(text.Substring(0,m.Index));
|
||||||
|
switch (m.Groups[1].Value)
|
||||||
|
{
|
||||||
|
case "b": // bold on
|
||||||
|
_WordSel.Font.Bold = 1;
|
||||||
|
break;
|
||||||
|
case "b0": // bold off
|
||||||
|
_WordSel.Font.Bold = 0;
|
||||||
|
break;
|
||||||
|
case "ul": // underline on
|
||||||
|
_WordSel.Font.Underline = LBWdUnderline.wdUnderlineSingle;
|
||||||
|
break;
|
||||||
|
case "ulnone": // underline off
|
||||||
|
_WordSel.Font.Underline = LBWdUnderline.wdUnderlineNone;
|
||||||
|
break;
|
||||||
|
case "dn0": // superscript off
|
||||||
|
_WordSel.Font.Superscript = 0;
|
||||||
|
break;
|
||||||
|
case "up0": // subscript off
|
||||||
|
_WordSel.Font.Subscript = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (m.Groups[1].Value.StartsWith("dn"))// subscript on
|
||||||
|
_WordSel.Font.Subscript = 1;
|
||||||
|
else // superscript on
|
||||||
|
_WordSel.Font.Superscript = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
text = text.Substring(m.Index+m.Length);
|
||||||
|
m = rgx.Match(text);
|
||||||
|
}
|
||||||
|
_WordSel.TypeText(text);
|
||||||
|
}
|
||||||
private void WriteCell(string text, bool bold, bool advance)
|
private void WriteCell(string text, bool bold, bool advance)
|
||||||
{
|
{
|
||||||
_WordSel.Font.Name = _pkFont.Family;//"Arial";
|
_WordSel.Font.Name = _pkFont.Family;//"Arial";
|
||||||
_WordSel.Font.Bold = bold ? 1 : 0;
|
_WordSel.Font.Bold = bold ? 1 : 0;
|
||||||
_WordSel.TypeText(text);
|
//_WordSel.TypeText(text);
|
||||||
|
WriteRTF(text);
|
||||||
if (advance) Advance();
|
if (advance) Advance();
|
||||||
}
|
}
|
||||||
private void SetIndent(float left, float first)
|
private void SetIndent(float left, float first)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user