Пример #1
0
        private void makeUI()
        {
            this.subj = new Parser.Subject(this.xmlSubjectDef);

            this.questionGroupPanels = new Dictionary <string, QGPanel>();

            //foreach (XmlElement elm in this.xmlSubjectDef.SelectNodes("QG"))
            //{
            foreach (Parser.QuestionGroup qGroup in this.subj.GetQuestionGroups())
            {
                QGPanel pn = new QGPanel();
                pn.Width = this.pnlContainer.Width - 10;
                pn.SetDefinition(qGroup);
                //pn.SetDefinition(elm);
                //pn.SetAnswer(this.xmlAnswers);
                //this.flowLayoutPanel1.Controls.Add(pn);
                Point p = new Point(this.padding, this.y_pos + this.padding);
                pn.Location = p;

                pn.OnContentChange += new QGPanel.ContentChange(pn_OnContentChange);

                this.pnlContainer.Controls.Add(pn);
                this.y_pos = pn.Location.Y + pn.Height;

                this.questionGroupPanels.Add(pn.GetIdentifyLabel(), pn);
            }

            this.pnlContainer.Height = this.y_pos + 5;
        }
        private void showPreview(Parser.QuestionGroup qgroup)
        {
            QGPanel pnl = new QGPanel();

            pnl.Width = this.pnlPreview.Width - 10;
            pnl.SetDefinition(qgroup);
            pnl.Top  = 5;
            pnl.Left = 5;

            this.pnlPreview.Controls.Clear();
            this.pnlPreview.Controls.Add(pnl);
        }
Пример #3
0
        private void makeUI()
        {
            this.subj = new Parser.Subject(this.xmlSubjectDef);

            this.questionGroupPanels = new Dictionary<string, QGPanel>();

            //foreach (XmlElement elm in this.xmlSubjectDef.SelectNodes("QG"))
            //{
            foreach (Parser.QuestionGroup qGroup in this.subj.GetQuestionGroups())
            {
                QGPanel pn = new QGPanel();
                pn.Width = this.pnlContainer.Width - 10;
                pn.SetDefinition(qGroup);
                //pn.SetDefinition(elm);
                //pn.SetAnswer(this.xmlAnswers);
                //this.flowLayoutPanel1.Controls.Add(pn);
                Point p = new Point(this.padding, this.y_pos + this.padding);
                pn.Location = p;

                pn.OnContentChange += new QGPanel.ContentChange(pn_OnContentChange);

                this.pnlContainer.Controls.Add(pn);
                this.y_pos = pn.Location.Y + pn.Height;

                this.questionGroupPanels.Add(pn.GetIdentifyLabel(), pn);
            }

            this.pnlContainer.Height = this.y_pos + 5;
        }
        private void showPreview(Parser.QuestionGroup qgroup)
        {
            QGPanel pnl = new QGPanel();
            pnl.Width = this.pnlPreview.Width - 10;
            pnl.SetDefinition(qgroup);
            pnl.Top = 5;
            pnl.Left = 5;

            this.pnlPreview.Controls.Clear();
            this.pnlPreview.Controls.Add(pnl);
        }
