Exemple #1
0
        /// <summary>
        /// 随机选择单元格
        /// </summary>
        /// <param name="howMany"></param>
        /// <returns></returns>
        public IEnumerable <CardCell> PickRandomCells(int howMany)
        {
            var r = new Random();

            for (int i = 0; i < howMany; i++)
            {
                var randomCol = r.Next(0, Columns);
                var randomRow = r.Next(0, Rows);
                var c         = new CardCell(randomRow, randomCol);
                yield return(c);
            }
        }
Exemple #2
0
 /// <summary>
 /// 使用指定的数组填充单元格
 /// </summary>
 /// <param name="array"></param>
 public void FillCellData(int[,] array)
 {
     Cells.Clear();
     if (array.GetLength(0) < Rows || array.GetLength(1) < Columns)
     {
         throw new ArgumentException($"{nameof(array)}长度小于密保卡要求行数或列数");
     }
     for (int row = 0; row < Rows; row++)
     {
         for (int col = 0; col < Columns; col++)
         {
             var cell = new CardCell(row, col, array[row, col]);
             Cells.Add(cell);
         }
     }
 }