コード例 #1
0
ファイル: DMToolForm.cs プロジェクト: SirSteev/3.5-DM-Tool
        private void lbFeats_SelectedIndexChanged(object sender, EventArgs e)
        {
            int    ndx         = 0;
            string lineBreaker = Environment.NewLine + "--------------------------------------------" + Environment.NewLine;
            Feat   featEntry   = InformationLibrary.FeatEntries.Find(entry => entry.Name == lbFeats.SelectedItem.ToString());


            string temp = featEntry.Name + " " + featEntry.Source + lineBreaker + featEntry.Prerequisite + lineBreaker + featEntry.Description;

            TbInformation.Text = string.Empty;
            TbInformation.Text = temp;

            string search = tbFeatsSearchKeyword.Text;

            while (ndx < TbInformation.TextLength)
            {
                int wordStartIndex = TbInformation.Find(search, ndx, RichTextBoxFinds.None);
                if (wordStartIndex != -1)
                {
                    TbInformation.SelectionStart     = wordStartIndex;
                    TbInformation.SelectionLength    = search.Length;
                    TbInformation.SelectionBackColor = Color.Orange;
                }
                else
                {
                    break;
                }
                ndx += wordStartIndex + search.Length;
            }
        }
コード例 #2
0
ファイル: DMToolForm.cs プロジェクト: SirSteev/3.5-DM-Tool
        private void SearchPlants(ListBox searchList)
        {
            string lineBreaker = Environment.NewLine + "--------------------------------------------" + Environment.NewLine;
            int    ndx         = 0;
            Plant  plnt        = InformationLibrary.PlantEntries.Find(entry => entry.Name == searchList.SelectedItem.ToString());
            string rarity      = "Rarity: ";
            string regions     = "Region: ";

            switch (plnt.Rarity)
            {
            case RarityType.VeryCommon:
                rarity += "Very Common";
                break;

            case RarityType.Common:
                rarity += "Common";
                break;

            case RarityType.Uncommon:
                rarity += "Uncommon";
                break;

            case RarityType.Rare:
                rarity += "Rare";
                break;

            case RarityType.VeryRare:
                rarity += "Very Rare";
                break;

            case RarityType.Legendary:
                rarity += "Legendary";
                break;

            default:
                rarity = "STILL NULL";
                break;
            }

            foreach (RegionSubTypes item in plnt.Regions)
            {
                switch (item)
                {
                case RegionSubTypes.Arctic:
                    regions += "Arctic";
                    break;

                case RegionSubTypes.Cities:
                    regions += "Cities";
                    break;

                case RegionSubTypes.Coastal:
                    regions += "Coastal";
                    break;

                case RegionSubTypes.Deserts:
                    regions += "Deserts";
                    break;

                case RegionSubTypes.Forests:
                    regions += "Forests";
                    break;

                case RegionSubTypes.Jungles:
                    regions += "Jungles";
                    break;

                case RegionSubTypes.Mountains:
                    regions += "Mountains";
                    break;

                case RegionSubTypes.Oceans:
                    regions += "Oceans";
                    break;

                case RegionSubTypes.Plains:
                    regions += "Plains";
                    break;

                case RegionSubTypes.Rivers:
                    regions += "Rivers";
                    break;

                case RegionSubTypes.Swamps:
                    regions += "Swamps";
                    break;

                case RegionSubTypes.UnderdarkCaves:
                    regions += "Underdark Caves";
                    break;

                case RegionSubTypes.Unknown:
                    regions += "Unknown";
                    break;

                default:
                    break;
                }
                regions += ", ";
            }
            regions = regions.Remove(regions.Length - 2, 2);

            string temp = plnt.Name + lineBreaker + rarity + Environment.NewLine + regions + lineBreaker + plnt.Description;

            TbInformation.Text = string.Empty;
            TbInformation.Text = temp;

            string search = tbPlantSearchKeyword.Text;

            while (ndx < TbInformation.TextLength)
            {
                int wordStartIndex = TbInformation.Find(search, ndx, RichTextBoxFinds.None);
                if (wordStartIndex != -1)
                {
                    TbInformation.SelectionStart     = wordStartIndex;
                    TbInformation.SelectionLength    = search.Length;
                    TbInformation.SelectionBackColor = Color.Orange;
                }
                else
                {
                    break;
                }
                ndx += wordStartIndex + search.Length;
            }
        }