Added a Command Line parameter (/NoChgID) which will allow the user to skip entering a ChgID.
Added Profile debug Improved Performance for ReplaceWords A wait cursor was set when a right-mouse click occurs on a treeview. This gives instant feedback that something is happening.
This commit is contained in:
parent
6a973a288b
commit
d501a39a7b
@ -874,8 +874,11 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void PromptForChangeId(ItemInfo myItemInfo, DisplayTabItem pg)
|
||||
{
|
||||
dlgChgId dlgCI = new dlgChgId(this); //, null);
|
||||
dlgCI.ShowDialog(this);
|
||||
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOCHGID"))
|
||||
{
|
||||
dlgChgId dlgCI = new dlgChgId(this); //, null);
|
||||
dlgCI.ShowDialog(this);
|
||||
}
|
||||
ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId);
|
||||
SetChangeId(ChgId, pg, myItemInfo);
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit, bool colorLinks, string prefix, string suffix)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> DisplayText");
|
||||
_FieldToEdit = fieldToEdit;
|
||||
_MyItemInfo = itemInfo;
|
||||
OriginalText = InfoText;
|
||||
@ -166,8 +167,9 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted, underlineAfterDashSpace);
|
||||
|
||||
|
||||
StartText = text;
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
private string ReplaceLinesWithUnicode(string text)
|
||||
{
|
||||
@ -226,6 +228,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder, bool ROsShouldBeAdjusted, bool underlineAfterDashSpace)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> CreateRtf");
|
||||
// Adjust RO display
|
||||
if (ROsShouldBeAdjusted)
|
||||
{
|
||||
@ -248,8 +251,12 @@ namespace Volian.Controls.Library
|
||||
// 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.
|
||||
// But don't do ReplaceWords if the TurnOffReplaceWords format flag is set
|
||||
if (wordsShouldBeReplaced && !_MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.TurnOffReplaceWords)
|
||||
if (wordsShouldBeReplaced && !_MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.TurnOffReplaceWords)
|
||||
{
|
||||
int profileDepth1 = ProfileTimer.Push(">>>> DoReplaceWords2");
|
||||
text = DoReplaceWords2(text);
|
||||
ProfileTimer.Pop(profileDepth1);
|
||||
}
|
||||
if (_MyItemInfo != null)
|
||||
{
|
||||
text = Regex.Replace(text, @"\<U\>", _MyItemInfo.MyDocVersion.DocVersionConfig.Unit_Number, RegexOptions.IgnoreCase);
|
||||
@ -344,7 +351,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
text = FixDiffUnitROReplaceWords(text);
|
||||
text = FixDiffUnitROReplaceWords(text);
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return text;
|
||||
}
|
||||
|
||||
@ -576,11 +584,16 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private string DoTransitionAdjustments(string text, bool boldTran)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> DoTransitionAdjustments");
|
||||
bool undtran = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.Underline;
|
||||
string strippedText = StaticStripRtfCommands(text);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v'?{{}}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):[0-9]* ([0-9]*).*?\[END>");
|
||||
MatchCollection matches = Regex.Matches(text, lookFor);
|
||||
if (matches.Count == 0) return text;
|
||||
if (matches.Count == 0)
|
||||
{
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return text;
|
||||
}
|
||||
string retstr = text;
|
||||
for (int i = matches.Count - 1; i >= 0; i--)
|
||||
{
|
||||
@ -633,6 +646,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return retstr.Replace("\x1", @"\u160?");
|
||||
}
|
||||
|
||||
@ -1705,7 +1719,7 @@ namespace Volian.Controls.Library
|
||||
// return Text;
|
||||
//}
|
||||
#endregion
|
||||
private Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
|
||||
private static Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
|
||||
private static bool? _ProcessReplaceWords;
|
||||
public static bool ProcessReplaceWords
|
||||
{
|
||||
@ -1737,45 +1751,52 @@ namespace Volian.Controls.Library
|
||||
// ReplaceStrData xml node is empty, it does the inheritance and gets the 'base' format's list.
|
||||
if (rsl.Count==1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text;
|
||||
// Loop through text looking for words to be replaced
|
||||
List<ReplaceStr> partialReplaceList = new List<ReplaceStr>();
|
||||
Dictionary<ReplaceStr, Regex> partialReplaceList = new Dictionary<ReplaceStr, Regex>();
|
||||
Dictionary<E_ReplaceFlags?, bool> shouldReplace = new Dictionary<E_ReplaceFlags?, bool>();
|
||||
//int profileDepth = ProfileTimer.Push(">>>> DoReplaceWords2.ForLoop");
|
||||
foreach (ReplaceStr rs in rsl)
|
||||
{
|
||||
bool dopartial = false;
|
||||
bool replaceit = false;
|
||||
bool dopartial = (rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials;
|
||||
// note that the order of this check is important. Check in this order...
|
||||
// background here
|
||||
if (_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High) > 0) replaceit = true;
|
||||
else if ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsStepPart && !_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
||||
//else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
|
||||
if (!shouldReplace.ContainsKey(rs.Flag))
|
||||
{
|
||||
//int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt");
|
||||
shouldReplace.Add(rs.Flag, ShouldReplaceIt(rs.Flag));
|
||||
//ProfileTimer.Pop(profileDepth2);
|
||||
}
|
||||
bool replaceit = shouldReplace[rs.Flag];
|
||||
|
||||
if (replaceit)
|
||||
{
|
||||
if (!dicReplaceRegex.ContainsKey(rs))
|
||||
{
|
||||
if ((rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials)
|
||||
RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
|
||||
if (dopartial)
|
||||
{
|
||||
partialReplaceList.Add(rs);
|
||||
dopartial = true;
|
||||
dicReplaceRegex.Add(rs, new Regex(rs.ReplaceWord, myOptions));
|
||||
}
|
||||
else
|
||||
{
|
||||
//int profileDepth3 = ProfileTimer.Push(">>>> DoReplaceWords2.BuildMatch");
|
||||
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace with the ReplaceWith string as is
|
||||
//RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase & RegexOptions.Singleline : RegexOptions.None & RegexOptions.Singleline;
|
||||
string replaceWord = Regex.Replace(rs.ReplaceWord, @"[[\]\\()]", @"\$0");
|
||||
// if first or last character in replaceword is a non-word character, for example, ',', ')', or '.',
|
||||
// don't use the \W, i.e. don't bother to look for a non-word character.
|
||||
string wordMatchBeg = Regex.IsMatch(replaceWord.Substring(0, 1), @"\W") ? "" : @"(?<=\W|^)";
|
||||
string wordMatchEnd = Regex.IsMatch(replaceWord.Substring(replaceWord.Length - 1, 1), @"\W") ? "" : @"(?=\W|$)";
|
||||
string pat = wordMatchBeg + @"(?<!\\u160\?|\\u8209\?)" + replaceWord + @"(?!\\u160\?|\\u8209\?)" + wordMatchEnd;
|
||||
dicReplaceRegex.Add(rs, new Regex(pat, myOptions));
|
||||
//ProfileTimer.Pop(profileDepth3);
|
||||
}
|
||||
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace with the ReplaceWith string as is
|
||||
//RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase & RegexOptions.Singleline : RegexOptions.None & RegexOptions.Singleline;
|
||||
RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase: RegexOptions.None;
|
||||
string replaceWord = Regex.Replace(rs.ReplaceWord, @"[[\]\\()]", @"\$0");
|
||||
// if first or last character in replaceword is a non-word character, for example, ',', ')', or '.',
|
||||
// don't use the \W, i.e. don't bother to look for a non-word character.
|
||||
string wordMatchBeg = Regex.IsMatch(replaceWord.Substring(0, 1), @"\W") ? "" : @"(?<=\W|^)";
|
||||
string wordMatchEnd = Regex.IsMatch(replaceWord.Substring(replaceWord.Length - 1, 1), @"\W") ? "" : @"(?=\W|$)";
|
||||
string pat = wordMatchBeg + @"(?<!\\u160\?|\\u8209\?)" + replaceWord + @"(?!\\u160\?|\\u8209\?)" + wordMatchEnd;
|
||||
if (!dopartial) dicReplaceRegex.Add(rs, new Regex(pat, myOptions));
|
||||
}
|
||||
try
|
||||
{
|
||||
//int profileDepth4 = ProfileTimer.Push(">>>> DoReplaceWords2.Partial");
|
||||
if (!dopartial) myMatches.Add(dicReplaceRegex[rs], rs);
|
||||
else partialReplaceList.Add(rs, dicReplaceRegex[rs]);
|
||||
//ProfileTimer.Pop(profileDepth4);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1784,12 +1805,15 @@ namespace Volian.Controls.Library
|
||||
dopartial = false;
|
||||
}
|
||||
}
|
||||
//ProfileTimer.Pop(profileDepth);
|
||||
//int profileDepth5 = ProfileTimer.Push(">>>> DoReplaceWords2.ReplaceMatches");
|
||||
Text = myMatches.ReplaceMatches();
|
||||
//ProfileTimer.Pop(profileDepth5);
|
||||
Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space
|
||||
try
|
||||
{
|
||||
foreach (ReplaceStr prs in partialReplaceList)
|
||||
Text = Regex.Replace(Text, prs.ReplaceWord, prs.ReplaceWith);
|
||||
foreach (ReplaceStr prs in partialReplaceList.Keys)
|
||||
Text = partialReplaceList[prs].Replace(Text, prs.ReplaceWith);
|
||||
}
|
||||
catch (Exception ex) // Don't crash on a format issue.
|
||||
{
|
||||
@ -1797,6 +1821,40 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return Text;
|
||||
}
|
||||
private bool ShouldReplaceIt(E_ReplaceFlags? myFlag)
|
||||
{
|
||||
bool replaceit= false;
|
||||
if (_MyItemInfo.IsHigh && (myFlag & E_ReplaceFlags.High) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
else if ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (myFlag & E_ReplaceFlags.Table) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
else if (_MyItemInfo.IsInRNO && (myFlag & E_ReplaceFlags.RNO) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
else if (_MyItemInfo.IsCaution && (myFlag & E_ReplaceFlags.Caution) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
else if (_MyItemInfo.IsNote && (myFlag & E_ReplaceFlags.Note) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
else if (_MyItemInfo.IsStepPart && !_MyItemInfo.IsHigh && (myFlag & E_ReplaceFlags.Substep) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
//else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsAccPages & (myFlag & E_ReplaceFlags.Attach) > 0)
|
||||
{
|
||||
replaceit = true;
|
||||
}
|
||||
return replaceit;
|
||||
}
|
||||
#region notused
|
||||
static Regex regFindLink = new Regex(@"\<START\].*?\[END\>", RegexOptions.Singleline);
|
||||
private string ReplaceWord(string text, string replace, string with, RegexOptions regexOptions)
|
||||
|
@ -15,6 +15,7 @@ using C1.Win.C1FlexGrid;
|
||||
using C1.Win.C1SpellChecker;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Serialization;
|
||||
using Volian.Base.Library;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
@ -856,6 +857,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public void LoadGrid(ItemInfo itemInfo)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> VlnFlexGrid.LoadGrid");
|
||||
_MyItemInfo = itemInfo;
|
||||
string str = itemInfo.MyContent.MyGrid.Data;
|
||||
VE_Font vefont = _MyItemInfo.GetItemFont();
|
||||
@ -916,6 +918,7 @@ namespace Volian.Controls.Library
|
||||
_ReadingXml = false;
|
||||
Select(-1, -1); // this keeps the cell from being selected when the grid is first displayed
|
||||
Visible = true;
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
|
||||
private void ReadXml(string str)
|
||||
|
@ -528,6 +528,7 @@ namespace Volian.Controls.Library
|
||||
MessageBox.Show("Security has not been defined for PROMS. All functionality has been defaulted to the lowest level for all users until security is defined.", "no security defined", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
#region Menu_New
|
||||
if (tn.VEObject as FolderInfo != null)
|
||||
{
|
||||
@ -883,6 +884,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Cursor = Cursors.Default;
|
||||
cm.Show(this, new Point(e.X, e.Y));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user