/***************************************************/
/***************************************************/
using System.Windows.Forms;
namespace IPadLibrary.FormsInterfaces {
///
/// Keyboard component, instantiate the Keyboard Form.
///
partial class KeyboradControl {
/*******************************************************************************************/
/* Constant & Static Variables
/*******************************************************************************************/
#region Constant & Static Variables
private const int MAX_DISPLAY_CHAR = 250; // Maximun number of char to text
private const char SHIFT_CHAR = '\u00ad'; // The simbol ^
private const char BACKSPACE_CHAR = '\u00ac'; // The simbol <--
private const string SIMBOL_CHARS = "~'().,_\\-*"; // Symbol key sequence
private const string NUMBER_CHARS = "0123456789"; // Number key sequence
#endregion
/*******************************************************************************************/
/* Public Variables Definition
/*******************************************************************************************/
#region Public Variables Definiton
// ...
#endregion
/*******************************************************************************************/
/* Private Variables Definition
/*******************************************************************************************/
#region Private Variables Definition
private Control owner; ///< The owner of Form Dialog
private Button[] buttonGroupNumbers; ///< Used to manage all group of Nubers buttons
private Button[] buttonGroupKeys; ///< Used to manage all group of Keys buttons
private bool shift_pressed; ///< Monitor the Shift-Key pression
private bool simbol_pressed; ///< Monitor the Simbol-Key pression
#endregion
/*******************************************************************************************/
/* Public Methods Definition
/*******************************************************************************************/
#region Public Methods Definition
//------------------------------------ DIALOG SECTION -------------------------------------//
///
/// Show this dialog, in modal mode.
///
/// Any object that implement IWin32Window that is the fisrt level window owner of the modal dialog.
/// One value of DialogResult.
public DialogResult ShowDialog(Control owner) {
this.owner = owner;
return base.ShowDialog(owner);
}
//------------------------------------ GETS SECTION ---------------------------------------//
///
/// Get/Set the text typed.
///
public override string Text {
get {
if ( Display != null )
return Display.Text;
else
return "";
}
set {
if ( Display != null ) {
Display.Text = value.Trim();
}
}
}
#endregion
/*******************************************************************************************/
/* Private Methods Definition
/*******************************************************************************************/
#region Private Methods Definition
//------------------------------------- INIT SECTION --------------------------------------//
///
/// Initialize all component of this Form.
///
private void InizializeLocalData() {
shift_pressed = false;
simbol_pressed = false;
SHIFT_Button.Text = SHIFT_CHAR.ToString(); // Set to correct ASCII char.
BACKSPACE_Button.Text = BACKSPACE_CHAR.ToString(); // Set to correct ASCII char.
buttonGroupNumbers = new Button[] {
NUM0_Button, NUM1_Button, NUM2_Button, NUM3_Button, NUM5_Button,
NUM4_Button, NUM6_Button, NUM7_Button, NUM8_Button, NUM9_Button
};
setEventClick(buttonGroupNumbers);
buttonGroupKeys = new Button[] {
KEY1_Button, KEY2_Button, KEY3_Button, KEY4_Button, KEY5_Button,
KEY6_Button, KEY7_Button, KEY8_Button, KEY9_Button, KEY10_Button,
KEY11_Button, KEY12_Button, KEY13_Button, KEY14_Button, KEY15_Button,
KEY16_Button, KEY17_Button, KEY18_Button, KEY19_Button, KEY20_Button,
KEY21_Button, KEY22_Button, KEY23_Button, KEY24_Button, KEY25_Button,
KEY26_Button
};
setEventClick(buttonGroupKeys);
setEventClick(SPACE_Button);
this.Select(); // Default selceted button
}
///
/// Add Key_Button_Click Event to button.
///
/// The Button the implement a click event.
private void setEventClick(Button b) {
b.Click += new System.EventHandler(KEY_Button_Click);
}
///
/// Add Key_Button_Click Event to buttons group.
///
///
private void setEventClick(Button[] group) {
foreach ( Button b in group )
b.Click += new System.EventHandler(KEY_Button_Click);
}
///
/// Change all keys char in UpperCase.
///
private void toUpperChase() {
foreach ( Button b in buttonGroupKeys )
b.Text = b.Text.ToUpper();
}
///
/// Change all keys char in LowerCase.
///
private void toLowerChase() {
foreach ( Button b in buttonGroupKeys )
b.Text = b.Text.ToLower();
}
///
/// Switch all Key numbers in symbol mode.
///
private void switchToSymbol() {
int idx = 0;
foreach ( Button b in buttonGroupNumbers )
b.Text = SIMBOL_CHARS[idx++].ToString();
}
///
/// Switch all Key numbers in symbol mode.
///
private void switchToNumber() {
int idx = 0;
foreach ( Button b in buttonGroupNumbers )
b.Text = NUMBER_CHARS[idx++].ToString();
}
#endregion
} // end class
} // end namespace