Skip to content

Instantly share code, notes, and snippets.

@kosir35
Created June 28, 2016 08:03
Show Gist options
  • Save kosir35/6c06c109e9bfac9ba1cafe3250efc042 to your computer and use it in GitHub Desktop.
Save kosir35/6c06c109e9bfac9ba1cafe3250efc042 to your computer and use it in GitHub Desktop.
Typing test 1.o
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.Threading;
namespace Typing1._0
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region TEXTS
static string text = "Hello all, Today we will be testing your ability to type fast and accurate within this small little test I have compiled together"; //Hopefully you will be able to manipulate the movement in your hands to type these keys at an incredible pace and keep up with the average amount by all users, and for that I wish you the best of luck, now lets begin How about an obligatory all letters used sentence? The quick brown fox jumps over the lazy cow, because dogs are for losers. How about we test your methods in typing number in sentences? For example, 74% of statistics are made up on the spot, I got this in an email from [email protected]. Hopefully you are now getting used to things, how about we create you a lovely story I wrote. Using all the skills we just learned! A A letter to my dearest and deceased Father Dear Father, I hope Heaven is treating you well, it is all cold and lonely down her now that you have passed away from me. The Jefferson's from next door have moved to 76 Acre St. and some new family has moved in from the Czech Republic. Hopefully they greet us with the kindness you showed us when we were kids. I miss you every day and hope that you come back to me, so that you can tell me your old war stories or give me lessons about what you regretted in life. I checked your email ([email protected]) and cancelled your subscriptions, so hopefulyl there isn't an issue with the 1000's of dollars you left us - $7892 to be exact - getting slowly drained from us. I miss you very much, all of us do. Love Jessica (A loving Daughter to James Eddington) See, that wasn't hard now was it? Lets see how you did finish this test type the word Eggplant. Eggplant.";
static string text1 = "took soon below people you this in oil far don't water quick just line old her tell those few does big study something live mile help must high mean young look learn food there follow America large year like some were was carry from began example";
static Random random = new Random();
public static string[] _besede = text.Split(' ');
#endregion
static int text_lenght;
int kertext = random.Next(4);
public static char[] crke1 = text.ToCharArray();
private void Form1_Load(object sender, EventArgs e)
{
string result1 = ConvertStringArrayToString(_besede);
prvitext = true;
typing_text.Text = text;
timer1_label.Text = i.ToString();
}
static public int j;
static string ConvertStringArrayToString(string[] _besede)
{
StringBuilder builder = new StringBuilder();
foreach ( string value in _besede)
{
builder.Append(value);
builder.Append(' ');
}
return builder.ToString();
}
int z = 0;
int crke = 0;
double time;
double _rechnung;
int znaki = 0;
int kok_crk = text.Length;
//This is where all the magic happens
private void _typing_KeyPress(object sender, KeyPressEventArgs e)
{
label8.Text = znaki.ToString();
if(znaki < kok_crk)
{
if (e.KeyChar == crke1[znaki])
{
_typing.ForeColor = Color.ForestGreen;
znaki++;
}
else
{
_typing.ForeColor = Color.Red;
}
}
if ( _typing.Text != "")
{
timer1.Enabled = true;
}
if (i > 0)
{
time = i;
_rechnung = crke / 5 / time * 60;
//double result = Convert.ToInt32(_rechnung);
label3.Text = _rechnung.ToString();
}
if (e.KeyChar == (char)Keys.Enter)
{
restartbutton.PerformClick();
}
text_lenght = text.Split().Length;
if (prvitext == true)
{
_besede = text.Split(' ');
}
if (eztext == true)
{
_besede = text1.Split(' ');
text_lenght = text1.Split().Length;
}
#region Checking algorithm
if (e.KeyChar == (char)Keys.Space)
{
if (_typing.Text == _besede[z])
{
crke += _typing.TextLength;
crke++;
_typing.Text = "";
e.KeyChar = (char)Keys.Back;
z++;
label2.Text = z.ToString();
label1.Text = crke.ToString();
}
else
{
napake++;
}
if (z == text_lenght)
{
timer1.Enabled = false;
if (z == text_lenght)
{
time = i;
_rechnung = crke / 5 / time * 60 - napake;
label3.Text = _rechnung.ToString();
MessageBox.Show("You are typing with the speed of " + _rechnung.ToString() + " You have also made some mistakes: " + napake.ToString(), "Your WPM");
}
}
#endregion
mistakes.Text = napake.ToString();
}
}
int napake;
int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
i++;
timer1_label.Text = i.ToString();
}
//Restart button
private void button1_Click(object sender, EventArgs e)
{
prvitext = false;
znaki = 0;
eztext = false;
_typing.Text = "";
napake = 0;
timer1.Enabled = false;
i = 0;
z = 0;
crke = 0;
_typing.BackColor = Color.White;
}
private void timer1_label_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
public bool prvitext;
public bool eztext;
private void button2_Click(object sender, EventArgs e)
{
prvitext = true;
typing_text.Text = text;
}
private void button3_Click(object sender, EventArgs e)
{
restartbutton.PerformClick();
eztext = true;
typing_text.Text = text1;
kok_crk = text1.Length;
crke1 = text1.ToCharArray();
}
private void typing_text_TextChanged_1(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private void _typing_TextChanged(object sender, EventArgs e)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment