Example #1
0
        private void textBox3_KeyDown(object sender, KeyEventArgs e)
        {
            //Console.WriteLine("key down");

            //过滤除了字母以及数字的按键
            if (KeyboardTimeline.IsAvailableKey(e.KeyValue))
                return;

            if ((Keys)e.KeyValue != Keys.Enter)
                timeline.MarkDown(e.KeyValue);

            //如果按下的是回车,代表输入已经完成
            if((Keys)e.KeyValue == Keys.Enter)
            {
                //recordList.Add(timeline.ToVector());
                if(MessageBox.Show("是否保存?", "保存", MessageBoxButtons.YesNo)
                    == DialogResult.Yes)
                {
                    recordList.Add(timeline.ToVector());
                    recordCounter++;

                    //已经记录完毕
                    if(recordCounter > MAX_RECORD_REQUIRED)
                    {

                        return;
                    }
                }
            }
            
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //密码输入错误
            if (!textBox2.Text.Equals(textBox3.Text))
            {
                MessageBox.Show("密码输入错误!", "错误");
                textBox3.Clear();
                timeline = new KeyboardTimeline();
                textBox3.Focus();
                return;
            }

            if (MessageBox.Show("是否保存?", "保存", MessageBoxButtons.YesNo)
                == DialogResult.Yes)
            {
                recordList.Add(timeline.ToVector());
                recordCounter++;

                label3.Text = "还需要输入" + (MAX_RECORD_REQUIRED - recordCounter) + "次";

                //已经记录完毕
                if (recordCounter >= MAX_RECORD_REQUIRED)
                {
                    //如果用户不存在,就新增用户
                    if (access.SearchUserID(textBox1.Text) <= 0)
                    {
                        access.insert(textBox1.Text, textBox2.Text);
                    }

                    foreach (var record in recordList)
                    {
                        access.InsertKeyboardData(textBox1.Text, record);
                    }

                    //输入完成后,关闭完成按钮,关闭输入文本框,打开用户名和密码输入框
                    textBox1.Enabled = true;
                    textBox1.Clear();
                    textBox1.Focus();
                    textBox2.Enabled = true;
                    textBox2.Clear();
                    textBox3.Enabled = false;
                    button1.Enabled  = true;
                    button2.Enabled  = false;
                    label3.Text      = "密码输入共需要" + MAX_RECORD_REQUIRED + "次";
                }
            }
            textBox3.Clear();
            textBox3.Focus();
            timeline = new KeyboardTimeline();
        }