Example #1
0
        private void AnswerAdd_Click(object sender, EventArgs e) // add new answer item
        {
            int nextSlide;

            if (!doRefresh)
            {
                nextSlide = -1;
            }
            else
            {
                nextSlide = answerList[answerList.Count - 1].getActiveVariantRealNumber();
            }

            Answer newAnswer = new Answer(answerList.Count);

            newAnswer.value = string.Concat("Вариант №", answerList.Count + 1);
            AnswerItemUC newAnswerItem = new AnswerItemUC();

            newAnswerItem.setNextSlides(availableSlides, nextSlide);
            newAnswerItem.GetTextBox1().Text = newAnswer.value;

            //newAnswerItem.editItemEvent += answerEdit;
            newAnswerItem.deleteItemEvent += answerDelete;
            newAnswerItem.nextSlideEvent  += answerNextSlideEdit;

            answerList.Add(newAnswerItem);
            flowLayoutPanel1.Controls.Add(newAnswerItem);

            if (doRefresh)
            {
                refresh();
            }
        }
Example #2
0
        //private void answerEdit(AnswerItemUC sender)
        //{
        //    int index = answerList.IndexOf(sender);
        //}

        private void answerDelete(AnswerItemUC sender)
        {
            int index = answerList.IndexOf(sender);

            flowLayoutPanel1.Controls.RemoveAt(index);
            answerList.RemoveAt(index);

            refresh();
        }
Example #3
0
        private void answerNextSlideEdit(AnswerItemUC sender)
        {
            //int next;
            //if (!sender.GetTextBox1().Text.Equals("<Конец>"))
            //    next = short.Parse(sender.GetTextBox1().Text.Split(':')[0]) - 1;
            //else
            //    next = -1;

            //int index = answerList.IndexOf(sender);
            //if (!index.Equals(-1))
            //    slide.answers[index].nextSlideNumber = next;
            //else if (sender.Equals(answerCustom))
            //    answerCustom.nextSlideNumber = next;
            //else
            //    answerText.nextSlideNumber = next;

            //if (comboBox1.SelectedItem.Equals(enumToString(AnswerType.many)))
            //{
            //    foreach (Answer answer in slide.answers)
            //    {
            //        answer.nextSlideNumber = next;
            //    }

            //    answerCustom.nextSlideNumber = next;
            //}

            if (comboBox1.SelectedItem.Equals(enumToString(AnswerType.many)))
            {
                int next = sender.getActiveVariantNumber();
                foreach (AnswerItemUC answerItem in answerList)
                {
                    answerItem.setActiveVariant(next);
                }
                answerCustomItem.setActiveVariant(next);
            }

            refresh();
        }
Example #4
0
        public EditSlideUC(Test test, Slide slide, MainForm owner) : base(owner)
        {
            InitializeComponent();
            this.test  = test;
            this.slide = slide;
            Owner      = owner;

            updatePhoto();

            // Setting up link for answerCustom obj
            //foreach (Answer answer in slide.answers)
            //{
            //    if (answer.isCustom)
            //    {
            //        answerCustom = answer;
            //        break;
            //    }
            //}

            //if (answerCustom.Equals(null))
            //{
            //    answerCustom = new Answer(0, true);
            //}

            // -Init answers-
            updateAvailableSlides();

            bool cust = true;

            // Init text answer
            if (slide.answerType.Equals(AnswerType.text) && (!slide.answers.Count.Equals(0)))
            {
                answerText = slide.answers[0];
            }
            else
            {
                answerText       = new Answer(0);
                answerText.value = "Плейсхолдер для респондента";
            }
            answerTextItem.GetTextBox1().Text = answerText.value;
            answerTextItem.setNextSlides(availableSlides, answerText.nextSlideNumber);

            if ((!slide.answerType.Equals(AnswerType.text)) && (!slide.answers.Count.Equals(0)))
            {
                foreach (Answer answer in slide.answers)
                {
                    if (!answer.isCustom)
                    {
                        AnswerItemUC answerItem       = new AnswerItemUC();
                        answerItem.GetTextBox1().Text = answer.value;
                        answerItem.setNextSlides(availableSlides, answer.nextSlideNumber);
                        answerItem.nextSlideEvent  += answerNextSlideEdit;
                        answerItem.deleteItemEvent += answerDelete;
                        answerList.Add(answerItem);
                        flowLayoutPanel1.Controls.Add(answerItem);
                    }
                    else
                    {
                        cust         = false;
                        answerCustom = answer;
                    }
                }
            }
            else
            {
                AnswerAdd_Click(null, null);
                AnswerAdd_Click(null, null);

                answerList[0].setActiveVariant(answerTextItem.getActiveVariantNumber());
                answerList[1].setActiveVariant(answerTextItem.getActiveVariantNumber());
            }

            if (cust)
            {
                answerCustom = new Answer(answerList.Count, true);
                //answerCustom.value = "Другое";
            }
            answerCustomItem.setNextSlides(availableSlides, answerCustom.nextSlideNumber);
            answerCustomItem.nextSlideEvent += answerNextSlideEdit;
            textBox2.Text = answerCustom.value;

            // Setting text and custom controls
            answerCustomItem.GetTextBox1().Enabled = false;
            answerCustomItem.GetTextBox1().Text    = "Другое";
            answerCustomItem.setDeletable(false);
            //answerTextItem.GetTextBox1().Enabled = false;
            //answerTextItem.GetTextBox1().Text = "Плейсхолдер";
            answerTextItem.setDeletable(false);

            //if (slide.answers.Count.Equals(0))
            //    if (slide.answerType.Equals(AnswerType.text))
            //    {
            //        answerText = new Answer(0); // not reachable (cause the slide is new => type == one)
            //    }
            //    else
            //    {
            //        AnswerAdd_Click(null, null);
            //        AnswerAdd_Click(null, null);
            //    }
            //else if (slide.answerType.Equals(AnswerType.text))
            //{
            //    answerText = slide.answers[0];
            //}
            //    else
            //    {
            //        foreach (Answer answer in slide.answers)
            //        {
            //            AnswerItemUC answerItem = new AnswerItemUC();
            //            answerItem.GetTextBox1().Text = answer.value;
            //            answerItem.setNextSlides(availableSlides, answer.nextSlideNumber);
            //            answerList.Add(answerItem);
            //            flowLayoutPanel1.Controls.Add(answerItem);
            //        }
            //}


            // Setting up the dropDown for answerType
            comboBox1.Items.Clear();
            foreach (AnswerType name in Enum.GetValues(typeof(AnswerType)))
            {
                comboBox1.Items.Add(enumToString(name));
            }
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            comboBox1.SelectedItem          = enumToString(slide.answerType);

            //Simplier
            answerAdd.Click += AnswerAdd_Click;

            foreach (Control control in answerAdd.Controls)
            {
                control.Click += AnswerAdd_Click;
            }

            textBox1.Text = slide.question;

            // Prepare next slides list
            doRefresh = true;
            refresh();
        }