private void cmdOK_Click(object sender, System.EventArgs e) { if (AddinAppData.Instance.Key != txtKey.Text) { txtKey.Text = txtKey.Text.Trim(); if (!ValidateRegistrationKey(txtKey.Text)) { MessageBox.Show("The entered key is not valid.", "Invalid Key!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (chkStat.Checked != AddinAppData.Instance.AllowStats) { try { var service = new nhydrateservice.MainService(); service.ResetStatistics(AddinAppData.Instance.Key, chkStat.Checked); } catch (Exception ex) { //Do Nothing } } AddinAppData.Instance.AllowStats = chkStat.Checked; AddinAppData.Instance.Key = txtKey.Text; AddinAppData.Instance.Save(); } this.DialogResult = DialogResult.OK; this.Close(); }
private void cmdLogin_Click(object sender, System.EventArgs e) { try { nhydrateservice.MainService service = null; service = new nhydrateservice.MainService(); if (service.AuthenticateUser2(txtLoginEMail.Text, txtLoginPassword.Text, SecurityHelper.GetMachineID())) { service.ResetStatistics(txtLoginEMail.Text, chkStat.Checked); var key = service.GetKey(txtLoginEMail.Text); AddinAppData.Instance.Key = key; AddinAppData.Instance.AllowStats = chkStat.Checked; AddinAppData.Instance.Save(); MessageBox.Show("There login has been validated. Your key has been verified.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("There login could not be validated.", "Invalid Login!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("There was an error trying to register. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }