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:
Rich 2015-01-19 20:54:28 +00:00
parent 6a973a288b
commit d501a39a7b
4 changed files with 99 additions and 33 deletions

View File

@ -874,8 +874,11 @@ namespace Volian.Controls.Library
} }
private void PromptForChangeId(ItemInfo myItemInfo, DisplayTabItem pg) private void PromptForChangeId(ItemInfo myItemInfo, DisplayTabItem pg)
{ {
dlgChgId dlgCI = new dlgChgId(this); //, null); if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOCHGID"))
dlgCI.ShowDialog(this); {
dlgChgId dlgCI = new dlgChgId(this); //, null);
dlgCI.ShowDialog(this);
}
ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId); ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId);
SetChangeId(ChgId, pg, myItemInfo); SetChangeId(ChgId, pg, myItemInfo);
} }

View File

@ -116,6 +116,7 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit, bool colorLinks, string prefix, string suffix) 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; _FieldToEdit = fieldToEdit;
_MyItemInfo = itemInfo; _MyItemInfo = itemInfo;
OriginalText = InfoText; OriginalText = InfoText;
@ -166,8 +167,9 @@ namespace Volian.Controls.Library
} }
} }
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted, underlineAfterDashSpace); text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted, underlineAfterDashSpace);
StartText = text; StartText = text;
ProfileTimer.Pop(profileDepth);
} }
private string ReplaceLinesWithUnicode(string text) 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) 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 // Adjust RO display
if (ROsShouldBeAdjusted) 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 // 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. // actual edit mode are replace words left as is.
// But don't do ReplaceWords if the TurnOffReplaceWords format flag is set // 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); text = DoReplaceWords2(text);
ProfileTimer.Pop(profileDepth1);
}
if (_MyItemInfo != null) if (_MyItemInfo != null)
{ {
text = Regex.Replace(text, @"\<U\>", _MyItemInfo.MyDocVersion.DocVersionConfig.Unit_Number, RegexOptions.IgnoreCase); 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; return text;
} }
@ -576,11 +584,16 @@ namespace Volian.Controls.Library
} }
private string DoTransitionAdjustments(string text, bool boldTran) private string DoTransitionAdjustments(string text, bool boldTran)
{ {
int profileDepth = ProfileTimer.Push(">>>> DoTransitionAdjustments");
bool undtran = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.Underline; bool undtran = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.Underline;
string strippedText = StaticStripRtfCommands(text); 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>"); 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); MatchCollection matches = Regex.Matches(text, lookFor);
if (matches.Count == 0) return text; if (matches.Count == 0)
{
ProfileTimer.Pop(profileDepth);
return text;
}
string retstr = text; string retstr = text;
for (int i = matches.Count - 1; i >= 0; i--) 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?"); return retstr.Replace("\x1", @"\u160?");
} }
@ -1705,7 +1719,7 @@ namespace Volian.Controls.Library
// return Text; // return Text;
//} //}
#endregion #endregion
private Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>(); private static Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
private static bool? _ProcessReplaceWords; private static bool? _ProcessReplaceWords;
public 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. // 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; if (rsl.Count==1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text;
// Loop through text looking for words to be replaced // 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) foreach (ReplaceStr rs in rsl)
{ {
bool dopartial = false; bool dopartial = (rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials;
bool replaceit = false;
// note that the order of this check is important. Check in this order... // note that the order of this check is important. Check in this order...
// background here // background here
if (_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High) > 0) replaceit = true; if (!shouldReplace.ContainsKey(rs.Flag))
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; //int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt");
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true; shouldReplace.Add(rs.Flag, ShouldReplaceIt(rs.Flag));
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true; //ProfileTimer.Pop(profileDepth2);
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; bool replaceit = shouldReplace[rs.Flag];
else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
if (replaceit) if (replaceit)
{ {
if (!dicReplaceRegex.ContainsKey(rs)) 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); dicReplaceRegex.Add(rs, new Regex(rs.ReplaceWord, myOptions));
dopartial = true; }
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 try
{ {
//int profileDepth4 = ProfileTimer.Push(">>>> DoReplaceWords2.Partial");
if (!dopartial) myMatches.Add(dicReplaceRegex[rs], rs); if (!dopartial) myMatches.Add(dicReplaceRegex[rs], rs);
else partialReplaceList.Add(rs, dicReplaceRegex[rs]);
//ProfileTimer.Pop(profileDepth4);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -1784,12 +1805,15 @@ namespace Volian.Controls.Library
dopartial = false; dopartial = false;
} }
} }
//ProfileTimer.Pop(profileDepth);
//int profileDepth5 = ProfileTimer.Push(">>>> DoReplaceWords2.ReplaceMatches");
Text = myMatches.ReplaceMatches(); Text = myMatches.ReplaceMatches();
//ProfileTimer.Pop(profileDepth5);
Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space
try try
{ {
foreach (ReplaceStr prs in partialReplaceList) foreach (ReplaceStr prs in partialReplaceList.Keys)
Text = Regex.Replace(Text, prs.ReplaceWord, prs.ReplaceWith); Text = partialReplaceList[prs].Replace(Text, prs.ReplaceWith);
} }
catch (Exception ex) // Don't crash on a format issue. catch (Exception ex) // Don't crash on a format issue.
{ {
@ -1797,6 +1821,40 @@ namespace Volian.Controls.Library
} }
return Text; 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 #region notused
static Regex regFindLink = new Regex(@"\<START\].*?\[END\>", RegexOptions.Singleline); static Regex regFindLink = new Regex(@"\<START\].*?\[END\>", RegexOptions.Singleline);
private string ReplaceWord(string text, string replace, string with, RegexOptions regexOptions) private string ReplaceWord(string text, string replace, string with, RegexOptions regexOptions)

View File

@ -15,6 +15,7 @@ using C1.Win.C1FlexGrid;
using C1.Win.C1SpellChecker; using C1.Win.C1SpellChecker;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volian.Base.Library;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
@ -856,6 +857,7 @@ namespace Volian.Controls.Library
} }
public void LoadGrid(ItemInfo itemInfo) public void LoadGrid(ItemInfo itemInfo)
{ {
int profileDepth = ProfileTimer.Push(">>>> VlnFlexGrid.LoadGrid");
_MyItemInfo = itemInfo; _MyItemInfo = itemInfo;
string str = itemInfo.MyContent.MyGrid.Data; string str = itemInfo.MyContent.MyGrid.Data;
VE_Font vefont = _MyItemInfo.GetItemFont(); VE_Font vefont = _MyItemInfo.GetItemFont();
@ -916,6 +918,7 @@ namespace Volian.Controls.Library
_ReadingXml = false; _ReadingXml = false;
Select(-1, -1); // this keeps the cell from being selected when the grid is first displayed Select(-1, -1); // this keeps the cell from being selected when the grid is first displayed
Visible = true; Visible = true;
ProfileTimer.Pop(profileDepth);
} }
private void ReadXml(string str) private void ReadXml(string str)

View File

@ -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); 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; return;
} }
this.Cursor = Cursors.WaitCursor;
#region Menu_New #region Menu_New
if (tn.VEObject as FolderInfo != null) 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)); cm.Show(this, new Point(e.X, e.Y));
} }
} }