private void setError(ErrorIcon icon, string message, string fieldName = "", string p1 = null, string p2 = null, string p3 = null, string p4 = null) { string msg = message; if (p1 != null) { msg = msg.Replace("%1", p1); } if (p2 != null) { msg = msg.Replace("%2", p2); } if (p3 != null) { msg = msg.Replace("%3", p3); } if (p4 != null) { msg = msg.Replace("%4", p4); } Icon = icon; FieldName = fieldName; Message = msg.Replace("\r\n", "||").Replace("\\", "\"); }
public void SetErrorOnField(ErrorIcon icon, string message, string focusField, string p1 = null, string p2 = null, string p3 = null, string p4 = null, bool bCookie = false) { SetError(icon, message, p1, p2, p3, p4, bCookie); if (bCookie) { setCookie("ErrorField", focusField, 100); } FocusField = focusField; }
private void NewPasswordTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (string.IsNullOrEmpty(NewPasswordTextBox.Text)) { ErrorIcon.SetError(NewPasswordTextBox, "This field cant be empty!"); } else { ErrorIcon.Clear(); } }
private void LoginTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (string.IsNullOrEmpty(LoginTextBox.Text)) { ErrorIcon.SetError(LoginTextBox, "This field cant be empty!"); } else if (!authorization.IsLoginExist(LoginTextBox.Text)) { ErrorIcon.SetError(LoginTextBox, "Login is not exists"); } else { ErrorIcon.Clear(); } }
private void PhoneTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (!PhoneTextBox.MaskCompleted) { ErrorIcon.SetError(PhoneTextBox, "Wrong phone number"); } else if (!authorization.IsPhoneExist(PhoneTextBox.Text)) { ErrorIcon.SetError(PhoneTextBox, "Phone is not exists"); } else { ErrorIcon.Clear(); } }
public LoginVerifyWindow() { InitializeComponent(); Task.Run(async() => { await Task.Delay(TimeSpan.FromSeconds(1)); Dispatcher.Invoke(() => { MainTransitioner.SelectedIndex++; }); await Task.Delay(TimeSpan.FromSeconds(1)); var verify = LoginManager.LoginVerify(true); Dispatcher.Invoke(() => { if (verify) { MainTextBlock.Text = "验证完成! 祝你游戏愉快"; AnimeBar.FadeOut(); SuccessIcon.FadeIn(); } else { MainTextBlock.Text = "很抱歉, 验证失败"; AnimeBar.FadeOut(); ErrorIcon.FadeIn(); } }); await Task.Delay(TimeSpan.FromSeconds(1)); Dispatcher.Invoke(() => { MainTransitioner.SelectedIndex++; }); await Task.Delay(TimeSpan.FromSeconds(2)); Dispatcher.Invoke(this.Close); }); }
public void SetError(ErrorIcon icon, string message, string p1 = null, string p2 = null, string p3 = null, string p4 = null, bool bCookie = false) { string msg = message; if (p1 != null) { msg = msg.Replace("%1", p1); } if (p2 != null) { msg = msg.Replace("%2", p2); } if (p3 != null) { msg = msg.Replace("%3", p3); } if (p4 != null) { msg = msg.Replace("%4", p4); } msg = msg.Replace("\\", "\"); if (bCookie) { setCookie("ErrorIcon", ((int)icon).ToString(), 100); setCookie("ErrorText", msg, 100); } else { Error = new Error(); Error.SetError(msg); Error.Icon = icon; } }