hi,
I am trying to do a program which fit for simple calculator as well as mobile phone keypad using delegates in c# windows application. I am trying only for keyboard events for calculator. I am unable to code arithmetic operations in one method which suits for both calculator and mobile phone. please help me..
Loading
Danatas GerviPosted Aug 25, 2009, 11:46 AM
You can create a number of handlers of every key event. It will help to separate the logic of key press processing. The key as sender should contain the reference to array of its possible values (it may be simple string – because the string already is the array of chars) and, on this event you can easy decide (according state (calculator or phone or sms input) – what char to take – number for calc and phone mode but next char (if sender is the same button) in sms mode.
srinathPosted Aug 24, 2009, 11:14 AM
I am actually trying for the code which works for muti purpose use. We have button keypress events for all buttons of calculator i.e only numbers and button keypress events for mobile phone keypad where we have multiple keypress for one button like [wxyz9] for button '9'. This is to be done with non-generic events like button_keypress.
Kirtan PatelPosted Aug 23, 2009, 4:56 AM
i could not Understood your requirement correctly
i understand as You have a Form Which has interface like Calculator and you want to press all that Buttons From Keyboard Right ?
Danatas GerviPosted Aug 23, 2009, 4:49 AM
As simplest (but not the best) way – you should add to you program a Boolean variable
"SystemInCalculatorMode" – and use it to call proper method:
if (SystemInCalculatorMode)
{
DoCalcOpreations();
}
else
{
DoDealingOperations();
}
But this is only beginning….
When you will need other modes – add an enum like
public enum SysMode
{
Calc,
Phone,
StopWhatch
}
And so on - up to the pattern "State mashine".