コード例 #1
0
            public IFilterValue?GetColumnValue(String columnName, int rowIndex)
            {
                IFilterValue?columnValue = null;

                int columnIndex = ColumnHeaders.IndexOf(columnName);

                if (columnIndex > -1 && rowIndex < Rows.Count)
                {
                    columnValue = Rows[rowIndex].GetColumn(columnName);
                }
                return(columnValue);
            }
コード例 #2
0
 private object[,] BuildDataArray()
 {
     try
     {
         int    columnNumber = 0;
         string cellValue    = null;
         for (int row = 0; row < DataRange.Rows.Count; row++)
         {
             for (int column = 0; column < DataRange.Columns.Count; column++)
             {
                 cellValue    = DataRange[row, column].ToString();
                 columnNumber = ColumnHeaders.IndexOf(cellValue);
                 DataArray[row, columnNumber] = cellValue;
             }
         }
         return(DataArray);
     }
     catch (Exception)
     {
         Console.WriteLine("Could not build the data array from the extracted range.");
         return(null);
     }
 }
コード例 #3
0
        private IQueryable <SkaterSeasonStat> SortBy(IQueryable <SkaterSeasonStat> stats, string column, bool sortDesc)
        {
            if (column == null)
            {
                column = "P";
            }

            IsSortDescending = sortDesc;

            IOrderedQueryable <SkaterSeasonStat> orderableStats;

            if (IsSortDescending)
            {
                switch (column)
                {
                case "GP": orderableStats = stats.OrderByDescending(s => s.GP); break;

                case "G": orderableStats = stats.OrderByDescending(s => s.G); break;

                case "A": orderableStats = stats.OrderByDescending(s => s.A); break;

                case "P": orderableStats = stats.OrderByDescending(s => s.P).ThenByDescending(s => s.G); break;

                case "PLMI": orderableStats = stats.OrderByDescending(s => s.PLMI); break;

                case "SHT": orderableStats = stats.OrderByDescending(s => s.SHT); break;

                case "SB": orderableStats = stats.OrderByDescending(s => s.SB); break;

                case "MP": orderableStats = stats.OrderByDescending(s => s.MP); break;

                case "PIM": orderableStats = stats.OrderByDescending(s => s.PIM); break;

                case "PM5": orderableStats = stats.OrderByDescending(s => s.PM5); break;

                case "HIT": orderableStats = stats.OrderByDescending(s => s.HIT); break;

                case "HTT": orderableStats = stats.OrderByDescending(s => s.HTT); break;

                case "PPG": orderableStats = stats.OrderByDescending(s => s.PPG); break;

                case "PPA": orderableStats = stats.OrderByDescending(s => s.PPA); break;

                case "PPP": orderableStats = stats.OrderByDescending(s => s.PPP); break;

                case "PPS": orderableStats = stats.OrderByDescending(s => s.PPS); break;

                case "PPM": orderableStats = stats.OrderByDescending(s => s.PPM); break;

                case "PKG": orderableStats = stats.OrderByDescending(s => s.PKG); break;

                case "PKA": orderableStats = stats.OrderByDescending(s => s.PKA); break;

                case "PKP": orderableStats = stats.OrderByDescending(s => s.PKP); break;

                case "PKS": orderableStats = stats.OrderByDescending(s => s.PKS); break;

                case "PKM": orderableStats = stats.OrderByDescending(s => s.PKM); break;

                case "GW": orderableStats = stats.OrderByDescending(s => s.GW); break;

                case "GT": orderableStats = stats.OrderByDescending(s => s.GT); break;

                case "EG": orderableStats = stats.OrderByDescending(s => s.EG); break;

                case "HT": orderableStats = stats.OrderByDescending(s => s.HT); break;

                case "FOW": orderableStats = stats.OrderByDescending(s => s.FOW); break;

                case "FOT": orderableStats = stats.OrderByDescending(s => s.FOT); break;

                case "PSG": orderableStats = stats.OrderByDescending(s => s.PSG); break;

                case "PSS": orderableStats = stats.OrderByDescending(s => s.PSS); break;

                case "FW": orderableStats = stats.OrderByDescending(s => s.FW); break;

                case "FL": orderableStats = stats.OrderByDescending(s => s.FL); break;

                case "FT": orderableStats = stats.OrderByDescending(s => s.FT); break;

                case "S1": orderableStats = stats.OrderByDescending(s => s.S1); break;

                case "S2": orderableStats = stats.OrderByDescending(s => s.S2); break;

                case "S3": orderableStats = stats.OrderByDescending(s => s.S3); break;

                default:
                {
                    AlertMessage = "Column does not exist.";
                    goto case "P";
                }
                }
            }
            else
            {
                switch (column)
                {
                case "GP": orderableStats = stats.OrderBy(s => s.GP); break;

                case "G": orderableStats = stats.OrderBy(s => s.G); break;

                case "A": orderableStats = stats.OrderBy(s => s.A); break;

                case "P": orderableStats = stats.OrderBy(s => s.P).ThenByDescending(s => s.G); break;

                case "PLMI": orderableStats = stats.OrderBy(s => s.PLMI); break;

                case "SHT": orderableStats = stats.OrderBy(s => s.SHT); break;

                case "SB": orderableStats = stats.OrderBy(s => s.SB); break;

                case "MP": orderableStats = stats.OrderBy(s => s.MP); break;

                case "PIM": orderableStats = stats.OrderBy(s => s.PIM); break;

                case "PM5": orderableStats = stats.OrderBy(s => s.PM5); break;

                case "HIT": orderableStats = stats.OrderBy(s => s.HIT); break;

                case "HTT": orderableStats = stats.OrderBy(s => s.HTT); break;

                case "PPG": orderableStats = stats.OrderBy(s => s.PPG); break;

                case "PPA": orderableStats = stats.OrderBy(s => s.PPA); break;

                case "PPP": orderableStats = stats.OrderBy(s => s.PPP); break;

                case "PPS": orderableStats = stats.OrderBy(s => s.PPS); break;

                case "PPM": orderableStats = stats.OrderBy(s => s.PPM); break;

                case "PKG": orderableStats = stats.OrderBy(s => s.PKG); break;

                case "PKA": orderableStats = stats.OrderBy(s => s.PKA); break;

                case "PKP": orderableStats = stats.OrderBy(s => s.PKP); break;

                case "PKS": orderableStats = stats.OrderBy(s => s.PKS); break;

                case "PKM": orderableStats = stats.OrderBy(s => s.PKM); break;

                case "GW": orderableStats = stats.OrderBy(s => s.GW); break;

                case "GT": orderableStats = stats.OrderBy(s => s.GT); break;

                case "EG": orderableStats = stats.OrderBy(s => s.EG); break;

                case "HT": orderableStats = stats.OrderBy(s => s.HT); break;

                case "FOW": orderableStats = stats.OrderBy(s => s.FOW); break;

                case "FOT": orderableStats = stats.OrderBy(s => s.FOT); break;

                case "PSG": orderableStats = stats.OrderBy(s => s.PSG); break;

                case "PSS": orderableStats = stats.OrderBy(s => s.PSS); break;

                case "FW": orderableStats = stats.OrderBy(s => s.FW); break;

                case "FL": orderableStats = stats.OrderBy(s => s.FL); break;

                case "FT": orderableStats = stats.OrderBy(s => s.FT); break;

                case "S1": orderableStats = stats.OrderBy(s => s.S1); break;

                case "S2": orderableStats = stats.OrderBy(s => s.S2); break;

                case "S3": orderableStats = stats.OrderBy(s => s.S3); break;

                default:
                {
                    AlertMessage = "Column does not exist.";
                    goto case "P";
                }
                }
            }

            SelectedColumnSort = column;

            var matchedColumn = ColumnHeaders.Where(a => a.Name == column).FirstOrDefault();

            SelectedColumnSortIndex = ColumnHeaders.IndexOf(matchedColumn);

            if (column == "MP")
            {
                return(orderableStats);
            }

            return((IsSortDescending) ?
                   orderableStats.ThenBy(s => s.MP) :
                   orderableStats.ThenByDescending(s => s.MP));
        }
