Пример #1
0
        private void QuestionsEditor_Load(object sender, EventArgs e)
        {
            SuspendDrawing(this);
            QuestionControls controls = new QuestionControls();

            controls.label   = lbl_qn1; controls.question = rtb_question1;
            controls.optiona = rtb_optiona1; controls.optionb = rtb_optionb1;
            controls.optionc = rtb_optionc1; controls.optiond = rtb_optiond1;
            controls.selecta = radio_a; controls.selectb = radio_b;
            controls.selectc = radio_c; controls.selectd = radio_d;
            controls.panel   = pnl_question;
            m_questionControls.Add(controls);

            pnl_passage        = pnl_question.Clone();
            rtb_passage        = rtb_question1.Clone();
            rtb_passage.Parent = pnl_passage;
            rtb_passage.Show();
            pnl_passage.Parent = pnl_holder;
            lbl_passage        = new Label();
            lbl_passage.Show();
            lbl_passage.Text   = PassageTitle;
            lbl_passage.Left   = 5;
            lbl_passage.Width  = pnl_passage.Width;
            lbl_passage.Parent = pnl_passage;
            lbl_passage.Font   = new Font(pnl_passage.Font, FontStyle.Bold);
            pnl_passage.Hide();

            lbl_groupA.Hide();
            lbl_groupB.Hide();

            pnl_title.Visible = pnl_question.Visible = true;

            for (int i = 1; i < m_questionsPerPage; ++i)
            {
                controls          = new QuestionControls();
                controls.label    = lbl_qn1.Clone();
                controls.question = rtb_question1.Clone();
                controls.optiona  = rtb_optiona1.Clone();
                controls.optionb  = rtb_optionb1.Clone();
                controls.optionc  = rtb_optionc1.Clone();
                controls.optiond  = rtb_optiond1.Clone();
                controls.selecta  = radio_a.Clone();
                controls.selectb  = radio_b.Clone();
                controls.selectc  = radio_c.Clone();
                controls.selectd  = radio_d.Clone();
                controls.panel    = pnl_question.Clone();


                controls.ChangeParent();

                controls.question.Tag = "qn" + i;
                controls.optiona.Tag  = "oa" + i;
                controls.optionb.Tag  = "ob" + i;
                controls.optionc.Tag  = "oc" + i;
                controls.optiond.Tag  = "od" + i;

                controls.selecta.Tag = controls.selectb.Tag = controls.selectc.Tag = controls.selectd.Tag = i.ToString();

                m_questionControls.Add(controls);
            }

            rtb_passage.ContentsResized += new ContentsResizedEventHandler(content_resized);
            foreach (QuestionControls c in m_questionControls)
            {
                c.question.ContentsResized += new ContentsResizedEventHandler(content_resized);
                c.optiona.ContentsResized  += new ContentsResizedEventHandler(content_resized);
                c.optionb.ContentsResized  += new ContentsResizedEventHandler(content_resized);
                c.optionc.ContentsResized  += new ContentsResizedEventHandler(content_resized);
                c.optiond.ContentsResized  += new ContentsResizedEventHandler(content_resized);

                c.question.Text = c.optiona.Text = c.optionb.Text = c.optionc.Text = c.optiond.Text = "\n";
                c.question.Text = c.optiona.Text = c.optionb.Text = c.optionc.Text = c.optiond.Text = "";

                c.question.GotFocus += new EventHandler(delegate(Object o, EventArgs a)
                {
                    c.label.Focus();
                });

                c.optiona.GotFocus += new EventHandler(delegate(Object o, EventArgs a)
                {
                    c.selecta.Focus();
                    c.selecta.Checked = true;
                });
                c.optionb.GotFocus += new EventHandler(delegate(Object o, EventArgs a)
                {
                    c.selectb.Focus();
                    c.selectb.Checked = true;
                });
                c.optionc.GotFocus += new EventHandler(delegate(Object o, EventArgs a)
                {
                    c.selectc.Focus();
                    c.selectc.Checked = true;
                });
                c.optiond.GotFocus += new EventHandler(delegate(Object o, EventArgs a)
                {
                    c.selectd.Focus();
                    c.selectd.Checked = true;
                });

                EventHandler onchecked = new EventHandler(delegate(Object o, EventArgs a)
                {
                    RadioButton r = (RadioButton)o;
                    String tag    = r.Tag.ToString();
                    int qn        = Int32.Parse(tag);
                    m_answers[m_currentPage * m_questionsPerPage + qn] = m_questionControls[qn].GetSelected();
                });
                c.selecta.CheckedChanged += onchecked;
                c.selectb.CheckedChanged += onchecked;
                c.selectc.CheckedChanged += onchecked;
                c.selectd.CheckedChanged += onchecked;
            }

            RefreshQuestions();
            RefreshControls();

            LoadSets();

            for (int i = 0; i < m_sets.Length; ++i)
            {
                ToolStripItem item = menu_item_change_set.DropDownItems.Add("Set " + (i + 1));
                item.Tag    = i;
                item.Click += new EventHandler(set_changed);
            }

            m_timer                     = new System.Timers.Timer(1000);
            m_timer.Elapsed            += new System.Timers.ElapsedEventHandler(time_elapsed);
            m_timer.SynchronizingObject = this;

            pnl_holder.Hide();
            pnl_bottom.Hide();
            m_loginscreen          = new FormLogIn(this);
            m_loginscreen.TopLevel = false;
            m_loginscreen.Parent   = this;
            m_loginscreen.Show();
            ResumeDrawing(this);
        }
