diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs
index c995e33d..eb9fe50c 100644
--- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs
+++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs
@@ -570,7 +570,9 @@ namespace Volian.Controls.Library
///
///
///
- public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus)
+ // C2023-016 Added doingFindReplace where if true Word section will not be opened - used only when doing Find/Replace
+ // We are not opening and searching inside Word sections, instead we just stop on the section title in the procedure editor (if a match is found in the title)
+ public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus, bool doingFindReplace=false)
{
ItemInfo myItemInfo = myItemInfo2;
@@ -649,7 +651,8 @@ namespace Volian.Controls.Library
_MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item.
- if (myItemInfo.MyContent.MyEntry == null) // If it is not a Word document open in step editor
+ // C2023-016 if a Word section and doing Find/Replace don't open Word section, position to section title in step editor instead
+ if (myItemInfo.MyContent.MyEntry == null || doingFindReplace) // If it is not a Word document open in step editor
{
return OpenStepTabPage(myItemInfo, setFocus);
}
diff --git a/PROMS/Volian.Controls.Library/FindReplace.Designer.cs b/PROMS/Volian.Controls.Library/FindReplace.Designer.cs
index b33046f0..57fcdad4 100644
--- a/PROMS/Volian.Controls.Library/FindReplace.Designer.cs
+++ b/PROMS/Volian.Controls.Library/FindReplace.Designer.cs
@@ -183,7 +183,6 @@ namespace Volian.Controls.Library
this.cmboFindText.WatermarkFont = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmboFindText.WatermarkText = "Enter text to find";
this.cmboFindText.TextChanged += new System.EventHandler(this.cmboFindText_TextChanged);
- this.cmboFindText.Leave += new System.EventHandler(this.cmboFindText_Leave);
//
// labelX3
//
@@ -349,6 +348,7 @@ namespace Volian.Controls.Library
this.cbxReverse.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.cbxReverse.TabIndex = 5;
this.cbxReverse.Text = "Reverse Find";
+ this.cbxReverse.CheckedChanged += new System.EventHandler(this.cbxReverse_CheckedChanged);
//
// cbxWholeWord
//
@@ -363,6 +363,7 @@ namespace Volian.Controls.Library
this.cbxWholeWord.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.cbxWholeWord.TabIndex = 4;
this.cbxWholeWord.Text = "Whole Word";
+ this.cbxWholeWord.CheckedChanged += new System.EventHandler(this.cbxWholeWord_CheckedChanged);
//
// cbxCaseSensitive
//
@@ -377,6 +378,7 @@ namespace Volian.Controls.Library
this.cbxCaseSensitive.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.cbxCaseSensitive.TabIndex = 3;
this.cbxCaseSensitive.Text = "Case Sensitive";
+ this.cbxCaseSensitive.CheckedChanged += new System.EventHandler(this.cbxCaseSensitive_CheckedChanged);
//
// cmbScope
//
diff --git a/PROMS/Volian.Controls.Library/FindReplace.cs b/PROMS/Volian.Controls.Library/FindReplace.cs
index efec8fc0..8a03c091 100644
--- a/PROMS/Volian.Controls.Library/FindReplace.cs
+++ b/PROMS/Volian.Controls.Library/FindReplace.cs
@@ -11,11 +11,13 @@ using JR.Utils.GUI.Forms;
namespace Volian.Controls.Library
{
+ // C2023-016 - Upgrade - have Find/Replace spin through all of the Step Editor sections within the current procedure
public partial class FindReplace : DevComponents.DotNetBar.Office2007Form
{
private bool doingfind = false;
private bool findingbookmarks = false;
private bool _FoundIt = false;
+ private ItemInfo _StartingItemInfo = null;// C2023-016 used to remember where we started doing the Find/Replace
public bool FoundIt
{
get { return _FoundIt; }
@@ -25,7 +27,7 @@ namespace Volian.Controls.Library
{
get
{
- // B2022-067 get display text version to convert 8209 dash to nornal (keyboard) dash
+ // B2022-067 get display text version to convert 8209 dash to normal (keyboard) dash
string selStr = ItemInfo.ConvertToDisplayText(MyEditItem.MyStepRTB.SelectedText);
if (!cbxCaseSensitive.Checked)
return selStr.ToUpper() == cmboFindText.Text.ToUpper();
@@ -33,7 +35,6 @@ namespace Volian.Controls.Library
return selStr == cmboFindText.Text;
}
}
- //private bool _offsetStartPos = false;
private EditItem _MyEditItem;
public EditItem MyEditItem
{
@@ -44,25 +45,13 @@ namespace Volian.Controls.Library
if (_MyEditItem == null) return;
_MyDocVersion = _MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
SetupContextMenu();
- //_offsetStartPos = false; // in a different rtf box, don't offset find position first time around
}
}
private DocVersionInfo _MyDocVersion;
public DocVersionInfo Mydocversion
{
get { return _MyDocVersion; }
- set
- {
- _MyDocVersion = value;
- //if (_MyDocVersion != null)
- //{
- // if (_MyDocVersion.DocVersionAssociationCount > 0)
- // {
- // MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.ROFSTLookup;
- // _MyRODbID = _MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID;
- // }
- //}
- }
+ set {_MyDocVersion = value; }
}
private DisplayBookMarks _myDisplayBookMarks;
@@ -83,17 +72,12 @@ namespace Volian.Controls.Library
{
InitializeComponent();
LoadFindReplaceTextListBox();
- //if (dvi != null && dvi.VersionType > 127)
- // InApproved = false; // in approved
cmbScope.SelectedIndex = 0;
btnBookMrkAll.Enabled = false;
btnFindNext.Enabled = false;
btnReplace.Enabled = false;
btnRplAll.Enabled = false;
- //if (MyRTBItem.MyStepRTB.SelectionLength > 0)
- // cmboFindText.Text = MyRTBItem.MyStepRTB.SelectedText;
cmboFindText.Focus();
- //SetupContextMenu();
}
private void LoadFindReplaceTextListBox()
{
@@ -113,51 +97,34 @@ namespace Volian.Controls.Library
}
}
- //public FindReplace(RTBItem stpitm)
- //{
- // MyRTBItem = stpitm;
- // DocVersionInfo dvi = MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
- // InitializeComponent();
- // if (dvi != null && dvi.VersionType > 127)
- // InApproved = false; // in approved
- // cmbScope.SelectedIndex = 0;
- // btnBookMrkAll.Enabled = false;
- // btnFindNext.Enabled = false;
- // btnReplace.Enabled = false;
- // btnRplAll.Enabled = false;
- // if (MyRTBItem.MyStepRTB.SelectionLength > 0)
- // cmboFindText.Text = MyRTBItem.MyStepRTB.SelectedText;
- // cmboFindText.Focus();
- //}
-
// bug fix: B2016-107, when Find/Replace is initially opened, set the cursor focus to the Find Text box (called from frmVEPROMS.cs)
public void SetFocusToTextBox()
{
cmboFindText.Focus();
}
+
private bool DoingClick = false; // Don't allow a button to be clicked until processing is complete for the last button
+
private void btnReplace_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
- DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = true;// We started processing a click
DoReplace();
- DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = false;// we're done processing the click
}
private void DoReplace()
{
if (!IsFound)
DoFindNext();
else
- {
MyEditItem.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, false, null);
- }
}
private void btnRplAll_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
- DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = true; // We started processing a click
DoRplAll();
- DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = false; // we're done processing the click
}
private void DoRplAll()
{
@@ -172,9 +139,9 @@ namespace Volian.Controls.Library
private void btnBookMrkAll_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
- DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = true; // We started processing a click
DoBookMrkAll();
- DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = false; // we're done processing the click
}
private void DoBookMrkAll()
{
@@ -193,7 +160,6 @@ namespace Volian.Controls.Library
}
private void btnFndRplDone_Click(object sender, EventArgs e)
{
- //this.Close();
doingfind = false;
this.Visible = false;
}
@@ -229,10 +195,48 @@ namespace Volian.Controls.Library
private void btnFindNext_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
- DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = true;// We started processing a click
DoFindNext();
- DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
+ DoingClick = false;// we're done processing the click
}
+
+ // C2023-016 Find the next element, but stay in the same procedure
+ private ItemInfo FindNextStepElement(ItemInfo curStepElem, string fndStr)
+ {
+ ItemInfo nxtStepElem = curStepElem;
+ if (_StartingItemInfo == null)
+ _StartingItemInfo = MyEditItem.MyItemInfo;
+ if (cbxReverse.Checked)
+ {
+ if (curStepElem.IsProcedure)
+ nxtStepElem = curStepElem.MyProcedure.SearchBottom; // at the top of the procedure, so next step would be the last step of the last section (or the section title if the last section is a Word section)
+ else
+ nxtStepElem = curStepElem.SearchPrev;
+ }
+ else if (curStepElem.SearchNext.IsProcedure) // searching(finding) forward but next is the next procedure, so jump to the top of the procedure (the procedure title in the step editor)
+ nxtStepElem = curStepElem.MyProcedure;
+ else
+ nxtStepElem = curStepElem.SearchNext;
+ // B2015-131 Find was not finding series of words when one or more of the words were bolded or underlined (ex finding "Any SG" where Any was bolded)
+ while (nxtStepElem != null && nxtStepElem.ItemID != _StartingItemInfo.ItemID)
+ {
+ if (nxtStepElem.MyContent != null && ContainsFndStr(RtfTools.RTFConvertedSymbolsToUnicode(nxtStepElem.MyContent.Text).ToUpper(), fndStr.ToUpper()))
+ break;
+ if (cbxReverse.Checked)
+ {
+ if (nxtStepElem.IsProcedure)
+ nxtStepElem = nxtStepElem.MyProcedure.SearchBottom;// at the top of the procedure, so next step would be the last step of the last section (or the section title if the last section is a Word section)
+ else
+ nxtStepElem = nxtStepElem.SearchPrev;
+ }
+ else if (nxtStepElem.SearchNext.IsProcedure)
+ nxtStepElem = nxtStepElem.MyProcedure;// searching(finding) forward but next is the next procedure, so jump to the top of the procedure(the procedure title in the step editor)
+ else
+ nxtStepElem = nxtStepElem.SearchNext;
+ }
+ return nxtStepElem;
+ }
+
private void DoFindNext()
{
AddToComboLists();
@@ -240,32 +244,21 @@ namespace Volian.Controls.Library
string fndStr = FixSymbol(cmboFindText.Text.Replace(@"\", @"\u9586?").Replace("-", @"\u8209?").Replace("\xa0", @"\u160?"));
while (!MyEditItem.FindText(cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked))
{
- ItemInfo next = (cbxReverse.Checked) ? MyEditItem.MyItemInfo.SearchPrev : MyEditItem.MyItemInfo.SearchNext;
+ ItemInfo next = FindNextStepElement(MyEditItem.MyItemInfo, fndStr);
- // B2015-131 Find was not finding series of words when one or more of the words were bolded or underlined (ex finding "Any SG" where Any was bolded)
- while ((next != null) && !next.IsSection && !ContainsFndStr(RtfTools.RTFConvertedSymbolsToUnicode(next.MyContent.Text).ToUpper(), fndStr.ToUpper()))
- {
- next = (cbxReverse.Checked) ? next.SearchPrev : next.SearchNext;
- }
- //if (next != null) Console.WriteLine("next {0} {1}", next.ItemID, next.MyContent.Text);
- if ((next == null) || next.IsSection)
- {
- if (!findingbookmarks)
- {
- // C2020-015: Improve dialog messaging
- if (cbxReverse.Checked)
- FlexibleMessageBox.Show(this, "Nothing found here to beginning of this section", "End of Find/Replace");
- else
- FlexibleMessageBox.Show(this, "Nothing found here to end of this section", "End of Find/Replace");
- }
- FoundIt = false;
- return;
- }
-
- MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next);
+ MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next,true,true);// C2023-016 open item (next), set focus (true), doing Find/Replace so don't open Word section (true)
if (cbxReverse.Checked)
MyEditItem.PositionToEnd();
if (next.IsTable && !cbxReverse.Checked) MyEditItem.PositionToStart();
+ //C2023-016 if we spun through all of the step editor sections, stop and display a message
+ if (MyEditItem.MyItemInfo.ItemID == _StartingItemInfo.ItemID)
+ {
+ FoundIt = false;
+ string msg = string.Format("Back to the starting point of the Find/Replace.{0}",(findingbookmarks)?"\n\n The Tools Panel will display showing the locations.":"");
+ FlexibleMessageBox.Show(this, msg, "Find/Replace Completed");
+ _StartingItemInfo = null;
+ return;
+ }
}
if (MyEditItem.MyStepRTB != null && !MyEditItem.MyStepRTB.Visible)
{
@@ -286,7 +279,7 @@ namespace Volian.Controls.Library
{
if (cmboFindText.Items.Count >= 10)
cmboFindText.Items.RemoveAt(9);
- cmboFindText.Items.Insert(0, cmboFindText.Text);//.Add(cmboFindText.Text);
+ cmboFindText.Items.Insert(0, cmboFindText.Text);
}
hastext = this.cmboReplaceText.Text.Length > 0;
if (hastext && btnReplace.Enabled && !cmboReplaceText.Items.Contains(cmboReplaceText.Text))
@@ -302,11 +295,13 @@ namespace Volian.Controls.Library
btnFindNext.Enabled = hastext;
btnBookMrkAll.Enabled = hastext;
btnReplace.Enabled = btnRplAll.Enabled = hastext && !InApproved;
+ _StartingItemInfo = null; //C2023-016 reset the starting position
}
private void cmboReplaceText_TextChanged(object sender, EventArgs e)
{
btnReplace.Enabled = btnRplAll.Enabled = !InApproved && cmboFindText.Text.Length > 0;
+ _StartingItemInfo = null;//C2023-016 reset the starting position
}
public void PerformFindNext()
@@ -336,17 +331,6 @@ namespace Volian.Controls.Library
e.Cancel = true; // cancel the form close event - the Done_Click() will hide it instead
}
- private void cmboFindText_Leave(object sender, EventArgs e)
- {
- //bool hastext = this.cmboFindText.Text.Length > 0;
- //if (hastext && !cmboFindText.Items.Contains(cmboFindText.Text))
- //{
- // if (cmboFindText.Items.Count >= 10)
- // cmboFindText.Items.RemoveAt(9);
- // cmboFindText.Items.Insert(0, cmboFindText.Text);//.Add(cmboFindText.Text);
- //}
- }
-
private void btnCmCut_Click(object sender, EventArgs e)
{
Clipboard.Clear();
@@ -456,6 +440,22 @@ namespace Volian.Controls.Library
tabReplace.Visible = true;
Text = "Find and Replace";//C2021-021 change the dialog title
}
+ _StartingItemInfo = null;//C2023-016 reset the starting position
+ }
+
+ private void cbxCaseSensitive_CheckedChanged(object sender, EventArgs e)
+ {
+ _StartingItemInfo = null;//C2023-016 reset the starting position
+ }
+
+ private void cbxWholeWord_CheckedChanged(object sender, EventArgs e)
+ {
+ _StartingItemInfo = null;//C2023-016 reset the starting position
+ }
+
+ private void cbxReverse_CheckedChanged(object sender, EventArgs e)
+ {
+ _StartingItemInfo = null;//C2023-016 reset the starting position
}
}
}
\ No newline at end of file