Beispiel #1
0
        private void btnGetListFromText_Click(object sender, EventArgs e)
        {
            //read each data of the given text
            //List<string> characterLine = HTML.GetListOfAllMatchData(txtAll.Text, "<td><a href=" + ".*" + " width=\"75\" height=\"75\" /></a></td>");
            List <string> listOfPattern = new List <string>();

            listOfPattern.Add("<td><a href=" + ".*" + " width=\"75\" height=\"75\" /></a></td>");
            listOfPattern.Add("<td width=\"75\"><a href=" + ".*" + " width=\"75\" height=\"75\" /></a></td>");
            List <string> characterLine = HTML.GetListOfAllMatchData(txtAll.Text, listOfPattern);

            List <Character> lsitOfcharacter = new List <Character>();

            foreach (string character in characterLine)
            {
                HTML xx = new HTML(character);
                xx.stripOuterHtml("td");
                xx.stripOuterHtml("div");
                string link = xx.Attribute["href"];
                xx.stripOuterHtml("a");
                string name = xx.Attribute["alt"];

                Character newCharacter = new Character(link, name);
                lsitOfcharacter.Add(newCharacter);
            }


            string test = Xmls.WriteXML(lsitOfcharacter);
            string a    = "ends";
        }
Beispiel #2
0
        private void btnGetHtmlCooking_Click(object sender, EventArgs e)
        {
            HTML charcaterList = new HTML(txtCookingLink.Text, "POST");

            txtAll.Text = charcaterList.Content;
            string RecipeName = "unAssigned";

            List <string> answer     = HTML.GetListOfAllRecipe(txtAll.Text);
            List <Recipe> realanswer = new List <Recipe>();

            Recipe eachRecipe = new Recipe();

            foreach (string relatedHtml in answer)
            {
                string[] keyNVAlue = relatedHtml.Split(':');
                if (keyNVAlue.Length > 1)
                {
                    string key   = keyNVAlue[0];
                    string value = keyNVAlue[1].Replace("\"", string.Empty).Replace("-", string.Empty).Trim();

                    if (key.Contains("Required Utensils"))
                    {
                        eachRecipe.RequiredUtensils = value;
                    }
                    else if (key.Contains("Required Ingredients"))
                    {
                        eachRecipe.RequiredIngredients = value;
                    }
                    else if (key.Contains("Required Seasoning"))
                    {
                        eachRecipe.RequiredSeasoning = value;
                    }
                    else if (key.Contains("Optional Utensils"))
                    {
                        eachRecipe.OptionalUtensils = value;
                    }
                    else if (key.Contains("Optional Ingredients"))
                    {
                        eachRecipe.OptionalIngredients = value;
                    }
                    else if (key.Contains("Optional Seasoning"))
                    {
                        eachRecipe.OptionalSeasoning = value;
                        realanswer.Add(eachRecipe);
                        eachRecipe = new Recipe();
                    }
                }
                else
                {
                    eachRecipe.RecipeName = relatedHtml;
                }
            }
            string yeahh = Xmls.WriteXML(realanswer);

            string zzz = string.Empty;
            //try
            //{
            //    charName = man.Link;
            //    string link = string.Format("http://harvestmoonbacktonatureguide.com/{0}", man.Link);
            //    HTML charcaterList = new HTML(link, "POST");

            //    CharacterFavourite eachFavour = new CharacterFavourite() { characterLink = man.Link };
            //    txtAll.Text = charcaterList.Content;
            //    List<string> favourListLine = HTML.GetListOfAllFavouriteLine(charcaterList.Content);
            //    foreach (string loveList in favourListLine)
            //    {

            //        if (loveList.ToLower().Contains("dislike"))
            //            eachFavour.DislikedItem = loveList;
            //        else if (loveList.ToLower().Contains("love"))
            //            eachFavour.LovedItem = loveList;
            //        else if (loveList.ToLower().Contains("like"))
            //            eachFavour.LikedItem = loveList;
            //        else if (loveList.ToLower().Contains("neutral"))
            //            eachFavour.NauturalItem = loveList;
            //        else if (loveList.ToLower().Contains("hate"))
            //            eachFavour.HatedItem = loveList;
            //        else
            //            eachFavour.ElseItem += loveList;
            //    }
            //    charFavour.Add(eachFavour);
            //    doneCOunt++;

            //    pgbWaitLoadCharFavour.Value += 1;
            //   // txtLoadInfo.Text = string.Format("Loaded {0} out of 27", doneCOunt.ToString());
            //}
            //catch
            //{
            //    error.AppendLine( string.IsNullOrEmpty(error.ToString()) ? string.Empty : ", " + charName );
            //    continue;
            //}
        }
