public ResultWindow(IList <Vote> votes, Competition competition) { this.votes = votes; this.competition = competition; InitializeComponent(); CreatePlaceDataGrid(); CreateNominationDataGrid(); var teams = competition.Teams; List <ResultMark> resultMarks = new List <ResultMark>(); foreach (var team in teams) { var _votes = votes.Where(v => v.Team == team).ToList(); var resultMark = new ResultMark(team, _votes); resultMarks.Add(resultMark); } resultMarks.Sort(ResultMark.CompareResultMark); for (int i = 0; i < resultMarks.Count; i++) { resultMarks[i].Place = i + 1; } placeDataGrid.ItemsSource = resultMarks; var resultNominations = new List <ResultNomination>(); foreach (var nomination in competition.Nominations) { var resultNomination = new ResultNomination(nomination, votes); resultNominations.Add(resultNomination); } nominationsDataGrid.ItemsSource = resultNominations; }
public static int CompareResultMark(ResultMark x, ResultMark y) { if (x.AverageMark > y.AverageMark) { return(-1); } else if (x.AverageMark < y.AverageMark) { return(1); } else { return(0); } }
/// <summary> /// リストボックスに結果マーク込みで文字列を書き込む /// </summary> /// <param name="lstResult"></param> /// <param name="strLog"></param> /// <param name="resultmark"></param> public void WriteLstResult(ListBox lstResult, string strLog, ResultMark resultmark = ResultMark.InformationMark) { try { string strMark = ""; switch (resultmark) { case ResultMark.InformationMark: strMark = "○"; break; case ResultMark.DoingMark: strMark = "→"; break; case ResultMark.WarningMark: strMark = "△"; break; case ResultMark.ErrorMark: strMark = "×"; break; default: break; } //時間と文字列をリストボックスに表示 lstResult.Items.Add(strMark + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\t" + strLog); //リストボックスの最終行を選択 lstResult.SetSelected(lstResult.Items.Count - 1, true); Application.DoEvents(); } catch (Exception) { //エラーメッセージを表示 throw; } }