//the actual part of the program that transforms the letters and put them into a string on screen private void DrawRansom() { //clearing the text from the Textbox RansomLetterBox.Text = null; //the loop making the text go random for (int i = 0; i < text.Length; i++) { //char that holds the text char kar = text[i]; //this part randomizes the font int next = randomSize.Next(0, 12); string font = fontType[next]; //this part randomizes the size int nextSize = randomSize.Next(0, 8); int fontGreat = fontSize[nextSize]; //this part randomizes the style through the if statements int nextStyle = randomSize.Next(0, 3); string fontStylish = fontStyle[nextStyle]; //the if statements changing the style and font and the size if (fontStyle[nextStyle] == fontStyle[0]) { //converting style size and font here RansomLetterBox.SelectionFont = new Font(font, fontGreat, FontStyle.Italic); //converting the color here RansomLetterBox.SelectionColor = FontColors[randomSize.Next(0, FontColors.Length)]; } else if (fontStyle[nextStyle] == fontStyle[1]) { //converting style size and font here RansomLetterBox.SelectionFont = new Font(font, fontGreat, FontStyle.Bold); //converting the color here RansomLetterBox.SelectionColor = FontColors[randomSize.Next(0, FontColors.Length)]; } else if (fontStyle[nextStyle] == fontStyle[2]) { //converting style size and font here RansomLetterBox.SelectionFont = new Font(font, fontGreat, FontStyle.Underline); //converting the color here RansomLetterBox.SelectionColor = FontColors[randomSize.Next(0, FontColors.Length)]; } //putting the chars out to the screen one by one RansomLetterBox.AppendText(kar.ToString()); } }
//this button shows a screen where the file can be saved (in any folder you like) //it facilitates the possibility to save private void btnSave_Click(object sender, EventArgs e) { //creating a variable for the SaveFileDialog and setting the format of the text file SaveFileDialog save = new SaveFileDialog(); save.DefaultExt = ".rtf"; save.Filter = "RTF Files | *.rtf"; try { //checks if the text is present. If not it goes to the exception if (save.ShowDialog() == DialogResult.OK && save.FileName.Length > 0) { RansomLetterBox.SaveFile(save.FileName); } } catch { MessageBox.Show("Geef me text om op te slaan!"); } }