Inserimento progetto
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
/***************************************************/
|
||||
/***************************************************/
|
||||
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace IPadLibrary.FormsInterfaces {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Keyboard component, instantiate the Keyboard Form.
|
||||
/// </summary>
|
||||
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 -------------------------------------//
|
||||
|
||||
/// <summary>
|
||||
/// Show this dialog, in modal mode.
|
||||
/// </summary>
|
||||
/// <param name="owner">Any object that implement <c>IWin32Window</c> that is the fisrt level window owner of the modal dialog.</param>
|
||||
/// <returns>One value of <c>DialogResult</c>.</returns>
|
||||
public DialogResult ShowDialog(Control owner) {
|
||||
this.owner = owner;
|
||||
return base.ShowDialog(owner);
|
||||
}
|
||||
|
||||
//------------------------------------ GETS SECTION ---------------------------------------//
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set the text typed.
|
||||
/// </summary>
|
||||
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 --------------------------------------//
|
||||
|
||||
/// <summary>
|
||||
/// Initialize all component of this Form.
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add <c>Key_Button_Click</c> Event to button.
|
||||
/// </summary>
|
||||
/// <param name="b">The <c>Button</c> the implement a click event.</param>
|
||||
private void setEventClick(Button b) {
|
||||
|
||||
b.Click += new System.EventHandler(KEY_Button_Click);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add <c>Key_Button_Click</c> Event to buttons group.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
private void setEventClick(Button[] group) {
|
||||
|
||||
foreach ( Button b in group )
|
||||
b.Click += new System.EventHandler(KEY_Button_Click);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Change all keys char in UpperCase.
|
||||
/// </summary>
|
||||
private void toUpperChase() {
|
||||
|
||||
foreach ( Button b in buttonGroupKeys )
|
||||
b.Text = b.Text.ToUpper();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Change all keys char in LowerCase.
|
||||
/// </summary>
|
||||
private void toLowerChase() {
|
||||
|
||||
foreach ( Button b in buttonGroupKeys )
|
||||
b.Text = b.Text.ToLower();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Switch all Key numbers in symbol mode.
|
||||
/// </summary>
|
||||
private void switchToSymbol() {
|
||||
int idx = 0;
|
||||
foreach ( Button b in buttonGroupNumbers )
|
||||
b.Text = SIMBOL_CHARS[idx++].ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Switch all Key numbers in symbol mode.
|
||||
/// </summary>
|
||||
private void switchToNumber() {
|
||||
int idx = 0;
|
||||
foreach ( Button b in buttonGroupNumbers )
|
||||
b.Text = NUMBER_CHARS[idx++].ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
} // end class
|
||||
|
||||
} // end namespace
|
||||
|
||||
Reference in New Issue
Block a user