Getting everthing functional
This commit is contained in:
@@ -11,6 +11,10 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class FindReplace : DevComponents.DotNetBar.Office2007Form
|
||||
{
|
||||
private bool doingfind = false;
|
||||
private bool found = false;
|
||||
private bool findingbookmarks = false;
|
||||
|
||||
//private bool _offsetStartPos = false;
|
||||
private StepItem _MyStepItem;
|
||||
public StepItem MyStepItem
|
||||
@@ -19,6 +23,9 @@ namespace Volian.Controls.Library
|
||||
set
|
||||
{
|
||||
_MyStepItem = value;
|
||||
//DocVersionInfo dvi = _MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; //MyStepItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
_MyDocVersion = _MyStepItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
SetupContextMenu();
|
||||
//_offsetStartPos = false; // in a different rtf box, don't offset find position first time around
|
||||
}
|
||||
}
|
||||
@@ -39,6 +46,31 @@ namespace Volian.Controls.Library
|
||||
// }
|
||||
//}
|
||||
|
||||
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;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
private DisplayBookMarks _myDisplayBookMarks;
|
||||
|
||||
public DisplayBookMarks MyDisplayBookMarks
|
||||
{
|
||||
get { return _myDisplayBookMarks; }
|
||||
set { _myDisplayBookMarks = value; }
|
||||
}
|
||||
|
||||
private bool _InApproved;
|
||||
|
||||
public bool InApproved
|
||||
@@ -51,6 +83,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
//DocVersionInfo dvi = MyStepItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
InitializeComponent();
|
||||
LoadFindReplaceTextListBox();
|
||||
//if (dvi != null && dvi.VersionType > 127)
|
||||
// InApproved = false; // in approved
|
||||
cmbScope.SelectedIndex = 0;
|
||||
@@ -61,6 +94,24 @@ namespace Volian.Controls.Library
|
||||
//if (MyStepItem.MyStepRTB.SelectionLength > 0)
|
||||
// cmboFindText.Text = MyStepItem.MyStepRTB.SelectedText;
|
||||
cmboFindText.Focus();
|
||||
//SetupContextMenu();
|
||||
}
|
||||
private void LoadFindReplaceTextListBox()
|
||||
{
|
||||
// Setup cmboFindText Combo box
|
||||
cmboFindText.Items.Clear();
|
||||
if (Properties.Settings.Default["FindTextList"] != null && Properties.Settings.Default.FindTextList.Count > 0)
|
||||
{
|
||||
foreach (string str in Properties.Settings.Default.FindTextList)
|
||||
cmboFindText.Items.Add(str);
|
||||
}
|
||||
// Setup cmboReplaceText Combo box
|
||||
cmboReplaceText.Items.Clear();
|
||||
if (Properties.Settings.Default["ReplaceTextList"] != null && Properties.Settings.Default.ReplaceTextList.Count > 0)
|
||||
{
|
||||
foreach (string str in Properties.Settings.Default.ReplaceTextList)
|
||||
cmboReplaceText.Items.Add(str);
|
||||
}
|
||||
}
|
||||
|
||||
//public FindReplace(StepItem stpitm)
|
||||
@@ -83,24 +134,90 @@ namespace Volian.Controls.Library
|
||||
|
||||
private void btnReplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!cmboReplaceText.Items.Contains(cmboReplaceText.Text))
|
||||
cmboReplaceText.Items.Add(cmboReplaceText.Text);
|
||||
btnFindNext_Click(sender, e);
|
||||
if (found) // found is set in btnFindNext_Click()
|
||||
MyStepItem.MyStepRTB.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, false, null);
|
||||
}
|
||||
|
||||
private void btnRplAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnFindNext_Click(sender, e);
|
||||
while (found) // found is set in btnFindNext_Click()
|
||||
{
|
||||
if (MyStepItem.MyStepRTB.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, true, this) == DialogResult.Cancel)
|
||||
found = false;
|
||||
else
|
||||
btnFindNext_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnBookMrkAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
findingbookmarks = true;
|
||||
btnFindNext_Click(sender, e);
|
||||
while (found) // found is set in btnFindNext_Click()
|
||||
{
|
||||
MyDisplayBookMarks.AddBookMark(MyStepItem.MyItemInfo);
|
||||
btnFindNext_Click(sender, e);
|
||||
}
|
||||
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Bookmarks");
|
||||
MyStepItem.MyStepPanel.OnTabDisplay(sender, args);
|
||||
findingbookmarks = false;
|
||||
}
|
||||
|
||||
private void btnFndRplDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
//this.Close();
|
||||
this.Visible = false;
|
||||
doingfind = false;
|
||||
this.Visible = false;
|
||||
}
|
||||
|
||||
private void btnFindNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!cmboFindText.Items.Contains(cmboFindText.Text))
|
||||
cmboFindText.Items.Add(cmboFindText.Text);
|
||||
MyStepItem.MyStepRTB.FindText(cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked);
|
||||
found = false;
|
||||
AddToComboLists();
|
||||
doingfind = true;
|
||||
while (!MyStepItem.MyStepRTB.FindText(cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked))
|
||||
{
|
||||
ItemInfo next = (cbxReverse.Checked) ? MyStepItem.MyItemInfo.SearchPrev : MyStepItem.MyItemInfo.SearchNext;
|
||||
while (!next.IsSection && !next.MyContent.Text.ToUpper().Contains(cmboFindText.Text.ToUpper()))
|
||||
next = (cbxReverse.Checked) ? next.SearchPrev : next.SearchNext;
|
||||
if (next.IsSection)
|
||||
{
|
||||
if (!findingbookmarks)
|
||||
{
|
||||
if (cbxReverse.Checked)
|
||||
MessageBox.Show(this, "Not Found - From Here to Beginning of Section", "Find/Replace");
|
||||
else
|
||||
MessageBox.Show(this, "Not Found - From Here to End of Section", "Find/Replace");
|
||||
}
|
||||
return;
|
||||
}
|
||||
MyStepItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next);
|
||||
if (cbxReverse.Checked)
|
||||
MyStepItem.MyStepRTB.SelectionStart = MyStepItem.MyStepRTB.Text.Length;
|
||||
}
|
||||
MyStepItem.MyStepRTB.Focus();
|
||||
found = true;
|
||||
}
|
||||
|
||||
private void AddToComboLists()
|
||||
{
|
||||
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);
|
||||
}
|
||||
hastext = this.cmboReplaceText.Text.Length > 0;
|
||||
if (hastext && btnReplace.Enabled && !cmboReplaceText.Items.Contains(cmboReplaceText.Text))
|
||||
{
|
||||
if (cmboReplaceText.Items.Count >= 10)
|
||||
cmboReplaceText.Items.RemoveAt(9);
|
||||
cmboReplaceText.Items.Insert(0, cmboReplaceText.Text);
|
||||
}
|
||||
}
|
||||
private void cmboFindText_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool hastext = this.cmboFindText.Text.Length > 0;
|
||||
@@ -140,5 +257,116 @@ namespace Volian.Controls.Library
|
||||
btnFndRplDone_Click(sender, e);
|
||||
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();
|
||||
DataObject myDO = new DataObject(DataFormats.Text, cmboReplaceText.Focused ? cmboReplaceText.SelectedText : cmboFindText.SelectedText);
|
||||
Clipboard.SetDataObject(myDO);
|
||||
// Need to check which combo box activated the context menu so that we know where to take/put selected text
|
||||
if (cmboFindText.Focused)
|
||||
cmboFindText.SelectedText = "";
|
||||
else if (cmboReplaceText.Focused)
|
||||
cmboReplaceText.SelectedText = "";
|
||||
}
|
||||
|
||||
private void btnCmCopy_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Need to check which combo box activated the context menu so that we know where to take/put selected text
|
||||
DataObject myDO = new DataObject(DataFormats.Text, cmboReplaceText.Focused ? cmboReplaceText.SelectedText : cmboFindText.SelectedText);
|
||||
if (cmboFindText.Focused || cmboReplaceText.Focused)
|
||||
{
|
||||
Clipboard.Clear();
|
||||
Clipboard.SetDataObject(myDO);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCmPaste_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Need to check which combo box activated the context menu so that we know where to take/put selected text
|
||||
IDataObject myDO = Clipboard.GetDataObject();
|
||||
if (myDO.GetDataPresent(DataFormats.Rtf))
|
||||
{
|
||||
StepRTB stpRTB = new StepRTB();
|
||||
stpRTB.SelectedRtf = myDO.GetData(DataFormats.Rtf).ToString();
|
||||
if (cmboReplaceText.Focused)
|
||||
cmboReplaceText.SelectedText = stpRTB.Text;
|
||||
else if (cmboFindText.Focused)
|
||||
cmboFindText.SelectedText = stpRTB.Text;
|
||||
}
|
||||
else if (myDO.GetDataPresent(DataFormats.Text))
|
||||
if (cmboReplaceText.Focused)
|
||||
cmboReplaceText.SelectedText = Clipboard.GetText();
|
||||
else if (cmboFindText.Focused)
|
||||
cmboFindText.SelectedText = Clipboard.GetText();
|
||||
}
|
||||
|
||||
private void btnCmHardSp_Click(object sender, EventArgs e)
|
||||
{
|
||||
// We use \u00A0 to represent a hard space because it show in the search text field as a blank
|
||||
// It will get translated to a real hard space character prior to searching
|
||||
if (cmboReplaceText.Focused)
|
||||
cmboReplaceText.SelectedText = "\u00A0";
|
||||
else if (cmboFindText.Focused)
|
||||
cmboFindText.SelectedText = "\u00A0";
|
||||
}
|
||||
private void btnSym_Click(object sender, EventArgs e)
|
||||
{
|
||||
DevComponents.DotNetBar.ButtonItem b = (DevComponents.DotNetBar.ButtonItem)sender;
|
||||
if (cmboReplaceText.Focused)
|
||||
cmboReplaceText.SelectedText = (string)b.Text;
|
||||
else if (cmboFindText.Focused)
|
||||
cmboFindText.SelectedText = (string)b.Text;
|
||||
}
|
||||
private void SetupContextMenu()
|
||||
{
|
||||
galSymbols.SubItems.Clear();
|
||||
if (_MyDocVersion != null)
|
||||
{
|
||||
FormatData fmtdata = _MyDocVersion.ActiveFormat.PlantFormat.FormatData;
|
||||
SymbolList sl = fmtdata.SymbolList;
|
||||
if (sl == null || sl.Count <= 0)
|
||||
{
|
||||
MessageBox.Show(this, "No symbols are available, check with administrator");
|
||||
return;
|
||||
}
|
||||
foreach (Symbol sym in sl)
|
||||
{
|
||||
DevComponents.DotNetBar.ButtonItem btnCM = new DevComponents.DotNetBar.ButtonItem();
|
||||
btnCM.Text = string.Format("{0}", (char)sym.Unicode);
|
||||
// to name button use unicode rather than desc, desc may have spaces or odd chars
|
||||
btnCM.Name = "btnCM" + sym.Unicode.ToString();
|
||||
btnCM.Tooltip = sym.Desc;
|
||||
btnCM.Tag = string.Format(@"{0}", sym.Unicode);
|
||||
btnCM.FontBold = true;
|
||||
btnCM.Click += new System.EventHandler(btnSym_Click);
|
||||
galSymbols.SubItems.Add(btnCM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FindReplace_Activated(object sender, EventArgs e)
|
||||
{
|
||||
StepRTB srtb = MyStepItem.MyStepRTB;
|
||||
if (srtb.SelectionLength > 0 && !doingfind)
|
||||
{
|
||||
if (srtb.IsSelectionLinked(srtb.SelectionStart, srtb.SelectionLength))
|
||||
cmboFindText.Text = srtb.SelectedText.Substring(0, srtb.SelectedText.IndexOf("#Link"));
|
||||
else
|
||||
cmboFindText.Text = srtb.SelectedText;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user