Esempio n. 1
0
        /// <summary>
        /// Get games with names, price and AppId.
        /// </summary>
        /// <param name="communityId">CommunityId</param>
        /// <returns>Games list with names, price and AppId.</returns>
        public List <Games> GetGames(string communityId)
        {
            var   games = new List <Games>();
            var   regex = new Regex("^[0-9]+$");
            Match match = regex.Match(communityId);

            if (!match.Success)
            {
                communityId = GetCommunityId(communityId);
            }
            var gamesJson = getGamesJSON(communityId);
            var args      = new UpdEventArgs();

            args.MaxProgress = gamesJson.Count;
            args.Progress    = 0;
            for (int i = 0; i < gamesJson.Count; i++)
            {
                var    game = new Games();
                double price;
                string name = string.Empty;
                GetGameInfo(gamesJson[i].appid.ToString(), out price, out name);
                name       = WebUtility.HtmlDecode(name);
                game.appId = gamesJson[i].appid.ToString();
                game.price = price;
                game.name  = name;
                if (!string.IsNullOrEmpty(name))
                {
                    games.Add(game);

                    args.Progress++;
                    args.Msg = "{0};{1}".F(name, price);
                    updEvent(this, args);
                }
                else
                {
                    args.Progress++;
                    args.Msg = "";
                    updEvent(this, args);
                }
            }
            return(games);
        }
Esempio n. 2
0
        private void UpdProgress(object sender, UpdEventArgs e)
        {
            pb1.Maximum = e.MaxProgress;
            pb1.Value   = e.Progress;
            string str = e.Msg;

            if (!String.IsNullOrEmpty(e.Msg))
            {
                string name  = str.Substring(0, str.IndexOf(';'));
                string price = str.Substring(str.IndexOf(';') + 1, str.Length - str.IndexOf(';') - 1);
                var    lvi   = new ListViewItem();
                lvi.Text = name;

                lvi.SubItems.Add("$" + price);
                lvGames.Items.Add(lvi);
                lvGames.Items[lvGames.Items.Count - 1].EnsureVisible();
                this._sumPrice += double.Parse(price);
            }
            lblInfo.Text = "{0} / {1}".F(e.Progress, e.MaxProgress);
            lblSum.Text  = "Sum: ${0}".F(this._sumPrice);
            this.CenterLables(lblInfo);
            this.CenterLables(lblSum);
        }