Пример #1
0
 public string[] GetWords(BingoSettings settings)
 {
     var words = settings.WordList.TakeRandom(25).ToArray();
     words.Shuffle();
     words[12] = settings.FreeText;
     return words;
 }
Пример #2
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            var settings = new BingoSettings();

            settings.Fonts = Fonts.Select(f => new SelectListItem() { Text = f, Value = f });

            return View(settings);
        }
Пример #3
0
        public string GetWordListPage(BingoSettings settings)
        {
            var words = new StringBuilder();

            foreach (var word in settings.WordList.OrderBy(w => w))
            {
                words.AppendFormat("<li class='word'>{0}</li>", word);
            }

            return string.Format(WordListPage, words.ToString());
        }
Пример #4
0
 public string GetSingleCardHtml(BingoSettings settings)
 {
     string rows = string.Empty;
     var words = GetWords(settings);
     for (int i = 0; i < 25; i++)
     {
         if (i % 5 == 0) rows += "<tr>";
         rows += "<td>" + words[i] + "</td>";
         if (i % 5 == 4) rows += "</tr>";
     }
     return string.Format(HtmlCard, settings.Title, settings.Subtitle, rows);
 }
Пример #5
0
        public ActionResult Index(BingoSettings settings)
        {
            settings.WordList = settings.WordListBlob.Split(new[] { '\r', '\n', ',', ';' }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.Trim()).ToArray();

            while (settings.WordList.Length < 25)
            {
                settings.WordList = settings.WordList.Concat(settings.WordList).ToArray();
            }

            var pageCount = settings.CardCount / 4;
            var pages = new StringBuilder();
            for (int i = 0; i < pageCount; i++)
            {
                pages.Append(string.Format(HtmlPage, GetSingleCardHtml(settings), GetSingleCardHtml(settings), GetSingleCardHtml(settings), GetSingleCardHtml(settings)));
            }
            var wordListPage = GetWordListPage(settings);
            return View(new RenderModel { Font = settings.Font, WordListHtml = new HtmlString(wordListPage), CardsHtml = new HtmlString(pages.ToString()) });
        }