Click here to Skip to main content
15,892,575 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: Checking for a Key Sequence Pin
Brady Kelly10-Nov-07 5:36
Brady Kelly10-Nov-07 5:36 
GeneralRe: Checking for a Key Sequence Pin
Trollslayer10-Nov-07 5:55
mentorTrollslayer10-Nov-07 5:55 
GeneralRe: Checking for a Key Sequence Pin
Brady Kelly10-Nov-07 6:04
Brady Kelly10-Nov-07 6:04 
GeneralRe: Checking for a Key Sequence Pin
Trollslayer10-Nov-07 6:28
mentorTrollslayer10-Nov-07 6:28 
GeneralRe: Checking for a Key Sequence Pin
Brady Kelly10-Nov-07 19:48
Brady Kelly10-Nov-07 19:48 
GeneralRe: Checking for a Key Sequence Pin
Luc Pattyn10-Nov-07 14:24
sitebuilderLuc Pattyn10-Nov-07 14:24 
GeneralRe: Checking for a Key Sequence Pin
Brady Kelly10-Nov-07 19:53
Brady Kelly10-Nov-07 19:53 
GeneralRe: Checking for a Key Sequence Pin
Luc Pattyn11-Nov-07 3:34
sitebuilderLuc Pattyn11-Nov-07 3:34 
Hi Brady,


Brady Kelly wrote:
every key press will create a new string


So does your statement string buff = keyBuffer.ToString();


Brady Kelly wrote:
I worried about the size of buf just using a string


My statement if (buf.Length>SEQ.Length) buf=buf.SubString(buf.Length-SEQ.Length, SEQ.Length);
limits the string length at all times (to 2 chars in case SEQ=x02x03).


If you don't want to do all the buffer stuff, there is one (slightly more complex)
alternative using a state machine, which basically remembers how many characters of SEQ
have been matched so far. So in one implementation it would use an int state;
and basically do:

if (e.KeyChar==SEQ[state]) state++; else state=0;
if (state==SEQ.Length) {
    state=0;
    ... we got a match
}


the above code however is incorrect as soon as SEQ contains repeating characters though;
if you must cope with the general case it becomes much more complex...

Smile | :)



Luc Pattyn [Forum Guidelines] [My Articles]


this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google


GeneralRe: Checking for a Key Sequence Pin
Brady Kelly11-Nov-07 3:39
Brady Kelly11-Nov-07 3:39 
QuestionMater / Detail Datagridview Pin
Mr. Candyman7-Nov-07 8:41
Mr. Candyman7-Nov-07 8:41 
AnswerRe: Mater / Detail Datagridview Pin
led mike7-Nov-07 8:46
led mike7-Nov-07 8:46 
GeneralRe: Mater / Detail Datagridview Pin
Mr. Candyman7-Nov-07 9:40
Mr. Candyman7-Nov-07 9:40 
GeneralRe: Mater / Detail Datagridview Pin
led mike7-Nov-07 10:41
led mike7-Nov-07 10:41 
GeneralRe: Mater / Detail Datagridview Pin
Mr. Candyman7-Nov-07 11:28
Mr. Candyman7-Nov-07 11:28 
Questionexpanding label control Pin
abdelhameed817-Nov-07 0:37
abdelhameed817-Nov-07 0:37 
AnswerRe: expanding label control Pin
Christian Graus7-Nov-07 9:43
protectorChristian Graus7-Nov-07 9:43 
QuestionDataGridView and Generics Pin
Ponzano Paolo5-Nov-07 23:44
Ponzano Paolo5-Nov-07 23:44 
AnswerRe: DataGridView and Generics Pin
Christian Graus5-Nov-07 23:53
protectorChristian Graus5-Nov-07 23:53 
GeneralRe: DataGridView and Generics Pin
Ponzano Paolo6-Nov-07 0:29
Ponzano Paolo6-Nov-07 0:29 
GeneralRe: DataGridView and Generics Pin
Pete O'Hanlon6-Nov-07 1:11
mvePete O'Hanlon6-Nov-07 1:11 
GeneralRe: DataGridView and Generics Pin
Ponzano Paolo6-Nov-07 1:13
Ponzano Paolo6-Nov-07 1:13 
GeneralRe: DataGridView and Generics Pin
Ponzano Paolo6-Nov-07 1:34
Ponzano Paolo6-Nov-07 1:34 
QuestionC# Soap and HTTP Pin
AssemblySoft5-Nov-07 6:16
AssemblySoft5-Nov-07 6:16 
Answercross-post Pin
Luc Pattyn5-Nov-07 6:40
sitebuilderLuc Pattyn5-Nov-07 6:40 
JokeRe: cross-post Pin
Paul Conrad6-Nov-07 16:00
professionalPaul Conrad6-Nov-07 16:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.