private void Filter() { PostedList.Clear(); foreach (Auction a in actualPostedList) { if (a.Name.ToLower().Contains(FilterWord.ToLower())) { PostedList.Add(a); } } }
private void SortBy(string arg) { arg = arg.ToLower(); List <Auction> temp = PostedList.ToList <Auction>(); if (arg.ToLower() == "name") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.Name.CompareTo(a2.Name)); }); sorted[arg] = true; } } if (arg.ToLower() == "timeleft") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.TimeLeft.CompareTo(a2.TimeLeft)); }); sorted[arg] = true; } } if (arg.ToLower() == "bid") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.Bid.CompareTo(a2.Bid)); }); sorted[arg] = true; } } if (arg.ToLower() == "buyout") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.Buyout.CompareTo(a2.Buyout)); }); sorted[arg] = true; } } if (arg.ToLower() == "seller") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.SellerName.CompareTo(a2.SellerName)); }); sorted[arg] = true; } } if (arg.ToLower() == "amount") { if (sorted[arg]) { temp.Reverse(); sorted[arg] = false; } else { temp.Sort(delegate(Auction a1, Auction a2) { return(a1.Amount.CompareTo(a2.Amount)); }); sorted[arg] = true; } } FixDic(arg); PostedList.Clear(); foreach (Auction a in temp) { PostedList.Add(a); } }