- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public int minutes;
- public int seconds;
- public Form1()
- {
- InitializeComponent();
- }
- List<string> verbs = new List<string>();
- List<string> ponies = new List<string>();
- List<string> nouns = new List<string>();
- private void Form1_Load_1(object sender, EventArgs e)
- {
- string[] buffer;
- string[] buffer2;
- buffer = System.IO.File.ReadAllLines(".\\Verbs.csv");
- foreach (string line in buffer)
- {
- buffer2 = line.Split(',');
- foreach (string item in buffer2)
- {
- verbs.Add(item);
- }
- }
- buffer = System.IO.File.ReadAllLines(".\\Ponies.csv");
- foreach (string line in buffer)
- {
- buffer2 = line.Split(',');
- foreach (string item in buffer2)
- {
- ponies.Add(item);
- }
- }
- buffer = System.IO.File.ReadAllLines(".\\Nouns.csv");
- foreach (string line in buffer)
- {
- buffer2 = line.Split(',');
- foreach (string item in buffer2)
- {
- nouns.Add(item);
- }
- }
- }
- private void poniesButton_Click(object sender, EventArgs e)
- {
- if (verbs.Count < 1 || ponies.Count < 1 || nouns.Count < 1)
- {
- boxponiesText.Text = "Error loading dictionary files...";
- return;
- }
- Random rnd = new Random();
- string verb = verbs[rnd.Next(verbs.Count - 1)];
- string pony = ponies[rnd.Next(ponies.Count - 1)];
- string noun = nouns[rnd.Next(nouns.Count - 1)];
- string sentence = pony + " " + verb + " " + noun;
- boxponiesText.Text = sentence;
- if (minTxt.Text != "")
- {
- timer1.Enabled = true;
- try
- {
- minutes = System.Convert.ToInt32(minTxt.Text);
- seconds = System.Convert.ToInt32("00");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- else
- {
- MessageBox.Show("I need some time!");
- }
- }
- private void timer1_Tick_1(object sender, EventArgs e)
- {
- {
- // Verify if the time didn't pass.
- if (minutes == 0)
- {
- // If the time is over, clear all settings and fields.
- // Also, show the message, notifying that the time is over.
- lblMin.Text = "00";
- if (seconds == 0)
- {
- System.Threading.Thread.Sleep(500);
- timer1.Enabled = false;
- System.Media.SystemSounds.Asterisk.Play();
- MessageBox.Show(" Hey everypony times up, Show your art.");
- }
- }
- else
- {
- // Else continue counting.
- if (seconds < 1)
- {
- seconds = 59;
- if (minutes == 0)
- {
- minutes = 59;
- }
- else
- {
- minutes -= 1;
- }
- }
- else
- seconds -= 1;
- // Display the current values of hours, minutes and seconds in
- // the corresponding fields.
- lblMin.Text = minutes.ToString();
- lblSec.Text = seconds.ToString();
- }
- }
- }
- }
- }