- Added feature to save search criteria into settings

- Bug Fix - when results list is changed due to a delete or edit, the results selection is cleared
- If a search criteria is selected from the list, the selected criteria is placed at the top of the list
- Limit the number of search criteria to 10.  We may want this to be a user configurable number.
This commit is contained in:
Rich 2010-01-08 14:30:16 +00:00
parent 147dd8919c
commit 4a977ce48d

View File

@ -29,15 +29,22 @@ namespace Volian.Controls.Library
private Color saveGpFindROsColor;
private Color saveGrpPanSearchResults;
private ItemInfoList _SearchResults;
public ItemInfoList SearchResults
{
get { return _SearchResults; }
set
{
_SearchResults = value;
DisplayResults();
}
}
public ItemInfoList SearchResults
{
get { return _SearchResults; }
set
{
_SearchResults = value;
if (value != null) // Don't select an item from the list when it is updated
_SearchResults.ListChanged += new ListChangedEventHandler(_SearchResults_ListChanged);
DisplayResults();
}
}
void _SearchResults_ListChanged(object sender, ListChangedEventArgs e)
{
lbSrchResults.SelectedIndex = -1; // Don't select an item from the new list
}
private string _DisplayMember = "SearchPath";
//public string Status
@ -118,12 +125,23 @@ namespace Volian.Controls.Library
gpSrchAnnoText.Enabled = true;
cmbResultsStyle.Enabled = false;
}
private void LoadSearchTextListBox()
{
cbxTextSearchText.Items.Clear();
cbxTextSearchAnnotation.Items.Clear();
}
private void LoadSearchTextListBox()
{
// Setup SearchText Combo
cbxTextSearchText.Items.Clear();
if (Properties.Settings.Default["SearchList"] != null && Properties.Settings.Default.SearchList.Count > 0)
{
foreach (string str in Properties.Settings.Default.SearchList)
cbxTextSearchText.Items.Add(str);
}
// Setup SearchAnnotation Combo
cbxTextSearchAnnotation.Items.Clear();
if (Properties.Settings.Default["SearchAList"] != null && Properties.Settings.Default.SearchAList.Count > 0)
{
foreach (string str in Properties.Settings.Default.SearchAList)
cbxTextSearchAnnotation.Items.Add(str);
}
}
public void advTreeStepTypesFillIn()
{
@ -600,37 +618,37 @@ namespace Volian.Controls.Library
LastResultsMouseOverIndex = ResultsMouseOverIndex;
}
}
private void lbSrchResults_SelectedValueChanged(object sender, EventArgs e)
{
if (_LoadingList) return;
ItemInfoList iil = lbSrchResults.DataSource as ItemInfoList;
// iil will be null for a sorted list, so only check RefreshingList for ItemInfoList
if(iil == null || !iil.RefreshingList)
{
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
private void lbSrchResults_SelectedValueChanged(object sender, EventArgs e)
{
_AnnotationDetails.CurrentAnnotation = AnnotationInfo.Get(_ItemInfo.SearchAnnotationID);
if (_AnnotationDetails.CurrentAnnotation != null)
_TabControl.OpenItem(_AnnotationDetails.CurrentAnnotation.MyItem); // open the corresponding procedure text
_AnnotationDetails.FindCurrentAnnotation(); // position to corresponding row in annotation grid
}
else
{
if (_ItemInfo != null)
if (_LoadingList) return;
// If the list is being refreshed, then set the selection index to -1 (no selection)
if (_SearchResults.RefreshingList && lbSrchResults.SelectedIndex != -1)
lbSrchResults.SelectedIndex = -1;
else
{
_OpenDocFromSearch = true;
DisplayTabItem dti = _TabControl.OpenItem(_ItemInfo); // open the corresponding procedure text
if (dti.MyDSOTabPanel != null)
dti.MyDSOTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
if (dti.MyStepTabPanel != null)
dti.MyStepTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
_OpenDocFromSearch = false;
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
{
_AnnotationDetails.CurrentAnnotation = AnnotationInfo.Get(_ItemInfo.SearchAnnotationID);
if (_AnnotationDetails.CurrentAnnotation != null)
_TabControl.OpenItem(_AnnotationDetails.CurrentAnnotation.MyItem); // open the corresponding procedure text
_AnnotationDetails.FindCurrentAnnotation(); // position to corresponding row in annotation grid
}
else
{
if (_ItemInfo != null)
{
_OpenDocFromSearch = true;
DisplayTabItem dti = _TabControl.OpenItem(_ItemInfo); // open the corresponding procedure text
if (dti.MyDSOTabPanel != null)
dti.MyDSOTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
if (dti.MyStepTabPanel != null)
dti.MyStepTabPanel.SearchString = _strSrchText; // this.cbxTextSearchText.Text;
_OpenDocFromSearch = false;
}
}
}
}
}
}
private void cmbResultsStyle_SelectedValueChanged(object sender, EventArgs e)
{
@ -887,15 +905,23 @@ namespace Volian.Controls.Library
InsertSearchCriteria();
}
private void InsertSearchCriteria()
{
if (!cbxTextSearchText.Text.Equals(string.Empty))
private void InsertSearchCriteria()
{
string tstr = cbxTextSearchText.Text;
if (!cbxTextSearchText.Items.Contains(tstr))
if (!cbxTextSearchText.Text.Equals(string.Empty))
{
string tstr = cbxTextSearchText.Text;
// if its already exists in the list - remove it
if (cbxTextSearchText.Items.Contains(tstr))
cbxTextSearchText.Items.Remove(tstr);
// Add the new criteria to the top of the list
cbxTextSearchText.Items.Insert(0, tstr);
// set the text to the new criteria
cbxTextSearchText.Text = tstr;
// If there are more than 10 remove the last one
if (cbxTextSearchText.Items.Count > 10)
cbxTextSearchText.Items.RemoveAt(10);
}
}
}
private void cbxSrchTypeUsage_CheckedChanged(object sender, EventArgs e)
{
@ -1313,7 +1339,6 @@ namespace Volian.Controls.Library
cbxAnnoTypes.Focus();
cbxBooleanAnoTxtSrch_CheckedChanged(sender, e);
}
}
#region Annoation Search Type Class