Ejemplo n.º 1
0
        void GetChamps()
        {
            var webGet   = new HtmlWeb();
            var document = webGet.Load(ChampionsUrl);
            var metaTags = document.DocumentNode.SelectNodes("//a");

            if (metaTags != null)
            {
                foreach (var tag in metaTags)
                {
                    if (tag.Attributes["class"] != null)
                    {
                        if (tag.Attributes["class"].Value.StartsWith("champ-box"))
                        {
                            string url    = tag.Attributes["href"].Value;
                            string imgUrl = tag.ChildNodes["img"].Attributes["src"].Value;
                            string nameId = url.Split('/')[url.Split('/').Count() - 1];

                            string name = nameId.Substring(0, nameId.LastIndexOf('-'));
                            int    id   = Convert.ToInt32(nameId.Substring(nameId.LastIndexOf('-') + 1));

                            string imgPath = DirectoryWorker.DownloadImage("champs", imgUrl, name + ".png");

                            Champions.Add(new Champion(id, name, imgPath, url));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public StackPanel ShowBuild(int buildNum = 0)
        {
            var buildStack = new StackPanel {
                Orientation = Orientation.Vertical
            };

            buildStack.Children.Add(new TextBlock {
                Text = Data[buildNum].Title, FontSize = 20
            });

            var summons = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var stackOfSummons = new WrapPanel {
                Orientation = Orientation.Horizontal, Width = 500
            };

            foreach (var summon in Data[buildNum].Summons)
            {
                Uri summonImgUri = new Uri(DirectoryWorker.DownloadImage("summons", summon.imgUrl, summon.name + ".png"));
                stackOfSummons.Children.Add(addTitle(summonImgUri, summon.name, 40));
            }
            summons.Children.Add(CreateContainer("Summons:", stackOfSummons));
            buildStack.Children.Add(summons);

            var runes = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var stackOfRunes = new WrapPanel {
                Orientation = Orientation.Horizontal, Width = 500
            };

            foreach (var rune in Data[buildNum].Runes)
            {
                Uri runeImgUri = new Uri(DirectoryWorker.DownloadImage("runes", rune.Data.imgUrl, rune.Data.name + ".png"));
                stackOfRunes.Children.Add(addTitle(runeImgUri, rune.Data.name.Replace("greater", ""), 50, 20));
            }
            runes.Children.Add(CreateContainer("Runes:", stackOfRunes));
            buildStack.Children.Add(runes);

            var lvls = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var stackOfSkills = new WrapPanel {
                Orientation = Orientation.Horizontal, Width = 500
            };
            var lvlCnt = 1;

            foreach (var lvl in Data[buildNum].Skills.Sequence)
            {
                var skillImgUri = new Uri(DirectoryWorker.DownloadImage("skills", Data[buildNum].Skills.SkillData[lvl].imgUrl, Data[buildNum].Skills.SkillData[lvl].name + ".png"));
                stackOfSkills.Children.Add(addTitle(skillImgUri, lvlCnt.ToString(), 30));
                lvlCnt++;
            }
            lvls.Children.Add(CreateContainer("Skills:", stackOfSkills));
            buildStack.Children.Add(lvls);

            var items = new StackPanel {
                Orientation = Orientation.Vertical
            };

            foreach (var group in Data[buildNum].GroupOfItems)
            {
                var newStack = new WrapPanel
                {
                    Orientation = Orientation.Horizontal,
                    Height      = 50,
                    Margin      = new Thickness(0, 3, 0, 3),
                    Width       = 500
                };
                foreach (var item in group.Items)
                {
                    var itemImgUri = new Uri(DirectoryWorker.DownloadImage("items", item.imgUrl, item.name + ".png"));
                    var itemImg    = new Image {
                        Source = new BitmapImage(itemImgUri), Margin = new Thickness(3, 0, 3, 0)
                    };
                    newStack.Children.Add(itemImg);
                }
                items.Children.Add(CreateContainer(group.name, newStack));
            }
            buildStack.Children.Add(items);
            return(buildStack);
        }