Esempio n. 1
0
        private void GetAchievements()
        {
            this._IsUpdatingAchievementList = true;

            this._AchievementListView.Items.Clear();
            this._AchievementListView.BeginUpdate();
            //this.Achievements.Clear();

            foreach (var def in this._AchievementDefinitions)
            {
                if (string.IsNullOrEmpty(def.Id) == true)
                {
                    continue;
                }

                bool isAchieved;
                if (this._SteamClient.SteamUserStats.GetAchievementState(def.Id, out isAchieved) == false)
                {
                    continue;
                }

                var info = new Stats.AchievementInfo()
                {
                    Id          = def.Id,
                    IsAchieved  = isAchieved,
                    IconNormal  = string.IsNullOrEmpty(def.IconNormal) ? null : def.IconNormal,
                    IconLocked  = string.IsNullOrEmpty(def.IconLocked) ? def.IconNormal : def.IconLocked,
                    Permission  = def.Permission,
                    Name        = def.Name,
                    Description = def.Description,
                };

                var item = new ListViewItem()
                {
                    Checked   = isAchieved,
                    Tag       = info,
                    Text      = info.Name,
                    BackColor = (def.Permission & 3) == 0 ? Color.Black : Color.FromArgb(64, 0, 0),
                };

                info.Item = item;

                item.SubItems.Add(info.Description);

                info.ImageIndex = 0;

                this.AddAchievementToIconQueue(info, false);
                this._AchievementListView.Items.Add(item);
                //this.Achievements.Add(info.Id, info);
            }
            this._AchievementListView.EndUpdate();
            this._IsUpdatingAchievementList = false;

            this.DownloadNextIcon();
        }
 private void AddAchievementIcon(Stats.AchievementInfo info, Image icon)
 {
     if (icon == null)
     {
         info.ImageIndex = 0;
     }
     else
     {
         info.ImageIndex = this._AchievementImageList.Images.Count;
         this._AchievementImageList.Images.Add(info.IsAchieved == true ? info.IconNormal : info.IconLocked, icon);
     }
 }
        private void AddAchievementToIconQueue(Stats.AchievementInfo info, bool startDownload)
        {
            int imageIndex = this._AchievementImageList.Images.IndexOfKey(
                info.IsAchieved == true ? info.IconNormal : info.IconLocked);

            if (imageIndex >= 0)
            {
                info.ImageIndex = imageIndex;
            }
            else
            {
                this._IconQueue.Add(info);

                if (startDownload == true)
                {
                    this.DownloadNextIcon();
                }
            }
        }
Esempio n. 4
0
        private void GetAchievements()
        {
            _IsUpdatingAchievementList = true;

            _AchievementListView.Items.Clear();
            _AchievementListView.BeginUpdate();
            //this.Achievements.Clear();

            foreach (var def in _AchievementDefinitions)
            {
                if (string.IsNullOrEmpty(def.Id))
                {
                    continue;
                }

                if (_SteamClient.SteamUserStats.GetAchievementState(def.Id, out var isAchieved) == false)
                {
                    continue;
                }
                if (!IsMatchingSearchAndDisplaySettings(isAchieved, def.Name, def.Description))
                {
                    continue;
                }
                var info = new Stats.AchievementInfo()
                {
                    Id          = def.Id,
                    IsAchieved  = isAchieved,
                    IconNormal  = string.IsNullOrEmpty(def.IconNormal) ? null : def.IconNormal,
                    IconLocked  = string.IsNullOrEmpty(def.IconLocked) ? def.IconNormal : def.IconLocked,
                    Permission  = def.Permission,
                    Name        = def.Name,
                    Description = def.Description,
                };

                var item = new ListViewItem()
                {
                    Checked   = isAchieved,
                    Tag       = info,
                    Text      = info.Name,
                    BackColor = (def.Permission & 3) == 0 ? Color.Black : Color.FromArgb(64, 0, 0),
                };

                info.Item = item;

                if (item.Text.StartsWith("#", StringComparison.InvariantCulture))
                {
                    item.Text = info.Id;
                }
                else
                {
                    item.SubItems.Add(info.Description);
                }

                info.ImageIndex = 0;

                AddAchievementToIconQueue(info, false);
                _AchievementListView.Items.Add(item);
                //this.Achievements.Add(info.Id, info);
            }
            _AchievementListView.EndUpdate();
            _IsUpdatingAchievementList = false;

            DownloadNextIcon();
        }
Esempio n. 5
0
        private void searchData(string filterText)
        {
            this._IsUpdatingAchievementList = true;

            this._AchievementListView.Items.Clear();
            this._AchievementListView.BeginUpdate();
            //this.Achievements.Clear();

            foreach (var def in this._AchievementDefinitions)
            {
                if (string.IsNullOrEmpty(def.Id) == true)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(filterText) && !string.IsNullOrWhiteSpace(filterText))
                {
                    if (!def.Name.ToLower().Contains(filterText.ToLower()) && !def.Description.ToLower().Contains(filterText.ToLower()))
                    {
                        continue;
                    }
                }

                bool isAchieved;
                if (this._SteamClient.SteamUserStats.GetAchievementState(def.Id, out isAchieved) == false)
                {
                    continue;
                }

                var info = new Stats.AchievementInfo()
                {
                    Id          = def.Id,
                    IsAchieved  = isAchieved,
                    IconNormal  = string.IsNullOrEmpty(def.IconNormal) ? null : def.IconNormal,
                    IconLocked  = string.IsNullOrEmpty(def.IconLocked) ? def.IconNormal : def.IconLocked,
                    Permission  = def.Permission,
                    Name        = def.Name,
                    Description = def.Description,
                };

                var item = new ListViewItem()
                {
                    Checked   = isAchieved,
                    Tag       = info,
                    Text      = info.Name,
                    BackColor = (def.Permission & 3) == 0 ? Color.Black : Color.FromArgb(64, 0, 0),
                };

                info.Item = item;

                if (item.Text.StartsWith("#", StringComparison.InvariantCulture) == true)
                {
                    item.Text = info.Id;
                }
                else
                {
                    item.SubItems.Add(info.Description);
                }

                info.ImageIndex = 0;

                this.AddAchievementToIconQueue(info, false);
                this._AchievementListView.Items.Add(item);
                //this.Achievements.Add(info.Id, info);
            }

            this._AchievementListView.EndUpdate();
            this._IsUpdatingAchievementList = false;

            this.DownloadNextIcon();
        }