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

            int ActualIndex = this.ManagerCraft.SelectedIndex + 1; // + 1 because we continue to the next item. the actual item would match again.

            bool found = false;                                    //will become true when we will find the craft

            while (ActualIndex < this.Mod.listCrafts.Count)
            {
                //we get the craft
                oMod.ModCraft mc = this.Mod.listCrafts[ActualIndex];
                //we get the name of the recipe
                string RecipeName = mc.Recipe.ItemName;

                //we use regex to check if the name contain the researched string
                bool IsMatchRecipeName = System.Text.RegularExpressions.Regex.IsMatch(RecipeName, str, System.Text.RegularExpressions.RegexOptions.IgnoreCase);

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

                    //select the craft
                    this.ManagerCraft.SelectIndex(ActualIndex);
                    this.ManagerCraft.SetTopIndex(ActualIndex - 1);

                    //we end the search here
                    break;
                }

                //next iteration
                ActualIndex++;
            }

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

                //we refresh so the user realize that the craft was unselected.
                this.ManagerCraft.RefreshImage();
            }
        }
Beispiel #2
0
 public ModCraftEventArgs(oMod.ModCraft sModCraft)
 {
     this.ModCraft = sModCraft;
 }