This commit is contained in:
Kathy Ruffing 2010-09-21 18:35:36 +00:00
parent 8c5aac4885
commit 6634758e73
4 changed files with 50 additions and 149 deletions

View File

@ -119,7 +119,6 @@ namespace Volian.Controls.Library
UpdateAnnotationGrid();
//_AnnotationSearch.UpdateAnnotationSearchResults(); // update the search results
}
}
private void btnSaveAnnotation_Click(object sender, EventArgs e)
@ -244,6 +243,7 @@ namespace Volian.Controls.Library
}
FindCurrentAnnotation(); // position to the grid row of the current annotation
_LoadingGrid = false;
if (_Annotations == null || _Annotations.Count == 0) btnRemoveAnnotation.Enabled = false;
}
/// <summary>

View File

@ -183,8 +183,8 @@ namespace Volian.Controls.Library
if (_SavCurROLink != null)
SavROLink = _SavCurROLink; ;
lbROId.Text = chld.appid;
btnSaveRO.Enabled = ((_SavCurROLink == null) || !(chld.roid.Equals(SavROLink)));
btnCancelRO.Enabled = ((_SavCurROLink != null) && !(chld.roid.Equals(SavROLink)));
btnSaveRO.Enabled = ((_SavCurROLink == null) || !(chld.roid.Substring(0, 12).ToLower().Equals(SavROLink.ROID.Substring(0, 12).ToLower())));
btnCancelRO.Enabled = ((_SavCurROLink != null) && chld.roid.Substring(0, 12).ToLower() != SavROLink.ROID.Substring(0, 12).ToLower());
switch (chld.type)
{
case 1: // standard (regular) text RO type

View File

@ -42,7 +42,19 @@ namespace Volian.Controls.Library
}
_MyRTB = value;
_CurItemInfo = MyRTB.MyItemInfo;
cbChgAll.Checked = !_CurItemInfo.IsHigh;
// only change all at level if all substeps are of same type
bool allSameType = true;
ItemInfo itmp = _CurItemInfo.FirstSibling;
while (itmp != null)
{
if (_CurItemInfo.MyContent.Type != itmp.MyContent.Type)
{
allSameType = false;
break;
}
itmp = itmp.NextItem;
}
cbChgAll.Checked = allSameType;
TagsFillIn();
}
}
@ -244,6 +256,7 @@ namespace Volian.Controls.Library
if (_Initalizing) return;
StepItem topStepItem = _MyRTB.MyStepItem;
FormatData fmtdata = _CurItemInfo.ActiveFormat.PlantFormat.FormatData;
string msgBox = null;
if (cbChgAll.Checked)
{
ItemInfo startitm = _CurItemInfo.FirstSibling;
@ -255,14 +268,18 @@ namespace Volian.Controls.Library
cnt.Save();
startitm = (startitm.NextItemCount > 0 ? startitm.NextItems[0] : null);
}
msgBox = string.Format("All Step Types at this level were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
}
else
{
Content cnt = Content.Get(_CurItemInfo.MyContent.ContentID);
cnt.Type = 20000 + fmtdata.StepDataList[_MyStepTypeInd[listBoxStepTypes.SelectedIndex]].Index;
cnt.Save();
msgBox = string.Format("This Step Type was changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
}
topStepItem.SetAllTabs();
MessageBox.Show(msgBox);
}
private void groupPanelCheckoff_VisibleChanged(object sender, EventArgs e)
{

View File

@ -321,8 +321,7 @@ namespace Volian.Controls.Library
{
string fnum = m.Groups[1].Value;
string supnum = m.Groups[2].Value;
//string newstr = string.Format(@"{0}x10\super {1}\nosupersub ", fnum, supnum);
string newstr = string.Format(@"{0}x10\up3 {1}\up0 ", fnum, supnum);
string newstr = string.Format(@"{0}x10\up2 {1}\up0 ", fnum, supnum);
retstr = retstr.Replace(m.Value, newstr);
}
return retstr;
@ -354,7 +353,6 @@ namespace Volian.Controls.Library
RtfToDisplayTextElements(OriginalText);
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
// now get new text into displaytext elements for comparison for links:
//RtfToDisplayTextElements(rtb.Rtf);
RtfToDisplayTextElements(modtext);
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
// added/deleted or modified.
@ -599,33 +597,32 @@ namespace Volian.Controls.Library
}
private void RtfToDisplayTextElements(string text)
{
// get original text into displaytext elements for comparison for links:
if (DisplayTextElementList == null)
DisplayTextElementList = new List<displayTextElement>();
else
DisplayTextElementList.Clear();
// get original text into displaytext elements for comparison for links:
if (DisplayTextElementList == null)
DisplayTextElementList = new List<displayTextElement>();
else
DisplayTextElementList.Clear();
if (text == null || text == "") return;
if (text == null || text == "") return;
//string noExtraRtfStr = RtfToDbText(text);
string noExtraRtfStr = text;
int startIndex = 0;
int index = -1;
while ((index = FindTokenChar(noExtraRtfStr, startIndex)) > -1)
{
// Do any 'plain' text that preceeds the token.
if (index > startIndex) DoTextElement(noExtraRtfStr, startIndex, index);
string noExtraRtfStr = text;
int startIndex = 0;
int index = -1;
noExtraRtfStr = noExtraRtfStr.Replace(@"><", @">\v0 \v <");
while ((index = FindTokenChar(noExtraRtfStr, startIndex)) > -1)
{
// Do any 'plain' text that preceeds the token.
if (index > startIndex) DoTextElement(noExtraRtfStr, startIndex, index);
if (noExtraRtfStr[index + 1] == 'v')
index = DoLink(noExtraRtfStr, index);
else
index = DoSymbol(noExtraRtfStr, startIndex, index);
startIndex = index; // +1;
if (startIndex >= noExtraRtfStr.Length) break;
}
// Add any remaining text.
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
if (noExtraRtfStr[index + 1] == 'v')
index = DoLink(noExtraRtfStr, index);
else
index = DoSymbol(noExtraRtfStr, startIndex, index);
startIndex = index; // +1;
if (startIndex >= noExtraRtfStr.Length) break;
}
// Add any remaining text.
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
}
private string RtfToDbText(string text)
{
@ -654,112 +651,6 @@ namespace Volian.Controls.Library
return noExtraRtfStr;
}
//private string RemoveRtfStyles(string rtf)
//{
// string retval = rtf;
// // remove rtf commands for any styles that were added. Note that if
// // the entire item has a style, and also contains 'pieces' of text with
// // the same style, the underlying rtf box removes the embedded rtf commands,
// // for example, if the entire step is bolded, and 'THEN' has bold on/off
// // surrounding it, the rtf box removes the bold around the 'THEN'
// // These remove the command with a following space or the command alone,
// // either case may exist, because if there are rtf commands following the
// // style command, there will be no space character following the style command.
// if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0))
// {
// retval = RemoveToken(retval, @"\\b0");
// retval = RemoveToken(retval, @"\\b");
// }
// if ((TextFont.Style & E_Style.Underline) > 0)
// {
// retval = RemoveToken(retval, @"\\ulnone");
// retval = RemoveToken(retval, @"\\ul");
// }
// if ((TextFont.Style & E_Style.Italics) > 0)
// {
// retval = RemoveToken(retval, @"\\i0");
// retval = RemoveToken(retval, @"\\i");
// }
// return retval;
//}
//private string RemoveToken(string str, string token)
//{
// // if this token is preceeded by another token and followed by a space
// // leave the preceeding token the ending space
// string retval = Regex.Replace(str, @"(\\[^ \\?\r\n\t]*)" + token + " ", "$1 ");
// if (retval != str)
// Console.WriteLine("leave the preceeding token the ending space");
// // otherwise replace the token optionally followed by a space
// retval = Regex.Replace(retval, token + " ?", "");
// return retval;
//}
//private static string StaticRemoveToken(string str, string token)
//{
// // if this token is preceeded by another token and followed by a space
// // leave the preceeding token the ending space
// string retval = Regex.Replace(str, @"(\\[^ \\?\r\n\t]*)" + token + " ", "$1 ");
// if (retval != str)
// Console.WriteLine("leave the preceeding token the ending space");
// // otherwise replace the token optionally followed by a space
// retval = Regex.Replace(retval, token + " ?", "");
// return retval;
//}
//public static string ReplaceRTFClause(Match m)
//{
// switch (m.Value[1])
// {
// case 'u':
// if (Regex.IsMatch(m.Value, @"\\u[0-9]+"))
// return m.Value; // Special Charcaters
// if (Regex.IsMatch(m.Value, @"\\ulnone"))
// return m.Value;
// if (Regex.IsMatch(m.Value, @"\\ul.*"))
// return m.Value; // Underline
// break;
// case '\'': // Special Character
// return m.Value;
// case 'b': // Bold
// return m.Value;
// case 's': // sub or super....
// if (m.Value == @"\sub") return m.Value;
// if (m.Value == @"\super") return m.Value;
// break;
// case 'n': // nosubsuper...
// if (m.Value == @"\nosupersub") return m.Value;
// break;
// case 'i': // Italics
// return m.Value;
// case '{': // look for escape for curly braces:
// return m.Value;
// case '}':
// return m.Value;
// case 'v': // save link hidden info
// if (m.Value == @"\v") return m.Value; // comment part of link
// // end comment may end in space or may end in '\' if another rtf command,
// // or may end at end of string. First check for space, keep it in string
// // if it is there.
// if (Regex.IsMatch(m.Value, @"\\v0 "))
// return m.Value;
// if (Regex.IsMatch(m.Value, @"\\v0"))
// return m.Value;
// break;
// case 'l':
// if (m.Value == @"\line") return m.Value;
// break;
// case 'p':
// if (m.Value == @"\par") return "\r\n";
// //if (m.Value == @"\protect")
// // return m.Value;
// //if (m.Value == @"\protect0")
// // return m.Value;
// if (m.Value.Length>=6 && m.Value.Substring(0,6) == "\\par\r\n") return m.Value.Replace("\r\n", " ");
// break;
// case 'f': // handle fonts separately because they may or may not have a space after them
// if (m.Value[2]>='0' && m.Value[2]<='9')return m.Value;
// break;
// }
// return "";//Strip All
//}
public static string StaticReplaceRTFClause(Match m)
{
try
@ -785,13 +676,6 @@ namespace Volian.Controls.Library
return token;
case 'b': // Bold
return token;
//case 's': // sub or super....
// if (Regex.IsMatch(token, @"^\\sub ?$")) return token;
// if (Regex.IsMatch(token, @"^\\super ?$")) return token;
// break;
//case 'n': // nosubsuper...
// if (Regex.IsMatch(token, @"^\\nosupersub ?$")) return token;
// break;
case 'i': // Italics
return token;
case '{': // look for escape for curly braces:
@ -990,7 +874,7 @@ namespace Volian.Controls.Library
// followed by a non-underline or single quote, and if so, return it.
if (((txt[indx + 1] == 'u' && txt[indx + 2] != 'l')) || (txt[indx + 1] == '\'')) return indx;
// see if link
if (txt[indx + 1] == 'v') return indx;
if (txt[indx + 1] == 'v') return indx; //TODO - should have <START here too!
// Otherwise, get next index, must have been a slash or other rtf command.
startIndex = indx + 1;
}
@ -1192,10 +1076,9 @@ namespace Volian.Controls.Library
if (m.Success) return m.Groups[1].ToString()[0];
return '\0';
}
private int DoLinkElements(string text, int index, displayLinkElement vte)
{
// Find the 'end comment' for the <START], can't count characters
// Find the 'end comment' for this <START], can't count characters
// because there may be formatting characters such as \b or \ul before
// the \v0
int linkIndx = text.IndexOf(@"#Link", index);
@ -1209,7 +1092,7 @@ namespace Volian.Controls.Library
// Now get the link part. It can be terminated by a '\v0' or an [END>
int endLinkIndxV = text.IndexOf(@"\v0 ", linkIndx);
if (endLinkIndxV == -1) endLinkIndxV = text.IndexOf(@"\v0", linkIndx); // at end of string
int endLinkIndxE = text.IndexOf(@"[END>", linkIndx);
int endLinkIndxE = text.IndexOf(@"[END>", linkIndx);
int endLinkIndx = (endLinkIndxV < endLinkIndxE) ? endLinkIndxV : endLinkIndxE;
vte.Link = text.Substring(linkIndx + 6, endLinkIndx - linkIndx - 6); // 6 for #Link:
@ -1228,7 +1111,7 @@ namespace Volian.Controls.Library
// Now get the entire text & link. Account for various ending possibilities:
// ends with '\v0\'; ends with '\v0 '; ends with '\v0' (end of string);
// ends with '[END>' if two in a row - will have <START]
int endToken = (endLinkIndx == endLinkIndxE)?endLinkIndx+3:text.IndexOf(@"[END>", endLinkIndx + 3); // get past end of link
int endToken = (endLinkIndx == endLinkIndxE) ? endLinkIndx + 3 : text.IndexOf(@"[END>", endLinkIndx + 3); // get past end of link
int endComment = text.IndexOf(@"\v0", endToken);
int rettoken = 0;
@ -1248,6 +1131,7 @@ namespace Volian.Controls.Library
DisplayTextElementList.Add(vte);
return rettoken;
}
private int DoSymbol(string text, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();