Exemple #1
0
        private void EditStrip_Click(object sender, EventArgs e)
        {
            editor.SetNativeEnabled(false);

            var questionEditor = new QuestionEditor(question);

            questionEditor.FormClosing += (s, ev) =>
            {
                editor.SetNativeEnabled(true);

                if (questionEditor.DialogResult == DialogResult.OK)
                {
                    editor.changes = true;

                    Question q = questionEditor.GetQuestion();

                    question.question       = q.question;
                    question.answers        = q.answers;
                    question.multipleChoice = q.multipleChoice;

                    int prvHeight = Height;

                    RefreshControls();

                    foreach (QPanel panel in owner.Controls)
                    {
                        if (panel == this)
                        {
                            continue;
                        }

                        if (panel.ID > ID)
                        {
                            panel.Top -= prvHeight - Height;
                        }
                    }
                }
            };

            questionEditor.Show();
        }
Exemple #2
0
        internal void AddQuestion(Question q = null, bool scrollToEnd = false)
        {
            SetNativeEnabled(false);

            var questionEditor = new QuestionEditor(q, s => !questions.Any(x => x.question == s));

            questionEditor.FormClosing += (s, e) =>
            {
                SetNativeEnabled(true);
                Focus();

                if (questionEditor.DialogResult == DialogResult.OK)
                {
                    changes = true;

                    Question question = questionEditor.GetQuestion();
                    questions.Add(question);

                    var questionPanel = new QPanel(QuestionPanel, question, QuestionPanel.Controls.Count);

                    AddPanel(questionPanel);

                    if (scrollToEnd)
                    {
                        QuestionPanel.VerticalScroll.Value = 0;
                        QuestionPanel.ScrollControlIntoView(questionPanel);
                    }

                    RefreshOK();

                    foreach (var control in QuestionPanel.Controls)
                    {
                        QPanel qPanel = control as QPanel;

                        qPanel.ID = qPanel.ID;
                    }
                }
            };

            questionEditor.Show();
        }