Introduction
Demo project (FileSearcher)
The FileSearcher is the demo of the MCKeyboard
. When you start it you can define a root folder for the searcher. Then you have to enter a search string by using the mobile phone control. With the GET IT button you can search the file names recursively.
Source Code and Compiled Code
The code is compiled as .NET UserControl DLL containing two classes...the MobileKB
class and the Selector
class.
MobileKB
is the control itself. Besides the buttons, labels and textboxes, it contains two timers, one for updating the current character textbox (updateTimer
) and the other for writing the current character (currentChar
) and going on to the next (nextTimer
). It also has a variable to indicate how often the button was hit and where we are in the array containing the source characters from keys.txt (pressCount
). Finally, there is also an instance of the Selector
class.
The Selector
is the part of the control, which always returns the right character to the MobileKB
, depending on which button was hit and how often it was hit. For example, if we hit button "4" three times, then we want to have a "l". This is done by the method GetChar(int, int)
. We take the first int
to determine what line of characters is right and the second int
to get the right character out of this line.
Background
Not long ago, myself and a friend had to test a Mediacenter-PC and we found it very exciting about what you can do with such a HomeCinema-Monster =). Not having any money at all, we put a computer next to our TV and started programming our own Mediacenter Software (which will soon be available at here). One of the difficulties for us was to provide a way to add text to the software using only a IR-remote. Our first try was a control with a keyboard graphic. You had to select a key and hit "Enter" on the IR to set a character. This was too much work to write the code, so we decided to use the keyboard style that mobile phones have. It is a much smoother way to enter text, because you don't have to navigate too much. This control is set up faster too, because the characters, which are shown by button-hitting, are defined in a text file outside and the timers can easily be set.
Using the code
The control is easy to set up:
- Go to the form (designer-mode) you want to add the control to.
- Right-click on the "Toolbox" will let you access the "Add/Remove Items" option. Then click the "Browse" button.
- Look for the MCKeyboard.dll and double click it.
- Add an instance to your form. You will receive an error message with a certain path at the end. You only have to copy the keys.txt file to this directory and it will work.
You can also use this way:
Remember: You will receive an error message with a certain path at the end. You only have to copy the keys.txt file to this directory and it will work.
Points of Interest
I still have some problems or code which is a little bit "dirty". For example, when you remove an instance of MobileKB
from your form, there will be an ObjectDisposedException
saying there's no access to a disposed textbox. Well...I think...that's true =). But I couldn't fix this problem by now. Another thing that's a little poor is the the navigation within the control. I'd rather have a arrow-key-based navigation than a tab-based navigation. But it's a little work. The last one is the error message that keys.txt was not found. hmm, copying does it but I have to fix this. I'm sure there will be an updated version soon...with your help.
I also want to say that I really look forward getting some feedback and tipps for writing this code better. Every mail is welcome.
History
I didn't do any changes to the code since it landed at CodeProject. But I want to fix the problem with the exception, get another solution instead of the updateTimer and I want the code to be smaller. You will hear from me soon...=)
P.S.: Please email if you have questions. I also am online every day at the lounge.