private void ButtonResearchItem_Click(object sender, EventArgs e)
        {
            //we get the string to search
            string str = this.tbResearch.Text;

            //we start the search where we left it. "where we left it" is because the user can click multiple times on the search button to go to the next item that match the research string. when a math is found, we select that item. so, to continue to the next item when the user click again on the search button, we start where this item is.
            //when no item is selected, the default value of the variable SelectedIndex is -1. this line of code under this comment start the search at SelectedIndex + 1, so we don't have to manage differently when the user start the search and when the search is already going on.
            int ActualIndex = this.ManagerItem.SelectedIndex + 1;             // + 1 because we continue to the next item. the actual item would match again.

            //we go through every item until we find an item that match or until we get to the end.
            bool found = false;             //becomes true when we find a match

            while (ActualIndex < this.Mod.listItems.Count)
            {
                //we get the item
                oMod.ModItem mi = this.Mod.listItems[ActualIndex];
                //we get the name of the item
                string ItemName = mi.ItemName;

                //we use regex to check if the name contain the researched string
                bool IsMatchItemName = System.Text.RegularExpressions.Regex.IsMatch(ItemName, str, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //bool result1 = System.Text.RegularExpressions.Regex.IsMatch(ActualFileName.Replace("@", ""), Pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                //if the item name match, we select that item to the user and we stop the research here, for now.
                if (IsMatchItemName)
                {
                    found = true;

                    //select the item
                    this.ManagerItem.SelectIndex(ActualIndex);
                    this.ManagerItem.SetTopIndex(ActualIndex - 3);

                    //we end the search here
                    break;
                }

                //next iteration
                ActualIndex++;
            }

            //if no more match were found, we restart the research
            if (!found)
            {
                this.ManagerItem.UnselectIndex();

                //we refresh so the user realize that the item was unselected.
                this.ManagerItem.RefreshImage();
            }
        }
Esempio n. 2
0
 public ModItemEventArgs(oMod.ModItem sModItem)
 {
     this.ModItem = sModItem;
 }