All pastes #201818 Raw Edit

Miscellany

public text v1 · immutable
#201818 ·published 2006-10-14 00:12 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TypeFast
{
    public partial class Form1 : Form
    {
        string keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int pos = 0;
        int last;
        DateTime start, end;

        public Form1()
        {
            last = keys.Length - 1;
            InitializeComponent();
            label2.Text = "Type the alphabet from A to begin. <SPACE> to reset.";
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == keys.ToUpper()[pos])
            {
                if (pos == 0)
                {
                    start = DateTime.Now;
                }
                if (pos == last)
                {
                    pos = 0;
                    label1.Text = keys[pos].ToString();
                    end = DateTime.Now;
                    label2.Text = "Your time is " + (end - start);
                    return;
                }
                pos++;
                label1.Text = keys[pos].ToString();
            }
            else if (e.KeyCode == Keys.Space)
            {
                pos = 0;
                label1.Text = keys[pos].ToString();
                return;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}