예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
 bool CheckURL()
 {
     if (string.IsNullOrEmpty(CtrlURL.Text))
     {
         CtrlError.ShowError("Укажите URL изображения.");
         return(false);
     }
     CtrlError.ClearError();
     return(true);
 }
예제 #4
0
        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("Неправильные данные.");
            }
        }
예제 #5
0
        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);
        }