Changed CheckOffs

Made DisplayText more generic
Added comments
- Added parameter to DisplayText
- Removed specific OutlineTable
This commit is contained in:
Rich
2010-05-25 16:12:51 +00:00
parent 8fd6c2eac4
commit 9cc6174ad1
4 changed files with 76 additions and 49 deletions

View File

@@ -121,14 +121,14 @@ namespace Volian.Controls.Library
cbCAS.Checked = sc.Step_CAS; cbCAS.Checked = sc.Step_CAS;
} }
if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0)) //if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0))
{ //{
foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList) // foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList)
{ // {
cmbCheckoff.Items.Add(co.RightCheckOffPrompt); // cmbCheckoff.Items.Add(co.RightCheckOffPrompt);
} // }
if (sc.Step_CheckOffIndex != -1) cmbCheckoff.SelectedIndex = sc.Step_CheckOffIndex; // if (sc.Step_CheckOffIndex != -1) cmbCheckoff.SelectedIndex = sc.Step_CheckOffIndex;
} //}
// change bar setting depends on whether step has changed (dts) as compared to date/time off the // change bar setting depends on whether step has changed (dts) as compared to date/time off the
// procedure that it's in. // procedure that it's in.

View File

@@ -109,32 +109,38 @@ namespace Volian.Controls.Library
/// bool noEdit - flags whether to edit or not (used to set data in /// bool noEdit - flags whether to edit or not (used to set data in
/// rtb as resolved replacewords for non-active rtb. /// rtb as resolved replacewords for non-active rtb.
/// E_FieldToEdit fieldToEdit - identifies the field to edit (number or text) /// E_FieldToEdit fieldToEdit - identifies the field to edit (number or text)
/// bool colorLinks - whether to add color to links
/// </summary> /// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit) public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit, bool colorLinks)
{ {
_FieldToEdit = fieldToEdit; _FieldToEdit = fieldToEdit;
_MyItemInfo = itemInfo; _MyItemInfo = itemInfo;
OriginalText = InfoText; OriginalText = InfoText;
TextFont = itemInfo.GetItemFont();//GetItemFont(); TextFont = itemInfo.GetItemFont();//GetItemFont();
string text = InfoText; string text = InfoText;
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
// actual edit mode are replace words left as is.
_MyFormat = itemInfo.ActiveFormat; _MyFormat = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) text = DoReplaceWords(text);
// adjust formatting of exponents bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
if (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit)) text = DoFortranFormat(text); (_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit;
// save portion of this code for an explanation. bool numbersShouldBeFormated = (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit));
text = text.Replace(@"\~", @"\u160?"); int typ = ((int)itemInfo.MyContent.Type) % 10000;
text = text.Replace("\r\n", @"\par "); bool tableHasBorder = tableShouldBeOutlined ? itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless") < 0 : false;
//if (text.IndexOf(@"\line") > -1)
// MessageBox.Show("Found rtf line");
text = text.Replace(@"\line", @"\par");
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder);
StartText = text;
}
public DisplayText(string text, VE_Font vFont, bool colorLinks)
{
TextFont = vFont;
StartText = CreateRtf(colorLinks, text, false, false, false, false);
}
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder)
{
// add colors around links: // add colors around links:
if (colorLinks)
{
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 "); text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 "); //text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
int indxcf = text.IndexOf("cf1"); int indxcf = text.IndexOf("cf1");
@@ -144,6 +150,30 @@ namespace Volian.Controls.Library
text = text.Insert(indxend, @"\cf0"); text = text.Insert(indxend, @"\cf0");
indxcf = text.IndexOf(@"cf1", indxend); indxcf = text.IndexOf(@"cf1", indxend);
} }
}
// determine whether the table/figure should be outlined:
if (tableShouldBeOutlined)
{
OutlineRTFTable myTable = new OutlineRTFTable(text, tableHasBorder);
myTable.OutlineTable();
text = myTable.Lines.ToString();
}
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
// actual edit mode are replace words left as is.
if (wordsShouldBeReplaced) text = DoReplaceWords(text);
// adjust formatting of exponents
if (numbersShouldBeFormated) text = DoFortranFormat(text);
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
// save portion of this code for an explanation.
text = text.Replace(@"\~", @"\u160?");
text = text.Replace("\r\n", @"\par ");
//if (text.IndexOf(@"\line") > -1)
// MessageBox.Show("Found rtf line");
text = text.Replace(@"\line", @"\par");
// Now put symbol (for fixed fonts) or unicode font (proportional) around symbols // Now put symbol (for fixed fonts) or unicode font (proportional) around symbols
// These fonts are VESymbFix & Arial Unicode MS respectively, and the font table // These fonts are VESymbFix & Arial Unicode MS respectively, and the font table
@@ -167,7 +197,7 @@ namespace Volian.Controls.Library
} }
indxsym = text.IndexOf(@"\u", indxsym + incrindx); indxsym = text.IndexOf(@"\u", indxsym + incrindx);
} }
StartText = text; return text;
} }
private string DoFortranFormat(string text) private string DoFortranFormat(string text)
@@ -195,7 +225,7 @@ namespace Volian.Controls.Library
{ {
try try
{ {
FormatInfo formatInfo = _MyItemInfo.ActiveFormat; //FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
using (_MyItem = _MyItemInfo.Get()) using (_MyItem = _MyItemInfo.Get())
{ {
// check for different text, i.e. text from this itm doesn't match // check for different text, i.e. text from this itm doesn't match
@@ -973,13 +1003,6 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region ReplaceWords #region ReplaceWords
private ReplaceStr _rs;
//private string ReplaceIt(Match m)
//{
// string s = m.ToString();
// string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
// return m.ToString().Replace(_rs.ReplaceWord, _rs.ReplaceWith);
//}
private string DoReplaceWords(string Text) private string DoReplaceWords(string Text)
{ {
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList; ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
@@ -1032,7 +1055,7 @@ namespace Volian.Controls.Library
else else
{ {
// If there are Regex Control Characters '\[]()' prefix them with backslash // If there are Regex Control Characters '\[]()' prefix them with backslash
string replaceWord = Regex.Replace(rs.ReplaceWord, @"\\[[\]()]", @"\$0"); string replaceWord = Regex.Replace(rs.ReplaceWord, @"[[\]\\()]", @"\$0");
string pat = @"(?<=\W|^)" + replaceWord + @"(?=\W|$)"; string pat = @"(?<=\W|^)" + replaceWord + @"(?=\W|$)";
try try
{ {

View File

@@ -195,7 +195,7 @@ namespace Volian.Controls.Library
switch (_MyChildRelation) switch (_MyChildRelation)
{ {
case ChildRelation.None: // Same as after case ChildRelation.None: // Same as after
case ChildRelation.After: case ChildRelation.After: // Procedures, sections, substeps, and tables/figures
// The size depends upon the parent type // The size depends upon the parent type
int iType = (int)_MyParentStepItem._Type; int iType = (int)_MyParentStepItem._Type;
@@ -267,7 +267,7 @@ namespace Volian.Controls.Library
} }
// Same size as the Parent // Same size as the Parent
break; break;
case ChildRelation.Before: case ChildRelation.Before: // Cautions and Notes
//if(_WatchThis > 0 && MyID > 2111) //if(_WatchThis > 0 && MyID > 2111)
// Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentStepItem.MyID, _MyParentStepItem // Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentStepItem.MyID, _MyParentStepItem
// ,_MyParentStepItem.TopMostStepItem.MyID,_MyParentStepItem.TopMostStepItem // ,_MyParentStepItem.TopMostStepItem.MyID,_MyParentStepItem.TopMostStepItem
@@ -1849,7 +1849,8 @@ namespace Volian.Controls.Library
} }
foreach (string line in lines) foreach (string line in lines)
{ {
string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any //string line2 = (addBorder ? "--" : "") + Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands - Really should not be any
//line2 = line2.Replace(@"\u8209?", "-"); //line2 = line2.Replace(@"\u8209?", "-");
//line2 = line2.Replace("<START]", ""); //line2 = line2.Replace("<START]", "");
//line2 = Regex.Replace(line2, @"#Link:.*?\[END>",""); //line2 = Regex.Replace(line2, @"#Link:.*?\[END>","");

View File

@@ -68,7 +68,6 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region Properties and Variables #region Properties and Variables
private static FontFamily _MyFontFamily = null; private static FontFamily _MyFontFamily = null;
public static FontFamily MyFontFamily public static FontFamily MyFontFamily
{ {
@@ -196,7 +195,7 @@ namespace Volian.Controls.Library
} }
_InitializingRTB = true; _InitializingRTB = true;
_SelectedRtfSB.Remove(0, _SelectedRtfSB.Length); _SelectedRtfSB.Remove(0, _SelectedRtfSB.Length);
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit); DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit, true);
//if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText) //if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText)
//{ //{
// ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit); // ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
@@ -243,9 +242,14 @@ namespace Volian.Controls.Library
RemoveEventHandlers(); RemoveEventHandlers();
if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
{ {
int typ = ((int)_MyItemInfo.MyContent.Type) % 10000; int newwidth = (int)_MyStepItem.TableWidth(Font, Text, true);
OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0); if (_MyStepItem.ItemWidth != newwidth)
FindAllLinks(); {
_MyStepItem.ItemWidth = newwidth;
}
// int typ = ((int)_MyItemInfo.MyContent.Type) % 10000;
// OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0);
// FindAllLinks();
} }
SelectAll(); SelectAll();
if (SelectionHangingIndent !=0) SelectionHangingIndent = 0; if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
@@ -425,7 +429,6 @@ namespace Volian.Controls.Library
Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message);
} }
} }
private void SetUpStepRTB() private void SetUpStepRTB()
{ {
C1SpellChecker2.SetActiveSpellChecking(this, true); C1SpellChecker2.SetActiveSpellChecking(this, true);