angličtina
c-sharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace WindowsFormsApplication4
{
public partial class Angličtina : Form
{
string[] polecz = new string[6];
string[] poleaj = new string[6];
Random random = new Random();
Stopwatch watch = new Stopwatch();
int cislo;
int dobre;
int spatne;
Boolean pokracovat = false;
public Angličtina()
{
InitializeComponent();
int randomC = random.Next(0, 5);
cislo = randomC;
}
private void Form1_Load(object sender, EventArgs e)
{
int randomC = random.Next(0, 5);
using (StreamReader reader = new StreamReader("Knihovna.txt"))
{
for (int i = 0; i <= 5; i += 1)
{
polecz[i] = reader.ReadLine();
}
}
using (StreamReader reader = new StreamReader("KnihovnaAJ.txt"))
{
for (int i = 0; i <= 5; i += 1)
{
poleaj[i] = reader.ReadLine();
}
}
dalsiCz();
}
public void dalsiCz()
{
pokracovat = true;
cislo = random.Next(0, 5);
label1.Text = polecz[cislo];
textBox1.Text = ("");
label2.Text = ("Dobře : "+ dobre);
label3.Text = ("Špatně : " + spatne);
}
public void button1_Click(object sender, EventArgs e)
{
overeni();
}
public void overeni()
{
if (textBox1.Text == poleaj[cislo])
{
pokracovat = false;
MessageBox.Show("Dobře");
dobre += 1;
dalsiCz();
label1.Text = polecz[cislo];
}
else
{
pokracovat = false;
MessageBox.Show(" Špatně\nSprávné slovo bylo: " + poleaj[cislo]);
spatne += 1;
dalsiCz();
label1.Text = polecz[cislo];
}
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (pokracovat == true)
{
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckKeys);
}
else { }
}
private void CheckKeys(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
button1.PerformClick();
}
}
private void Tick(object sender, EventArgs e)
{
pokracovat = true;
}
}
}
Neformátovaný
Přidáno: 22.6.2013
Expirace: Neuvedeno