/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridResults_ItemClick(object sender, ItemClickEventArgs e)
        {
            CardMini cardSel = e.ClickedItem as CardMini;
            CardMini selcard = new CardMini();

            selcard.Hero       = cardSel.Hero;
            selcard.CardName   = cardSel.CardName;
            selcard.CardPoints = cardSel.CardPoints;
            selcard.CardSource = cardSel.CardSource;
            selcard.UpdateData();

            App.carddatasetselected.Add(selcard);
            listSquad.DataContext = App.carddatasetselected;

            UpdatePoints();
        }
Exemplo n.º 2
0
        private async Task <bool> GetPackagedFile(string folderName, string fileName, UIElement rootFrame)
        {
            StorageFolder installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
            StorageFile   file          = null;

            if (folderName != null)
            {
                StorageFolder subFolder = await installFolder.GetFolderAsync(folderName);

                file = await subFolder.GetFileAsync(fileName);
            }
            else
            {
                file = await installFolder.GetFileAsync(fileName);
            }

            //string text = await Windows.Storage.FileIO.ReadTextAsync(file);
            //datafile df = new datafile();
            //df = Newtonsoft.Json.JsonConvert.DeserializeObject<datafile>(text);



            XmlLoadSettings settings = new XmlLoadSettings()
            {
                ValidateOnParse = false
            };
            XmlDocument xmlDoc = await XmlDocument.LoadFromFileAsync(file, settings);

            foreach (IXmlNode xmlNode in xmlDoc.GetElementsByTagName("card"))
            {
                CardMini c = new CardMini();
                foreach (XmlAttribute xa in xmlNode.Attributes)
                {
                    if (xa.Value == null)
                    {
                        continue;                   //skip bad/blank entries
                    }
                    if (xa.Value == "")
                    {
                        continue;
                    }
                    switch (xa.Name.ToLower())
                    {
                    case "id":
                        c.Hero.EntryId = xa.Value;
                        break;

                    case "life":
                        c.Hero.Life = Convert.ToInt32(xa.Value);
                        break;

                    case "world":
                        c.Hero.World = xa.Value;
                        break;

                    case "set":
                        c.Hero.Set = xa.Value;
                        break;

                    case "collectornumber":
                        c.Hero.CollectorNumber = xa.Value;
                        break;

                    case "name":
                        c.Hero.Name = xa.Value;
                        break;

                    case "valkyrie":
                        c.Hero.Valkyrie = xa.Value;
                        break;

                    case "species":
                        c.Hero.Species = xa.Value;
                        break;

                    case "herotype":
                        c.Hero.HeroType = xa.Value;
                        break;

                    case "class":
                        c.Hero.ClassType = xa.Value;
                        break;

                    case "personality":
                        c.Hero.Personality = xa.Value;
                        break;

                    case "size":
                        c.Hero.Size = xa.Value;
                        break;

                    case "move":
                        c.Hero.Move = Convert.ToInt32(xa.Value);
                        break;

                    case "range":
                        c.Hero.Range = Convert.ToInt32(xa.Value);
                        break;

                    case "attack":
                        c.Hero.Attack = Convert.ToInt32(xa.Value);
                        break;

                    case "defense":
                        c.Hero.Defense = Convert.ToInt32(xa.Value);
                        break;

                    case "points":
                        c.Hero.Points = Convert.ToInt32(xa.Value);
                        break;

                    case "bmove":
                        c.Hero.BasicMove = Convert.ToInt32(xa.Value);
                        break;

                    case "brange":
                        c.Hero.BasicRange = Convert.ToInt32(xa.Value);
                        break;

                    case "battack":
                        c.Hero.BasicAttack = Convert.ToInt32(xa.Value);
                        break;

                    case "bdefense":
                        c.Hero.BasicDefense = Convert.ToInt32(xa.Value);
                        break;

                    case "armysize":
                        c.Hero.ArmySize = Convert.ToInt32(xa.Value);
                        break;
                    }
                }
                c.Hero.Image = string.Format("/Assets/Cards/{0}.png", c.Hero.EntryId);
                c.Hero.Thumb = string.Format("/Assets/Cards/_t/{0}.png", c.Hero.EntryId);
                //c.CardSource = ImageFromRelativePath(rootFrame, c.Hero.Thumb);
                c.CardName   = c.Hero.Name;
                c.CardPoints = string.Format("{0} PTS", c.Hero.Points);
                c.UpdateData();

                CardDataset.Add(c);
            }

            foreach (IXmlNode xmlNode in xmlDoc.GetElementsByTagName("glyph"))
            {
                GlyphControl g = new GlyphControl();
                foreach (XmlAttribute xa in xmlNode.Attributes)
                {
                    switch (xa.Name.ToLower())
                    {
                    case "id":
                        g.EntryId = xa.Value;
                        break;

                    case "description":
                        g.Description = xa.Value;
                        break;
                    }
                }
                g.ImageFileName = string.Format("/Assets/Glyphs/{0}.png", g.EntryId);
                //                g.GlyphSource = ImageFromRelativePath(rootFrame, g.ImageFileName);
                glyphdataset.Add(g);
            }
            GameSetting.DataLoaded = true;
            return(true);
        }