Ejemplo n.º 1
0
        private Dictionary <int, Dictionary <string, double> > CalculateScoreOfEachPlayerInEachRound(bool orderByWeight = true)
        {
            var dicResult         = new Dictionary <int, Dictionary <string, double> >();
            int sortByColumnIndex = orderByWeight ? 8 : 9;
            int absenseScore      = SharedData.PlayersCountInEachSubArea + 1;

            for (int round = 1; round <= SharedData.TotalRounds; round++)
            {
                var dicScoresInArea = new Dictionary <string, double>();
                for (int area = 1; area <= SharedData.TotalAreas; area++)
                {
                    IList <DataRow> half1 = SharedData.GetScoreDatarowsOfCertainSubArea(round, area, true);
                    this.AddScoresInSubAreaToArea(dicScoresInArea, half1, sortByColumnIndex);

                    IList <DataRow> half2 = SharedData.GetScoreDatarowsOfCertainSubArea(round, area, false);
                    this.AddScoresInSubAreaToArea(dicScoresInArea, half2, sortByColumnIndex);
                }
                foreach (string absenseName in SharedData.AllPlayersNames.Except(dicScoresInArea.Select(x => x.Key)))
                {
                    dicScoresInArea.Add(absenseName, absenseScore);
                }
                dicResult.Add(round, dicScoresInArea);
            }

            return(dicResult);
        }
Ejemplo n.º 2
0
        private void GetSelectedSubAreaDataRowsAndToListView()
        {
            int round   = Convert.ToInt32(this.cboRound.Text);
            int area    = Convert.ToInt32(this.cboArea.Text);
            int subArea = Convert.ToInt32(this.cboSubArea.Text);

            this.currentSubAreaDataRows = SharedData.GetScoreDatarowsOfCertainSubArea(round, area, subArea == 1);
            SharedData.ShowDataRowsToListView(this.listView1, this.currentSubAreaDataRows);
        }
Ejemplo n.º 3
0
        private void DisplayAllPlayersScores(Dictionary <int, Dictionary <string, double> > dicResult, bool orderByWeight = true)
        {
            for (int rowIndex = 0; rowIndex < SharedData.AllUniquePlayersInfo.Count; rowIndex++)
            {
                DataRow PlayerTotalScoresRow = this.UniquePlayersScoresDataTable.Rows[rowIndex];
                string  playerName           = PlayerTotalScoresRow[2].ToString();

                int sortByColumnIndex = orderByWeight ? 8 : 9;
                for (int colIndex = 4; colIndex < this.UniquePlayersScoresDataTable.Columns.Count - 1; colIndex++)
                {
                    string colName = this.UniquePlayersScoresDataTable.Columns[colIndex].ColumnName;
                    int    round   = -1;

                    if (colName.Contains("得分"))
                    {
                        round = Convert.ToInt32(string.Join("", colName.Where(x => char.IsDigit(x))));
                        PlayerTotalScoresRow[colIndex] = dicResult[round][playerName];
                    }
                    else if (colName.Contains("重量"))
                    {
                        round = Convert.ToInt32(string.Join("", colName.Where(x => char.IsDigit(x))));
                        DataRow player = SharedData.GetScoreDatarowsOfCertainSubArea(round, null, null).FirstOrDefault(x => x[0].ToString() == playerName);

                        if (player == null)
                        {
                            PlayerTotalScoresRow[colIndex] = "0";
                        }
                        else
                        {
                            PlayerTotalScoresRow[colIndex] = player[sortByColumnIndex].ToString();
                        }
                    }

                    else if (colName.Contains("尾数"))
                    {
                        round = Convert.ToInt32(string.Join("", colName.Where(x => char.IsDigit(x))));
                        DataRow player = SharedData.GetScoreDatarowsOfCertainSubArea(round, null, null).FirstOrDefault(x => x[0].ToString() == playerName);

                        if (player == null)
                        {
                            PlayerTotalScoresRow[colIndex] = "0";
                        }
                        else
                        {
                            PlayerTotalScoresRow[colIndex] = player[sortByColumnIndex].ToString();
                        }
                    }
                }
                PlayerTotalScoresRow[this.UniquePlayersScoresDataTable.Columns.Count - 1] = this.CalculateTotalScoreForEachPlayer(dicResult, playerName).ToString();
            }
        }