public void SetDefinition(QuestionGroup qGroup) { this.titleParser = qGroup; this.uim = new QGUIMaker(this, this.titleParser); this.uim.OnContentChange += new QGUIMaker.ContentChange(uim_OnContentChange); //this.BackColor = System.Drawing.Color.LightYellow; }
public Subject(XmlElement elmSubject) { this.questionGroups = new Dictionary <string, QuestionGroup>(); this.qgs = new List <QuestionGroup>(); foreach (XmlElement elm in elmSubject.SelectNodes("QG")) { QuestionGroup qg = new QuestionGroup(elm); this.questionGroups.Add(qg.GetIdentifyLabel(), qg); this.qgs.Add(qg); } }
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(); }