Пример #5
0
        private TextBoxDropDownDecorator textBoxDropDownDecorator; //用來處理 TextBoxDropDown 控制項以及 CheckedListBox 互動的 Decorator 物件

        #endregion Fields

        #region Constructors

        public QGUIMaker(QGPanel pnl, QuestionGroup questionGroup)
        {
            this.pnlQGroup = pnl;
            this.questionGroup = questionGroup;
            this.pnlQGroup.FlowDirection = FlowDirection.TopDown;   // why?

            adjHeight();

            //Make Header :
            Font font = this.pnlQGroup.Font;
            SizeF stringSize = pnl.CreateGraphics().MeasureString(this.questionGroup.GetLabel(), font);

            TextBox lbl = new TextBox();
            lbl.Multiline = true;
            lbl.BorderStyle = BorderStyle.None;
            lbl.ReadOnly = true;
            lbl.BackColor = Color.White;
            lbl.Width = 80; //default width
            if (this.questionGroup.GetLabelVisible())
            {
                if (!string.IsNullOrEmpty(this.questionGroup.GetLabelWidth()))
                {
                    int width = 0;
                    bool isNumber = int.TryParse(this.questionGroup.GetLabelWidth(), out width);
                    if (isNumber)
                        lbl.Width = width;
                }
            }
            else
                lbl.Width = 0;

            //lbl.Width = (this.questionGroup.GetLabelVisible() ? 80 : 0);
            lbl.Height = (lbl.Width == 0) ? 0 : 20 * ((int)stringSize.Width / lbl.Width + 1);
            lbl.Text = this.questionGroup.GetLabel() + ":";
            System.Windows.Forms.Padding margin = lbl.Margin;
            margin.Top = 10;
            lbl.Margin = margin;
            this.pnlQGroup.Controls.Add(lbl);

            /*
            Label lbl = new Label();
            lbl.Width = (int)stringSize.Width + 20;
            lbl.Height = 25;
            lbl.Top = 4;
            lbl.Text = this.questionGroup.GetLabel() + ":";
            System.Windows.Forms.Padding margin = lbl.Margin;
            margin.Top = 10;
            lbl.Margin = margin;
            //lbl.BackColor = System.Drawing.Color.Red;
            this.pnlQGroup.Controls.Add(lbl);
            */

            //make content panel
            this.contentPanel = new FlowLayoutPanel();
            this.contentPanel.FlowDirection = FlowDirection.LeftToRight;
            this.contentPanel.Height = this.pnlQGroup.Height - lbl.Height + 10;
            this.contentPanel.Width = this.pnlQGroup.Width - lbl.Width - 10;
            this.contentPanel.WrapContents = true;
            //this.contentPanel.BackColor = System.Drawing.Color.Green;
            this.pnlQGroup.Controls.Add(this.contentPanel);

            this.allQControls = new Dictionary<string, Control>();

            makeUI();
        }
Пример #6
0
        private Dictionary <string, Control> allQControls;  //紀錄所有題目的控制項,以利後續設定答案時使用。

        public QGUIMaker(QGPanel pnl, QuestionGroup questionGroup)
        {
            this.pnlQGroup               = pnl;
            this.questionGroup           = questionGroup;
            this.pnlQGroup.FlowDirection = FlowDirection.TopDown;   // why?

            adjHeight();

            //Make Header :
            Font  font       = this.pnlQGroup.Font;
            SizeF stringSize = pnl.CreateGraphics().MeasureString(this.questionGroup.GetLabel(), font);

            TextBox lbl = new TextBox();

            lbl.Multiline   = true;
            lbl.BorderStyle = BorderStyle.None;
            lbl.ReadOnly    = true;
            lbl.BackColor   = Color.White;
            lbl.Width       = 80; //default width
            if (this.questionGroup.GetLabelVisible())
            {
                if (!string.IsNullOrEmpty(this.questionGroup.GetLabelWidth()))
                {
                    int  width    = 0;
                    bool isNumber = int.TryParse(this.questionGroup.GetLabelWidth(), out width);
                    if (isNumber)
                    {
                        lbl.Width = width;
                    }
                }
            }
            else
            {
                lbl.Width = 0;
            }



            //lbl.Width = (this.questionGroup.GetLabelVisible() ? 80 : 0);
            lbl.Height = (lbl.Width == 0) ? 0 : 20 * ((int)stringSize.Width / lbl.Width + 1);
            lbl.Text   = this.questionGroup.GetLabel() + ":";
            System.Windows.Forms.Padding margin = lbl.Margin;
            margin.Top = 10;
            lbl.Margin = margin;
            this.pnlQGroup.Controls.Add(lbl);

            /*
             * Label lbl = new Label();
             * lbl.Width = (int)stringSize.Width + 20;
             * lbl.Height = 25;
             * lbl.Top = 4;
             * lbl.Text = this.questionGroup.GetLabel() + ":";
             * System.Windows.Forms.Padding margin = lbl.Margin;
             * margin.Top = 10;
             * lbl.Margin = margin;
             * //lbl.BackColor = System.Drawing.Color.Red;
             * this.pnlQGroup.Controls.Add(lbl);
             */

            //make content panel
            this.contentPanel = new FlowLayoutPanel();
            this.contentPanel.FlowDirection = FlowDirection.LeftToRight;
            this.contentPanel.Height        = this.pnlQGroup.Height - lbl.Height + 10;
            this.contentPanel.Width         = this.pnlQGroup.Width - lbl.Width - 10;
            this.contentPanel.WrapContents  = true;
            //this.contentPanel.BackColor = System.Drawing.Color.Green;
            this.pnlQGroup.Controls.Add(this.contentPanel);

            this.allQControls = new Dictionary <string, Control>();

            makeUI();
        }