コード例 #4
0
        private IQueryable <GoalieSeasonStat> SortBy(IQueryable <GoalieSeasonStat> stats, string column, bool sortDesc)
        {
            if (column == null)
            {
                column = "W";
            }

            IsSortDescending = sortDesc;

            IOrderedQueryable <GoalieSeasonStat> orderableStats;

            if (IsSortDescending)
            {
                switch (column)
                {
                case "GP": orderableStats = stats.OrderByDescending(s => s.GP); break;

                case "W": orderableStats = stats.OrderByDescending(s => s.W); break;

                case "L": orderableStats = stats.OrderByDescending(s => s.L); break;

                case "OTL": orderableStats = stats.OrderByDescending(s => s.OTL); break;

                case "MP": orderableStats = stats.OrderByDescending(s => s.MP); break;

                case "PIM": orderableStats = stats.OrderByDescending(s => s.PIM); break;

                case "SO": orderableStats = stats.OrderByDescending(s => s.SO); break;

                case "A": orderableStats = stats.OrderByDescending(s => s.A); break;

                case "EG": orderableStats = stats.OrderByDescending(s => s.EG); break;

                case "GA": orderableStats = stats.OrderByDescending(s => s.GA); break;

                case "SA": orderableStats = stats.OrderByDescending(s => s.SA); break;

                case "PSS": orderableStats = stats.OrderByDescending(s => s.PSS); break;

                case "PSA": orderableStats = stats.OrderByDescending(s => s.PSA); break;

                case "ST": orderableStats = stats.OrderByDescending(s => s.ST); break;

                case "BG": orderableStats = stats.OrderByDescending(s => s.BG); break;

                case "S1": orderableStats = stats.OrderByDescending(s => s.S1); break;

                case "S2": orderableStats = stats.OrderByDescending(s => s.S2); break;

                case "S3": orderableStats = stats.OrderByDescending(s => s.S3); break;

                default:
                {
                    AlertMessage = "Column does not exist.";
                    goto case "W";
                }
                }
            }
            else
            {
                switch (column)
                {
                case "GP": orderableStats = stats.OrderBy(s => s.GP); break;

                case "W": orderableStats = stats.OrderBy(s => s.W); break;

                case "L": orderableStats = stats.OrderBy(s => s.L); break;

                case "OTL": orderableStats = stats.OrderBy(s => s.OTL); break;

                case "MP": orderableStats = stats.OrderBy(s => s.MP); break;

                case "PIM": orderableStats = stats.OrderBy(s => s.PIM); break;

                case "SO": orderableStats = stats.OrderBy(s => s.SO); break;

                case "A": orderableStats = stats.OrderBy(s => s.A); break;

                case "EG": orderableStats = stats.OrderBy(s => s.EG); break;

                case "GA": orderableStats = stats.OrderBy(s => s.GA); break;

                case "SA": orderableStats = stats.OrderBy(s => s.SA); break;

                case "PSS": orderableStats = stats.OrderBy(s => s.PSS); break;

                case "PSA": orderableStats = stats.OrderBy(s => s.PSA); break;

                case "ST": orderableStats = stats.OrderBy(s => s.ST); break;

                case "BG": orderableStats = stats.OrderBy(s => s.BG); break;

                case "S1": orderableStats = stats.OrderBy(s => s.S1); break;

                case "S2": orderableStats = stats.OrderBy(s => s.S2); break;

                case "S3": orderableStats = stats.OrderBy(s => s.S3); break;

                default:
                {
                    AlertMessage = "Column does not exist.";
                    goto case "W";
                }
                }
            }

            SelectedColumnSort = column;

            var matchedColumn = ColumnHeaders.Where(a => a.Name == column).FirstOrDefault();

            SelectedColumnSortIndex = ColumnHeaders.IndexOf(matchedColumn);

            if (column == "MP")
            {
                return(orderableStats);
            }

            return((IsSortDescending) ?
                   orderableStats.ThenBy(s => s.MP) :
                   orderableStats.ThenByDescending(s => s.MP));
        }