Files
2025-05-15 16:01:31 +02:00

159 lines
4.3 KiB
C#

/***************************************************/
// __ ______
//
/***************************************************/
using System.Drawing;
using System.Windows.Forms;
namespace IPadLibrary.FormsInterfaces {
/// <summary>
/// Keypad component, instantiate the Keypad Form.
/// </summary>
partial class NumericPad {
/*******************************************************************************************/
/* Constant & Static Variables
/*******************************************************************************************/
#region Constant & Static Variables
private const char BACKSPACE_CHAR = '\u00dc'; ///< The simbol <--
private const int MAX_DISPLAY_NUMBERS = 9; ///< Maximun number of char to text
#endregion
/*******************************************************************************************/
/* Public Variables Definition
/*******************************************************************************************/
#region Public Variables Definiton
// ...
#endregion
/*******************************************************************************************/
/* Private Variables Definition
/*******************************************************************************************/
#region Private Variables Definition
private Button[] buttonGroupNumbers; ///< Used to manage all group of Keys buttons
private Control owner; ///< The owner of Form Dialog
private bool dot; ///< Monitor the dot 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();
dot = value.IndexOf('.') == -1 ? false : true ;
}
}
}
/// <summary>
/// Get/Set the password char for input data.
/// </summary>
public char PasswordChar {
get {
return Display.PasswordChar;
}
set {
Display.PasswordChar = value;
}
}
#endregion
/*******************************************************************************************/
/* Private Methods Definition
/*******************************************************************************************/
#region Private Methods Definition
//------------------------------------- INIT SECTION --------------------------------------//
/// <summary>
/// Initialize all component of this Form.
/// </summary>
private void InizializeLocalData() {
dot = false;
BACKSPACE_Button.Text = BACKSPACE_CHAR.ToString();
buttonGroupNumbers = new Button[] {
NUM0_Button, NUM1_Button, NUM2_Button, NUM3_Button, NUM4_Button,
NUM5_Button, NUM6_Button, NUM7_Button, NUM8_Button, NUM9_Button
};
setEventClick(buttonGroupNumbers);
}
/// <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);
}
#endregion
} // end class
} // end namespace