private void TieTable_Load(object sender, EventArgs e) { List <Member> list = MainForm.Instance.Manager.QueryMember(""); List <History> list2 = MainForm.Instance.Manager.QueryHistory(""); SwissTournamentRound round = new SwissTournamentRound(); int index = 0; while (true) { if (index >= list2.Count) { foreach (Member member in list) { round.InsertPlayer(member.Id); } foreach (History history in list2) { round.InsertRoundResult(history.Player1, history.Player2, history.Status, this.round); } round.Sort(); Dictionary <int, Tuple <int, int, int, int> > tScore = round.GetTScore(); round.rank.ForEach(r => { string[] items = new string[] { (r.Value + 1).ToString(), (from x in list where x.Id == r.Key select x).First <Member>().Name, r.Key.ToString(), tScore[r.Key].Item1.ToString(), tScore[r.Key].Item2.ToString(), tScore[r.Key].Item3.ToString(), tScore[r.Key].Item4.ToString() }; this.lvTTable.Items.Add(new ListViewItem(items)); }); //using (List<KeyValuePair<int, int>>.Enumerator enumerator3 = round.rank.GetEnumerator()) //{ // while (enumerator3.MoveNext()) // { // KeyValuePair<int, int> r; // string[] items = new string[] { (r.Value + 1).ToString(), (from x in list // where x.Id == r.Key // select x).First<Member>().Name, r.Key.ToString(), tScore[r.Key].Item1.ToString(), tScore[r.Key].Item2.ToString(), tScore[r.Key].Item3.ToString(), tScore[r.Key].Item4.ToString() }; // this.lvTTable.Items.Add(new ListViewItem(items)); // } //} ColumnSorter.InitListView(this.lvTTable); return; } if (list2[index].Round > this.round) { index--; list2.RemoveAt(index); } index++; } }
private List<Member> GetTieTableInfo(int round) { var list = Manager.QueryMember(""); var list2 = Manager.QueryHistory("round=" + round); var str = new SwissTournamentRound(); foreach (Member member in list) str.InsertPlayer(member.Id); foreach (History history in list2) str.InsertRoundResult(history.Player1, history.Player2, history.Status, round); str.Sort(); var result = new List<Member>(); var ppindex = new Dictionary<int, Member>(); list.ForEach(x => ppindex.Add(x.Id, x)); str.rank.ForEach(pp => result.Add(ppindex[pp.Key])); return result; }