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;
}
if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0))
{
foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList)
{
cmbCheckoff.Items.Add(co.RightCheckOffPrompt);
}
if (sc.Step_CheckOffIndex != -1) cmbCheckoff.SelectedIndex = sc.Step_CheckOffIndex;
}
//if (!(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0))
//{
// foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList)
// {
// cmbCheckoff.Items.Add(co.RightCheckOffPrompt);
// }
// 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
// procedure that it's in.

View File

@ -109,22 +109,63 @@ namespace Volian.Controls.Library
/// bool noEdit - flags whether to edit or not (used to set data in
/// rtb as resolved replacewords for non-active rtb.
/// E_FieldToEdit fieldToEdit - identifies the field to edit (number or text)
/// bool colorLinks - whether to add color to links
/// </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;
_MyItemInfo = itemInfo;
OriginalText = InfoText;
TextFont = itemInfo.GetItemFont();//GetItemFont();
string text = InfoText;
_MyFormat = itemInfo.ActiveFormat;
bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit;
bool numbersShouldBeFormated = (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit));
int typ = ((int)itemInfo.MyContent.Type) % 10000;
bool tableHasBorder = tableShouldBeOutlined ? itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless") < 0 : false;
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:
if (colorLinks)
{
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
int indxcf = text.IndexOf("cf1");
while (indxcf != -1)
{
int indxend = text.IndexOf(@"\v", indxcf);
text = text.Insert(indxend, @"\cf0");
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.
_MyFormat = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) text = DoReplaceWords(text);
if (wordsShouldBeReplaced) text = DoReplaceWords(text);
// adjust formatting of exponents
if (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit)) text = DoFortranFormat(text);
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.
@ -134,17 +175,6 @@ namespace Volian.Controls.Library
// MessageBox.Show("Found rtf line");
text = text.Replace(@"\line", @"\par");
// add colors around links:
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
int indxcf = text.IndexOf("cf1");
while (indxcf != -1)
{
int indxend = text.IndexOf(@"\v", indxcf);
text = text.Insert(indxend, @"\cf0 ");
indxcf = text.IndexOf(@"cf1", indxend);
}
// Now put symbol (for fixed fonts) or unicode font (proportional) around symbols
// These fonts are VESymbFix & Arial Unicode MS respectively, and the font table
// is actually defined in the StepRTB code.
@ -155,19 +185,19 @@ namespace Volian.Controls.Library
if (text[indxsym + 2] != 'l')
{
text = text.Insert(indxsym, @"\f1 ");
int indxendsym = text.IndexOfAny(@"\ ?".ToCharArray(),indxsym+5);
int indxendsym = text.IndexOfAny(@"\ ?".ToCharArray(), indxsym + 5);
if (indxendsym == -1) // must be end of line:
text = text.Insert(text.Length-1,@"\f0 ");
text = text.Insert(text.Length - 1, @"\f0 ");
else
{
if (text[indxendsym]=='?') indxendsym++;
if (text[indxendsym] == '?') indxendsym++;
text = text.Insert(indxendsym, @"\f0 "); // TODO: do I need a space??
}
incrindx = 5;
}
indxsym = text.IndexOf(@"\u",indxsym + incrindx);
indxsym = text.IndexOf(@"\u", indxsym + incrindx);
}
StartText = text;
return text;
}
private string DoFortranFormat(string text)
@ -195,7 +225,7 @@ namespace Volian.Controls.Library
{
try
{
FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
//FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
using (_MyItem = _MyItemInfo.Get())
{
// check for different text, i.e. text from this itm doesn't match
@ -973,13 +1003,6 @@ namespace Volian.Controls.Library
}
#endregion
#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)
{
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
@ -1032,7 +1055,7 @@ namespace Volian.Controls.Library
else
{
// 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|$)";
try
{

View File

@ -195,7 +195,7 @@ namespace Volian.Controls.Library
switch (_MyChildRelation)
{
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
int iType = (int)_MyParentStepItem._Type;
@ -267,7 +267,7 @@ namespace Volian.Controls.Library
}
// Same size as the Parent
break;
case ChildRelation.Before:
case ChildRelation.Before: // Cautions and Notes
//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
// ,_MyParentStepItem.TopMostStepItem.MyID,_MyParentStepItem.TopMostStepItem
@ -1849,7 +1849,8 @@ namespace Volian.Controls.Library
}
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("<START]", "");
//line2 = Regex.Replace(line2, @"#Link:.*?\[END>","");

View File

@ -68,7 +68,6 @@ namespace Volian.Controls.Library
}
#endregion
#region Properties and Variables
private static FontFamily _MyFontFamily = null;
public static FontFamily MyFontFamily
{
@ -196,7 +195,7 @@ namespace Volian.Controls.Library
}
_InitializingRTB = true;
_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)
//{
// ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
@ -243,9 +242,14 @@ namespace Volian.Controls.Library
RemoveEventHandlers();
if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
{
int typ = ((int)_MyItemInfo.MyContent.Type) % 10000;
OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0);
FindAllLinks();
int newwidth = (int)_MyStepItem.TableWidth(Font, Text, true);
if (_MyStepItem.ItemWidth != newwidth)
{
_MyStepItem.ItemWidth = newwidth;
}
// int typ = ((int)_MyItemInfo.MyContent.Type) % 10000;
// OutlineTable(_MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless")<0);
// FindAllLinks();
}
SelectAll();
if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
@ -396,7 +400,7 @@ namespace Volian.Controls.Library
this.KeyUp += new KeyEventHandler(StepRTB_KeyUp);
this.TextChanged += new EventHandler(StepRTB_TextChanged);
this.MouseUp += new MouseEventHandler(StepRTB_MouseUp);
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
this.MouseLeave += new EventHandler(StepRTB_MouseLeave);
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged);
@ -425,7 +429,6 @@ namespace Volian.Controls.Library
Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message);
}
}
private void SetUpStepRTB()
{
C1SpellChecker2.SetActiveSpellChecking(this, true);
@ -472,7 +475,7 @@ namespace Volian.Controls.Library
_MouseDown = false;
//Console.WriteLine("^^^^^^^^^^ StepRTB Mouse Up id= {0}", MyItemInfo.ItemID);
if (this.Focused) // Only HandleSelectionChange if this control has focus.
if(this.Focused) // Only HandleSelectionChange if this control has focus.
{
HandleSelectionChange();
// save our context menu to add to the spell checker's context menu