using EgwControlCenter.Core; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace EgwControlCenter { public partial class CheckPwd : Form { #region Public Constructors public CheckPwd() { InitializeComponent(); InitConf(); } #endregion Public Constructors #region Private Fields private int maxTry = 3; #endregion Private Fields #region Private Properties /// /// Oggetto gestione conf applicazione /// private ConfigManager AppConf { get; set; } = new ConfigManager("", ""); #endregion Private Properties #region Private Methods private void btnCheck_Click(object sender, EventArgs e) { checkPassword(); } private void checkPassword() { // verifico la pwd... if (txtPasswd.Text == "24068Seriate") { TargetSetup tgtForm = new TargetSetup(); tgtForm.Show(); Close(); } else { maxTry--; // se ho superato num tentativi chiudo... if (maxTry <= 0) { Close(); } else { txtPasswd.Text = ""; lblOut.Text = $"Chiave errata: ancora {maxTry} tentativi ammessi"; } } } private void CheckPwd_Load(object sender, EventArgs e) { FixPosition(); } private void FixPosition() { Rectangle workArea = Screen.GetWorkingArea(this); this.Location = new Point((workArea.Right - Size.Width) / 2, (workArea.Bottom - Size.Height) / 2); } private void InitConf() { AppConf = new ConfigManager(AccUtils.ConfDir, AccUtils.ConfName); txtPasswd.Focus(); } private void txtPasswd_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { checkPassword(); } } #endregion Private Methods } }