private void ButtonSave_Click(object sender, RoutedEventArgs e) { if (!CheckAllFields()) { return; } TestInfo test = Test; if (!TestValidator.IsValid(test)) { CtrlError.ShowError(TestValidator.Error); return; } if (TestId != null) { manager.Channel.EditTest(test, Questions); } else { manager.Channel.AddTest(test, Questions); } manager.MenuControl.Back(); }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { if (!CheckText()) { return; } QuestionInfo question = Question; if (!QuestionValidator.IsValid(question)) { CtrlError.ShowError(QuestionValidator.Error); return; } if (questionId != null) { manager.TestEditControl.EditQuestion(Question); } else { manager.TestEditControl.AddQuestion(Question); } manager.TestEditControl.Back(); }
bool CheckURL() { if (string.IsNullOrEmpty(CtrlURL.Text)) { CtrlError.ShowError("Укажите URL изображения."); return(false); } CtrlError.ClearError(); return(true); }
private void CtrlSignIn_Click(object sender, RoutedEventArgs e) { if (!CheckPassword() | !CheckName()) { return; } if (UserValidator.IsValidName(CtrlName.Text) && UserValidator.IsValidPassword(CtrlPassword.Password) && manager.Channel.SignIn(CtrlName.Text, CtrlPassword.Password)) { manager.SignIn(); } else { CtrlError.ShowError("Неправильные данные."); } }
private void CtrlLoad_Click(object sender, RoutedEventArgs e) { if (!CheckURL()) { return; } byte[] photobytes = null; try { using (WebClient client = new WebClient()) { photobytes = client.DownloadData(CtrlURL.Text); } } catch (Exception) { CtrlError.ShowError("Ошибка."); } AppManager.Instance.LoadImageControl.LoadImage(photobytes); }