public void SortChampions() { #if DEBUG Log.Info("Sort champions."); #endif SortedChampions = Champions.Data.Values; if (!string.IsNullOrEmpty(SortChampionName)) { SortedChampions = SortedChampions.Where(s => s.Name.IndexOf(SortChampionName, StringComparison.OrdinalIgnoreCase) > -1); } var tag = ChampionTags.FirstOrDefault(s => s.IsChecked == true); if (tag != null) { if (!string.IsNullOrEmpty(tag.Tag)) { SortedChampions = SortedChampions.Where(s => s.Tags.Contains(tag.Tag)); } } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SortedChampions")); }
public bool UpdateChampionControl() { bool success = false; flowLayoutPanelItems2.SuspendLayout(); if (flowLayoutPanelItems2.Controls.Count > 0) { List <Control> ctrls = flowLayoutPanelItems2.Controls.Cast <Control>().ToList(); flowLayoutPanelItems2.Controls.Clear(); foreach (Control c in ctrls) { c.Dispose(); } } try { foreach (KeyValuePair <string, ChampionStatic> champ in getChampionsFromServer.championsOrder) { string version = getChampionsFromServer.version; string file = string.Format(@"{0}\Data\Champions\Images\{1}\{2}", PublicStaticVariables.thisAppDataDir, version, champ.Value.Image.Sprite); string dir = string.Format(@"{0}\Data\Champions\Images", PublicStaticVariables.thisAppDataDir); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Image imageItem = Image.FromFile(file); //Creating this control is actually pretty quick ChampionControl championControl = new ChampionControl(form, champ); Image image = CommonMethods.cropImage(imageItem, new Rectangle(champ.Value.Image.X, champ.Value.Image.Y, champ.Value.Image.Width, champ.Value.Image.Height)); championControl.ChampImage = image; championControl.Name = "ItemControl " + champ.Value.Name; championControl.ChampLabel = champ.Value.Name; //championControl.item = champ; ChampionTags champTags = new ChampionTags(); List <string> temp = new List <string>(); if (champ.Value.Partype == ParTypeStatic.Mana) { temp.Add("Mana"); } else { temp.Add("Other"); } if (champ.Value.Tags == null) { temp.Add("noTag"); //championControl.Tag = temp; } else { foreach (TagStatic t in champ.Value.Tags) { temp.Add(t.ToString()); } //championControl.Tag = temp; } champTags.Tags = temp; champTags.ChampionName = champ.Value.Name; championControl.Tag = champTags; flowLayoutPanelItems2.Controls.Add(championControl); } success = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); success = false; } flowLayoutPanelItems2.ResumeLayout(); return(success); }