Hi! i'm doing a project, i'm not going to details but i will simplify my idea, i'm using Morse Code ( dot and dash) and i have 2 methods: convert_MorseToChar() and Convert_MorseTonum()
in the convert_MorseToChar() method there is swich to compare the input from a user which will be Morse codes and mapping it to characters:
private String convert_MorseToChar(ref string Ch)
{
switch (Ch)
{
Case ".-":
MorsetoChar = "a"
break;
Case "-...":
MorsetoChar = "b"
break;
Case "-.-.":
MorsetoChar = "c"
break;
Case "-..":
MorsetoChar = "d"
break;
Case ".":
MorsetoChar = "e"
break;
}
}
and the other method Convert_MorseToNum(), ues the SAME combinations of Morse codes but mapping them to numbers:
private String Convert_MorseToNum(ref string Ch)
{
switch (Ch)
{
Case ".-":
MorsetoChar = "1"
break;
Case "-...":
MorsetoChar = "2"
break;
Case "-.-.":
MorsetoChar = "3"
break;
Case "-..":
MorsetoChar = "4"
break;
Case ".":
MorsetoChar = "5"
break;
}
}
now the senario is: there are 2 Textbox, one the user will write Morse codes in it and the other is for the output. The user will write dot "." and dash "-" from the keyboard and press Enter then the program will go to ONE of the 2 methods to convert the Morse codes. Now what tells the program where to go to convert?? my question is: I want to create mode key to swich between 2 modes: MorseTochar and MorseToNum. i want the down arrow key to act like a mode, when a user press the down arrow then it the program will be in MorseToChar mode, when ever the user input the program directly use the method convert_MorseToChar to convert to characters. and when the user press the down arrow agian, the prohram will swich to MorseToNum mode here when ever the user input as morsecode, the program will directly use the method Convert_MorseToNum() to convert to numbers. HOW I CAN DO THAT Pleaaaas!!! help me!
Please excuse my English, English is not my native language :)