Find/Replace dialog box
This commit is contained in:
144
PROMS/Volian.Controls.Library/FindReplace.cs
Normal file
144
PROMS/Volian.Controls.Library/FindReplace.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class FindReplace : DevComponents.DotNetBar.Office2007Form
|
||||
{
|
||||
//private bool _offsetStartPos = false;
|
||||
private StepItem _MyStepItem;
|
||||
public StepItem MyStepItem
|
||||
{
|
||||
get { return _MyStepItem; }
|
||||
set
|
||||
{
|
||||
_MyStepItem = value;
|
||||
//_offsetStartPos = false; // in a different rtf box, don't offset find position first time around
|
||||
}
|
||||
}
|
||||
//private DocVersionInfo _MyDVI;
|
||||
//public DocVersionInfo MyDVI
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_MyDVI != null) return _MyDVI;
|
||||
// if (_MyStepItem != null)
|
||||
// {
|
||||
// ItemInfo procInfo = _MyStepItem.MyItemInfo.MyProcedure as ItemInfo;
|
||||
// if (procInfo == null) return null;
|
||||
// _MyDVI = procInfo.ActiveParent as DocVersionInfo;
|
||||
// return _MyDVI;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
private bool _InApproved;
|
||||
|
||||
public bool InApproved
|
||||
{
|
||||
get { return _InApproved; }
|
||||
set { _InApproved = value; }
|
||||
}
|
||||
|
||||
public FindReplace()
|
||||
{
|
||||
//DocVersionInfo dvi = MyStepItem.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 (MyStepItem.MyStepRTB.SelectionLength > 0)
|
||||
// cmboFindText.Text = MyStepItem.MyStepRTB.SelectedText;
|
||||
cmboFindText.Focus();
|
||||
}
|
||||
|
||||
//public FindReplace(StepItem stpitm)
|
||||
//{
|
||||
// MyStepItem = stpitm;
|
||||
// DocVersionInfo dvi = MyStepItem.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 (MyStepItem.MyStepRTB.SelectionLength > 0)
|
||||
// cmboFindText.Text = MyStepItem.MyStepRTB.SelectedText;
|
||||
// cmboFindText.Focus();
|
||||
//}
|
||||
|
||||
|
||||
private void btnReplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!cmboReplaceText.Items.Contains(cmboReplaceText.Text))
|
||||
cmboReplaceText.Items.Add(cmboReplaceText.Text);
|
||||
}
|
||||
|
||||
private void btnFndRplDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
//this.Close();
|
||||
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);
|
||||
MyStepItem.MyStepRTB.Focus();
|
||||
}
|
||||
|
||||
private void cmboFindText_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool hastext = this.cmboFindText.Text.Length > 0;
|
||||
btnFindNext.Enabled = hastext;
|
||||
btnBookMrkAll.Enabled = hastext;
|
||||
btnReplace.Enabled = btnRplAll.Enabled = hastext && !InApproved;
|
||||
}
|
||||
|
||||
private void cmboReplaceText_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
btnReplace.Enabled = btnRplAll.Enabled = !InApproved && cmboFindText.Text.Length > 0;
|
||||
}
|
||||
|
||||
public void PerformFindNext()
|
||||
{
|
||||
btnFindNext.PerformClick();
|
||||
}
|
||||
|
||||
private void tabFind_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblRplTxt.Visible = false;
|
||||
cmboReplaceText.Visible = false;
|
||||
btnReplace.Visible = false;
|
||||
btnRplAll.Visible = false;
|
||||
}
|
||||
|
||||
private void tabReplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblRplTxt.Visible = true;
|
||||
cmboReplaceText.Visible = true;
|
||||
btnReplace.Visible = true;
|
||||
btnRplAll.Visible = true;
|
||||
}
|
||||
|
||||
private void FindReplace_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
btnFndRplDone_Click(sender, e);
|
||||
e.Cancel = true; // cancel the form close event - the Done_Click() will hide it instead
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user