Beispiel #3
0
        //private void DoTheLoad()//(object sender, EventArgs e)
        //{
        //    for (int progress = 1; progress <= 100; progress++)
        //    {
        //        System.Threading.Thread.Sleep(20);

        //        // Update the wait window message
        //        pgbWaitLoadCharFavour.Value = doneCOunt;
        //        //txtLoadInfo.Text = string.Format("Loaded {0} out of 27", doneCOunt.ToString());
        //    }
        //}


        //private void btnGetCharFavourite_Click(object sender, EventArgs e)
        private void btnGetCharFavourite_Click(object sender, EventArgs e)
        {
            int doneCOunt = 0;

            pgbWaitLoadCharFavour.Maximum = 27;
            //Thread workerThread = new Thread(new ThreadStart(this.DoTheLoad));
            //workerThread.Start();

            List <Character>          characters = Xmls.DeserializeObject(txtXmlPath.Text);
            List <CharacterFavourite> charFavour = new List <CharacterFavourite>();
            StringBuilder             error      = new StringBuilder();

            foreach (Character man in characters)
            {
                string charName = "unassginedYet";
                try
                {
                    charName = man.Link;
                    string link          = string.Format("http://harvestmoonbacktonatureguide.com/{0}", man.Link);
                    HTML   charcaterList = new HTML(link, "POST");

                    CharacterFavourite eachFavour = new CharacterFavourite()
                    {
                        characterLink = man.Link
                    };
                    txtAll.Text = charcaterList.Content;
                    List <string> favourListLine = HTML.GetListOfAllFavouriteLine(charcaterList.Content);
                    foreach (string loveList in favourListLine)
                    {
                        if (loveList.ToLower().Contains("dislike"))
                        {
                            eachFavour.DislikedItem = loveList;
                        }
                        else if (loveList.ToLower().Contains("love"))
                        {
                            eachFavour.LovedItem = loveList;
                        }
                        else if (loveList.ToLower().Contains("like"))
                        {
                            eachFavour.LikedItem = loveList;
                        }
                        else if (loveList.ToLower().Contains("neutral"))
                        {
                            eachFavour.NauturalItem = loveList;
                        }
                        else if (loveList.ToLower().Contains("hate"))
                        {
                            eachFavour.HatedItem = loveList;
                        }
                        else
                        {
                            eachFavour.ElseItem += loveList;
                        }
                    }
                    charFavour.Add(eachFavour);
                    doneCOunt++;

                    pgbWaitLoadCharFavour.Value += 1;
                    // txtLoadInfo.Text = string.Format("Loaded {0} out of 27", doneCOunt.ToString());
                }
                catch
                {
                    error.AppendLine(string.IsNullOrEmpty(error.ToString()) ? string.Empty : ", " + charName);
                    continue;
                }
            }

            string test = Xmls.WriteXML(charFavour);
            string f    = "";
            //HTML charcaterList = new HTML("http://harvestmoonbacktonatureguide.com/anna.html", "POST");
            //txtAll.Text = charcaterList.Content;
            //List<string> favourList =  HTML.GetListOfAllFavourite(charcaterList.Content);
            //string d = string.Empty;
        }