148 lines
3.6 KiB
C#
148 lines
3.6 KiB
C#
/***************************************************/
|
|
// __ ______
|
|
//
|
|
/***************************************************/
|
|
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace IPadLibrary.FormsInterfaces {
|
|
|
|
|
|
public partial class KeyboradControl : Form {
|
|
|
|
|
|
/*******************************************************************************************/
|
|
/* Constructors and Initialization
|
|
/*******************************************************************************************/
|
|
#region Public Class Constructors
|
|
|
|
|
|
public KeyboradControl() {
|
|
|
|
InitializeComponent(); // This is for the designer (not edit)
|
|
InizializeLocalData(); // This is for local data private/public
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
/*******************************************************************************************/
|
|
/* Form Events
|
|
/*******************************************************************************************/
|
|
#region Form Events
|
|
|
|
|
|
private void SHIFT_Button_Click(object sender, EventArgs e) {
|
|
|
|
shift_pressed = !shift_pressed;
|
|
if ( shift_pressed ) {
|
|
SHIFT_Button.FlatStyle = FlatStyle.Standard;
|
|
SHIFT_Button.BackColor = ProfessionalColors.ButtonPressedHighlight;
|
|
toUpperChase();
|
|
}
|
|
else {
|
|
SHIFT_Button.FlatStyle = FlatStyle.System;
|
|
SHIFT_Button.BackColor = Button.DefaultBackColor;
|
|
toLowerChase();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void SIMBOL_Button_Click(object sender, EventArgs e) {
|
|
|
|
simbol_pressed = !simbol_pressed;
|
|
if (simbol_pressed) {
|
|
SIMBOL_Button.FlatStyle = FlatStyle.Standard;
|
|
SIMBOL_Button.BackColor = ProfessionalColors.ButtonPressedHighlight;
|
|
switchToSymbol();
|
|
}
|
|
else {
|
|
SIMBOL_Button.FlatStyle = FlatStyle.System;
|
|
SIMBOL_Button.BackColor = Button.DefaultBackColor;
|
|
switchToNumber();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void KEY_Button_Click(object sender, EventArgs e) {
|
|
|
|
if (Display.Text.Length < MAX_DISPLAY_CHAR) { // If not reach the maximus text length
|
|
Display.Text += ((Button)sender).Text; // Insert the char into text line
|
|
Display.SelectionStart = Display.TextLength; // Allign the string on right
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void BACKSPACE_Button_Click(object sender, EventArgs e) {
|
|
|
|
int len;
|
|
if ((len = Display.Text.Length) > 0) { // If there is somethig to delete
|
|
Display.Text = Display.Text.Remove(len - 1); // Remove last char (right side)
|
|
Display.SelectionStart = Display.TextLength; // Allign the string on right
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OK_Button_Click(object sender, EventArgs e) {
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
|
|
|
|
private void CANCEL_Button_Click(object sender, EventArgs e) {
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
|
|
|
|
private void CLEAR_Button_Click(object sender, EventArgs e) {
|
|
|
|
Display.Text = "";
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Used to drawing the Form borders only.
|
|
/// </summary>
|
|
private void KeyboradControl_Paint(object sender, PaintEventArgs e) {
|
|
|
|
GeneralLibrary.DrawFormBorder(sender, e);
|
|
}
|
|
|
|
|
|
private void KeyboradControl_KeyPress(object sender, KeyPressEventArgs e) {
|
|
|
|
char ch = e.KeyChar;
|
|
int len = Display.Text.Length;
|
|
// If there is somethig to delete
|
|
if (len > 0 && ch == '\b' ) {
|
|
Display.Text = Display.Text.Remove(len - 1); // Remove last char (right side)
|
|
} else
|
|
if (Display.Text.Length < MAX_DISPLAY_CHAR) {
|
|
Display.Text += ch.ToString(); // Insert the char into text line
|
|
}
|
|
Display.SelectionStart = Display.TextLength; // Allign the string on right
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
} // end class
|
|
|
|
} // end namespace
|