Пример #2
0
 // 생성한 문제 컨트롤을 패널에 넣어준다
 public void AddQuestionControl(BaseQuestionControl question)
 {
     question.Dock = DockStyle.Bottom;
     pnlBoard.Controls.Add(question);
     QuestionControls.Add(question);
 }
        private void QuestionsEditor_Load(object sender, EventArgs e)
        {
            QuestionControls controls = new QuestionControls();

            controls.label   = lbl_qn1; controls.question = rtb_question1;
            controls.optiona = rtb_optiona1; controls.optionb = rtb_optionb1;
            controls.optionc = rtb_optionc1; controls.optiond = rtb_optiond1;
            controls.paste   = btn_paste; controls.insert = btn_insert; controls.remove = btn_remove;
            m_questionControls.Add(controls);
            m_questions.Add(new Question());

            int distance = 300;
            int shift    = distance;

            for (int i = 1; i < m_questionsPerPage; ++i)
            {
                controls          = new QuestionControls();
                controls.label    = lbl_qn1.Clone();
                controls.question = rtb_question1.Clone();
                controls.optiona  = rtb_optiona1.Clone();
                controls.optionb  = rtb_optionb1.Clone();
                controls.optionc  = rtb_optionc1.Clone();
                controls.optiond  = rtb_optiond1.Clone();
                controls.paste    = btn_paste.Clone();
                controls.insert   = btn_insert.Clone();
                controls.remove   = btn_remove.Clone();

                controls.label.Top    += shift;
                controls.question.Top += shift;
                controls.optiona.Top  += shift;
                controls.optionb.Top  += shift;
                controls.optionc.Top  += shift;
                controls.optiond.Top  += shift;
                controls.paste.Top    += shift;
                controls.insert.Top   += shift;
                controls.remove.Top   += shift;

                controls.question.Tag = "qn" + i;
                controls.optiona.Tag  = "oa" + i;
                controls.optionb.Tag  = "ob" + i;
                controls.optionc.Tag  = "oc" + i;
                controls.optiond.Tag  = "od" + i;
                controls.paste.Tag    = i + "";
                controls.insert.Tag   = i + "";
                controls.remove.Tag   = i + "";

                shift += distance;

                m_questionControls.Add(controls);
                m_questions.Add(new Question());
            }

            // A little extra space at the bottom
            Panel extra = new Panel();

            extra.Top    = shift;
            extra.Height = 20;
            extra.Parent = pnl_holder;

            RefreshQuestions();

            foreach (QuestionControls c in m_questionControls)
            {
                c.question.TextChanged += new EventHandler(text_changed);
                c.optiona.TextChanged  += new EventHandler(text_changed);
                c.optionb.TextChanged  += new EventHandler(text_changed);
                c.optionc.TextChanged  += new EventHandler(text_changed);
                c.optiond.TextChanged  += new EventHandler(text_changed);

                c.question.SelectionChanged += new EventHandler(selection_changed);
                c.optiona.SelectionChanged  += new EventHandler(selection_changed);
                c.optionb.SelectionChanged  += new EventHandler(selection_changed);
                c.optionc.SelectionChanged  += new EventHandler(selection_changed);
                c.optiond.SelectionChanged  += new EventHandler(selection_changed);

                c.paste.Click  += new EventHandler(paste_clicked);
                c.insert.Click += new EventHandler(insert_question);
                c.remove.Click += new EventHandler(delete_question);
            }
        }
        public void paste_clicked(object _sender, EventArgs args)
        {
            Button           sender   = (Button)_sender;
            int              index    = Int32.Parse(sender.Tag.ToString());
            QuestionControls controls = m_questionControls[index];

            controls.question.Paste();

            Match match   = new Regex(@"\A\s*\d+\.\s?").Match(controls.question.Text);
            int   startid = 0;

            if (match.Success)
            {
                startid = match.Index + match.Length;
            }

            match = new Regex(@"\s*a\)\s?").Match(controls.question.Text, startid);
            if (!match.Success)
            {
                return;
            }
            int id = match.Index + match.Length;

            controls.question.Select(startid, id - startid - match.Length);
            string question = controls.question.SelectedRtf;

            match = new Regex(@"b\)\s?").Match(controls.question.Text, id);
            if (!match.Success)
            {
                return;
            }
            int nid = match.Index + match.Length;

            controls.question.Select(id, nid - id - match.Length);
            controls.optiona.Rtf = controls.question.SelectedRtf;

            id    = nid;
            match = new Regex(@"c\)\s?").Match(controls.question.Text, id);
            if (!match.Success)
            {
                return;
            }
            nid = match.Index + match.Length;
            controls.question.Select(id, nid - id - match.Length);
            controls.optionb.Rtf = controls.question.SelectedRtf;

            id    = nid;
            match = new Regex(@"d\)\s?").Match(controls.question.Text, id);
            if (!match.Success)
            {
                return;
            }
            nid = match.Index + match.Length;
            controls.question.Select(id, nid - id - match.Length);
            controls.optionc.Rtf = controls.question.SelectedRtf;

            id    = nid;
            match = new Regex(@"(?m)^\s*\d+\.\s?").Match(controls.question.Text, id);
            String remaining = "";

            if (match.Success)
            {
                nid = match.Index;
                controls.question.Select(nid, controls.question.Text.Length);
                remaining = controls.question.SelectedRtf;
            }
            else
            {
                nid = controls.question.Text.Length;
            }
            controls.question.Select(id, nid - id);
            controls.optiond.Rtf = controls.question.SelectedRtf;

            controls.question.Rtf = question;
        }
        private void QuestionsEditor_Load(object sender, EventArgs e)
        {
            QuestionControls controls = new QuestionControls();
            controls.label = lbl_qn1; controls.question = rtb_question1;
            controls.optiona = rtb_optiona1; controls.optionb = rtb_optionb1;
            controls.optionc = rtb_optionc1; controls.optiond = rtb_optiond1;
            controls.paste = btn_paste; controls.insert = btn_insert; controls.remove = btn_remove;
            m_questionControls.Add(controls);
            m_questions.Add(new Question());

            int distance = 300;
            int shift = distance;
            for (int i = 1; i < m_questionsPerPage; ++i)
            {
                controls = new QuestionControls();
                controls.label = lbl_qn1.Clone();
                controls.question = rtb_question1.Clone();
                controls.optiona = rtb_optiona1.Clone();
                controls.optionb = rtb_optionb1.Clone();
                controls.optionc = rtb_optionc1.Clone();
                controls.optiond = rtb_optiond1.Clone();
                controls.paste = btn_paste.Clone();
                controls.insert = btn_insert.Clone();
                controls.remove = btn_remove.Clone();

                controls.label.Top += shift;
                controls.question.Top += shift;
                controls.optiona.Top += shift;
                controls.optionb.Top += shift;
                controls.optionc.Top += shift;
                controls.optiond.Top += shift;
                controls.paste.Top += shift;
                controls.insert.Top += shift;
                controls.remove.Top += shift;

                controls.question.Tag = "qn" + i;
                controls.optiona.Tag = "oa" + i;
                controls.optionb.Tag = "ob" + i;
                controls.optionc.Tag = "oc" + i;
                controls.optiond.Tag = "od" + i;
                controls.paste.Tag = i + "";
                controls.insert.Tag = i + "";
                controls.remove.Tag = i + "";

                shift += distance;

                m_questionControls.Add(controls);
                m_questions.Add(new Question());
            }

            // A little extra space at the bottom
            Panel extra = new Panel();
            extra.Top = shift;
            extra.Height = 20;
            extra.Parent = pnl_holder;

            RefreshQuestions();

            foreach (QuestionControls c in m_questionControls)
            {
                c.question.TextChanged += new EventHandler(text_changed);
                c.optiona.TextChanged += new EventHandler(text_changed);
                c.optionb.TextChanged += new EventHandler(text_changed);
                c.optionc.TextChanged += new EventHandler(text_changed);
                c.optiond.TextChanged += new EventHandler(text_changed);

                c.question.SelectionChanged += new EventHandler(selection_changed);
                c.optiona.SelectionChanged += new EventHandler(selection_changed);
                c.optionb.SelectionChanged += new EventHandler(selection_changed);
                c.optionc.SelectionChanged += new EventHandler(selection_changed);
                c.optiond.SelectionChanged += new EventHandler(selection_changed);

                c.paste.Click += new EventHandler(paste_clicked);
                c.insert.Click += new EventHandler(insert_question);
                c.remove.Click += new EventHandler(delete_question);
            }
        }