private bool AreTheTextFieldsFilledDifferently()
        {
            var textResultsBodies = _textResults.Select(textR => textR.Body.ToUpperInvariant());

            if (GeneralMethods.AreThereSameElementsInTheStringCollection(textResultsBodies, out string textResultElement))
            {
                UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(PossibleResultTextsListBox, 1, textResultElement, "По крайней мере два текстовых результата совпадают. Удалите ненужные либо переименуйте.");

                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool AreTheFieldsFilledDifferently()
        {
            var questionsBodies = _questions.Select(qu => qu.Body.ToUpperInvariant());

            if (GeneralMethods.AreThereSameElementsInTheStringCollection(questionsBodies, out string questionElement))
            {
                UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(QuestionsListBox, 1, questionElement, "По крайней мере два Ваших вопроса совпадают. Так нельзя — как же игроки будут их различать?");

                return(false);
            }

            foreach (var question in _questions)
            {
                int questionIndex = _questions.IndexOf(question);

                var answerBodies = question.Answers.Select(an => an.Body.ToUpperInvariant());

                ListBox AnswerListBox = UIMethods.GetUIElementChildByNumberFromTemplatedListBox(QuestionsListBox, questionIndex, 4) as ListBox;

                if (GeneralMethods.AreThereSameElementsInTheStringCollection(answerBodies, out string answerElement))
                {
                    UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(AnswerListBox, 0, answerElement, $"В вопросе {(questionIndex + 1).ToString()} есть одинаковые ответы. Измените их либо удалите ненужные.");

                    return(false);
                }

                foreach (var answer in question.Answers)
                {
                    int answerIndex = question.Answers.IndexOf(answer);

                    var reactionBodies = answer.Effects.Select(re => re.Body.ToUpperInvariant());

                    if (GeneralMethods.AreThereSameElementsInTheStringCollection(reactionBodies, out string reactionElement))
                    {
                        ListBox ReactionListBox = UIMethods.GetUIElementChildByNumberFromTemplatedListBox(AnswerListBox, answerIndex, 3) as ListBox;

                        UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(ReactionListBox, 0, reactionElement, $"В вопросе {(questionIndex + 1).ToString()} есть реакции с совпадающим текстом. Измените их либо удалите ненужные.");

                        return(false);
                    }
                }
            }

            return(true);
        }
        private bool CheckingIfEveryFieldIsFilledCorrectly()
        {
            if (GameNameTextBox.Text == defaultGameName)
            {
                MessageBox.Show("Название игры является обязательным полем!", "Ошибка!");
                GameNameTextBox.Focus();
                return(false);
            }

            else if (GameDescriptionTextBox.Text == defaultDescription)
            {
                MessageBox.Show("Описание должно присутствовать у каждой игры. Не оставляйте это поле пустым.", "Ошибка!");
                GameDescriptionTextBox.Focus();
                return(false);
            }

            else if (CharacteristicsListBox.Items.Count == 0)
            {
                MessageBox.Show("В игре не может не быть характеристик вообще — добавьте, пожалуйста, хотя бы одну!", "Ошибка!");

                AddNewDefaultCharacteristic();
                _characteristicNameTextBoxShouldBeFocused = true;

                return(false);
            }

            else if (UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(CharacteristicsListBox, 0, defaultCharacteristicName, "Название характеристики — обязательный аттрибут. Заполните все поля либо удалите ненужные характеристики."))
            {
                return(false);
            }

            var namesOfCharacteristics = _characteristics.Select(ch => ch.Name);
            var namesOfCharacteristicsWithOneRegister = _characteristics.Select(ch => ch.Name.ToUpperInvariant());

            if (GeneralMethods.AreThereSameElementsInTheStringCollection(namesOfCharacteristics, out string element))
            {
                UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(CharacteristicsListBox, 0, element, "По крайней мере две ваши характеристики имеют одинаковое название. Так нельзя — как же игроки будут их различать?");

                _theSameCharacteristicsNamesErrorWasShown = true;

                return(false);
            }

            else if (GeneralMethods.AreThereSameElementsInTheStringCollection(namesOfCharacteristicsWithOneRegister, out element))
            {
                if (_theSameCharacteristicsNamesErrorWasShown)
                {
                    UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(CharacteristicsListBox, 0, element, "Одинаковые названия в разном регистре  — не вариант, уж простите. Пожалуйста, измените названия.");
                }

                else
                {
                    UIMethods.FindCurrentTextInTextBoxesOfTheTemplatedListBox(CharacteristicsListBox, 0, element, "По крайней мере две ваши характеристики имеют одинаковое название. Без учета регистра. Пожалуйста, измените названия.");
                }

                return(false);
            }

            int amountOfGamesWithSuchName = _user.Games.Where(game => game.Name == GameNameTextBox.Text).Count();

            if ((amountOfGamesWithSuchName > 0 && _creatingTheGameForTheFirstTime) || (amountOfGamesWithSuchName > 1 && (!_creatingTheGameForTheFirstTime)))
            {
                MessageBox.Show("У Вас уже есть игра с таким названием. Пожалуйста, придумайте для этой игры другое!", "Ошибка!");

                GameNameTextBox.Focus();

                return(false);
            }

            return(true);
        }