- 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

@ -35,9 +35,16 @@ namespace Volian.Controls.Library
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,11 +125,22 @@ namespace Volian.Controls.Library
gpSrchAnnoText.Enabled = true;
cmbResultsStyle.Enabled = false;
}
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,13 +618,13 @@ 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)
// 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
{
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
@ -892,8 +910,16 @@ namespace Volian.Controls.Library
if (!cbxTextSearchText.Text.Equals(string.Empty))
{
string tstr = cbxTextSearchText.Text;
if (!cbxTextSearchText.Items.Contains(tstr))
// 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);
}
}
@ -1313,7 +1339,6 @@ namespace Volian.Controls.Library
cbxAnnoTypes.Focus();
cbxBooleanAnoTxtSrch_CheckedChanged(sender, e);
}
}
#region Annoation Search Type Class