private void button3_Click(object sender, EventArgs e) { string[] randomText = Resources.ResourceManager.GetObject("LoremIpsum").ToString().Split('.'); List <CustomMessageBoxButton> buttons = new List <CustomMessageBoxButton>(); for (int j = 0; j < 10; j++) { string textValue = StaticRandomizer.RandomInt(0, 10) > 6 ? randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)] : ""; buttons.Clear(); int buttonCount = StaticRandomizer.RandomInt(1, 5); for (int i = 0; i < buttonCount; i++) { buttons.Add(new CustomMessageBoxButton(CustomButtonResult.Button1, randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)].Trim().Split(' ').FirstOrDefault())); } using (InputTextBox customMessageBox = new InputTextBox(textValue, randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)], "CustomMessageBox Demo", buttons.ToArray(), StaticRandomizer.RandomInt(1, buttonCount)) { StartPosition = FormStartPosition.CenterParent }) { customMessageBox.VerificationText = StaticRandomizer.RandomInt(0, 10) > 6 ? randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)] : ""; customMessageBox.ShowDialog(); } } }
private async Task IoTClientTest(string iotHubConnectionString, JObject payload, int clientCount, int messageCount, int messageDelaySeconds, bool randomize) { Random rnd = new Random(); string devicePrefix = "Device" + rnd.Next().ToString() + "-"; // assuming the string looks like "HostName={hubName}.azure-devices.net;SharedAccessKeyName={keyName};SharedAccessKey={key}" string iotHub = iotHubConnectionString.Split(";")[0].Split("=")[1]; createDevices(iotHubConnectionString, devicePrefix, clientCount, commonKey).ToString(); for (int sendCounter = 1; sendCounter <= clientCount; sendCounter++) { await Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(StaticRandomizer.Next(0, 3) * 1000); sendMessage(devicePrefix + sendCounter, commonKey, iotHub, messageCount, payload, messageDelaySeconds, randomize).Wait(); }, TaskCreationOptions.LongRunning); } deleteDevice(iotHubConnectionString, devicePrefix, clientCount).Wait(); }
public RecentlyUsedCharacterEntry() { Random rn = StaticRandomizer.GetStaticRandom(); int colorInt = rn.Next(0, 72); LeftColor = GetColorFromStandardColorsByInt(colorInt); RightColor = GetComplementaryColor(LeftColor); }
private void button2_Click(object sender, EventArgs e) { string[] randomText = Resources.ResourceManager.GetObject("LoremIpsum").ToString().Split('.'); List <string> newContent = new List <string>(); List <CustomMessageBoxButton> buttons = new List <CustomMessageBoxButton>(); for (int j = 0; j < 10; j++) { newContent.Clear(); int lineCount = StaticRandomizer.RandomInt(0, 10) > 4 ? StaticRandomizer.RandomInt(1, 6) : 1; for (int i = 0; i < lineCount; i++) { newContent.Add(randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)].Trim() + "."); } if (StaticRandomizer.RandomInt(0, 10) < 7) { using (CustomMessageBox customMessageBox = new CustomMessageBox(string.Join(Environment.NewLine, newContent), StaticRandomizer.RandomInt(0, 10) > 3 ? "Lorem Ipsum Title" : "", "CustomMessageBox Demo", (MessageBoxIcon)(16 * StaticRandomizer.RandomInt(0, 4)), (MessageBoxButtons)StaticRandomizer.RandomInt(0, 5), MessageBoxDefaultButton.Button1) { StartPosition = FormStartPosition.CenterParent }) { customMessageBox.VerificationText = StaticRandomizer.RandomInt(0, 10) > 6 ? randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)].Trim() : ""; customMessageBox.ShowDialog(); } } else { buttons.Clear(); int buttonCount = StaticRandomizer.RandomInt(1, 5); for (int i = 0; i < buttonCount; i++) { buttons.Add(new CustomMessageBoxButton(CustomButtonResult.Button1, randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)].Trim().Split(' ').FirstOrDefault())); } using (CustomMessageBox customMessageBox = new CustomMessageBox(string.Join(Environment.NewLine, newContent), StaticRandomizer.RandomInt(0, 10) > 3 ? "Lorem Ipsum Title" : "", "CustomMessageBox Demo", SystemIcons.Information.ToBitmap(), buttons.ToArray(), StaticRandomizer.RandomInt(1, buttonCount)) { StartPosition = FormStartPosition.CenterParent }) { customMessageBox.VerificationText = StaticRandomizer.RandomInt(0, 10) > 6 ? randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)] : ""; customMessageBox.ShowDialog(); } } } }
private void button1_Click(object sender, EventArgs e) { string[] randomText = Resources.ResourceManager.GetObject("LoremIpsum").ToString().Split('.'); List <string> newContent = new List <string>(); for (int j = 0; j < 10; j++) { newContent.Clear(); int lineCount = StaticRandomizer.RandomInt(0, 10) > 4 ? StaticRandomizer.RandomInt(1, 6) : 1; for (int i = 0; i < lineCount; i++) { newContent.Add(randomText[StaticRandomizer.RandomInt(0, randomText.Length - 1)].Trim() + "."); } MessageBox.Show(string.Join(Environment.NewLine, newContent), "StandartMessageBox Demo", (MessageBoxButtons)StaticRandomizer.RandomInt(0, 5), (MessageBoxIcon)(16 * StaticRandomizer.RandomInt(0, 4)), MessageBoxDefaultButton.Button1); } }
public async Task <ActionResult> Index() { var viewModel = new QuoteAndAuthorAnswersDTO(); QuoteDTO randomQuote = await this.quotesService.GetRandomQuote(); viewModel.Quote = randomQuote; var authorAnswers = new List <string>(); viewModel.QuizModeType = await this.modesService.GetSelectedMode(); if (viewModel.QuizModeType == QuizModeType.Binary) { var randomAuthor = await this.authorsService.GetRandomAuthor(); authorAnswers.Add(randomAuthor.Name); } else { while (authorAnswers.Count < GlobalConstants.MultipleChoiceModeDefaultAuthorsCount) { var randomAuthor = await this.authorsService.GetRandomAuthor(); if (authorAnswers.Contains(randomAuthor.Name)) { continue; } authorAnswers.Add(randomAuthor.Name); } if (!authorAnswers.Contains(randomQuote.Author)) { int randomPosition = StaticRandomizer.RandomNumber(0, GlobalConstants.MultipleChoiceModeDefaultAuthorsCount); authorAnswers[randomPosition] = randomQuote.Author; } } viewModel.AuthorAnswers = authorAnswers; return(this.View(viewModel)); }
public async Task <AuthorDTO> GetRandomAuthor() { int authorsCount = this.authorsRepository.GetAll().Count(); if (authorsCount == 0) { throw new UnpopulatedDbException( "No authors in the database. Please populate db with authors first."); } int randomAuthorId = StaticRandomizer.RandomNumber(1, authorsCount + 1); var randomAuthor = await this.authorsRepository .GetAll() .Where(x => x.Id == randomAuthorId) .Select(AuthorDTO.MapToDTO) .FirstOrDefaultAsync(); return(randomAuthor); }
public async Task <QuoteDTO> GetRandomQuote() { int quotesCount = this.quotesRepository.GetAll().Count(); if (quotesCount == 0) { throw new UnpopulatedDbException( "No quotes in the database. Please populate db with quotes first."); } int randomQuoteId = StaticRandomizer.RandomNumber(1, quotesCount + 1); var randomQuote = await this.quotesRepository .GetAll() .Include(x => x.Author) .Where(x => x.Id == randomQuoteId) .Select(QuoteDTO.MapToDTO) .FirstOrDefaultAsync(); return(randomQuote); }