예제 #1
0
        // Добавление варианта ответа и картинки
        private void addAnswer_Click(Object sender, EventArgs e)
        {
            _survey.Questions[listQuestions.SelectedIndex].Answers.Add("");

            ViewAnswer viewAnswer = new ViewAnswer
            {
                Text     = "",
                Size     = new Size(panel2.Width, 69),
                Location = new Point(0, listAnswers.Controls[listAnswers.Controls.Count - 1].Location.Y + 80),
                Margin   = new Padding(0, 0, 0, 0),
                Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                //TabIndex = i + 2,
                Dock = DockStyle.Top,

                Name   = "pAnswer" + _survey.Questions[listQuestions.SelectedIndex].Answers.Count.ToString(),
                Parent = listAnswers,
            };

            viewAnswer.BringToFront();

            foreach (Control Control in listAnswers.Controls)
            {
                if (Control is ViewAnswer)
                {
                    (Control as ViewAnswer).TrueChanged += delegate(Object _object, EventArgs _eventArgs)
                    {
                        foreach (ViewAnswer Answer in listAnswers.Controls)
                        {
                            if (Answer.Name != Control.Name)
                            {
                                Answer.True = (Control as ViewAnswer).True ? false : true;
                            }
                        }
                    };

                    (Control as ViewAnswer).True = false;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Обновляет отображение вопроса
        /// </summary>
        /// <param name="Question"></param>
        private void Update(Question Question)
        {
            Clear();
            tQuestion.Text = Question.Name;

            if (Question.Image != null)
            {
                pImage.Image = Question.Image;
                _survey.Questions[listQuestions.SelectedIndex].Image = Question.Image;

                pImage.Visible      = true;
                pictureBox1.Visible = true;
            }
            else
            {
                pImage.Visible      = false;
                pictureBox1.Visible = false;
            }

            Int32 Y = -80;

            for (int i = 1; i <= ((Question.Type == "Свободный ответ") ? 1 : Question.Answers.Count); i++)
            {
                ViewAnswer viewAnswer = new ViewAnswer
                {
                    Text = Question.Answers[i - 1],
                    Size = new Size(panel2.Width, 72),
                    //MaximumSize = new Size(1000, 69),
                    //Location = new Point(0, Y += 80),
                    Margin   = new Padding(0, 0, 0, 0),
                    Padding  = new Padding(0, 3, 0, 0),
                    Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                    TabIndex = i + 2,
                    Dock     = DockStyle.Top,

                    Name   = "pAnswer" + i.ToString(),
                    Parent = listAnswers,
                };

                viewAnswer.BringToFront();
            }

            switch (Question.Type)
            {
            case "Выбор одного правильного ответа":
                foreach (Control Control in listAnswers.Controls)
                {
                    if (Control is ViewAnswer)
                    {
                        (Control as ViewAnswer).TrueChanged += delegate(Object _object, EventArgs _eventArgs)
                        {
                            foreach (ViewAnswer Answer in listAnswers.Controls)
                            {
                                if (Answer.Name != Control.Name)
                                {
                                    Answer.True = (Control as ViewAnswer).True ? false : true;
                                }
                            }
                        };

                        (Control as ViewAnswer).True = false;
                    }
                }

                True(Question);

                addAnswer.Visible = true;
                addImage.Location = new Point(419, 465);

                mSingleAnswerSelection.Checked = true;
                mFreeAnswer.Checked            = false;
                break;

            case "Свободный ответ":
                foreach (ViewAnswer Answer in listAnswers.Controls)
                {
                    Answer.VisibleTrue = Answer.VisibleDelete = false;
                }

                addAnswer.Visible = false;
                addImage.Location = addAnswer.Location;

                mSingleAnswerSelection.Checked = false;
                mFreeAnswer.Checked            = true;
                break;

            default: break;
            }
        }