// Get a list of question controls filtered by the specific question type & set of questions private IEnumerable<DropDownEntityControlType> GetDropDownEntityControls(AimDropDownEntityType dropDownType, List<TemplateQuestion> questionList) { string codeTypeDescription = StringValueOf(dropDownType); foreach (DropDownEntityControlType control in this.GetDropDownEntityControls(dropDownType)) { foreach (TemplateQuestion templateQuestion in questionList) { if (GetLabelForQuestion(templateQuestion.Name, codeTypeDescription) == control.Label) { yield return control; break; } } } }
private static string GetTagName(AimDropDownEntityType ddeType) { return StringValueOf(ddeType).Replace(" ", ""); }
// Get a list of question controls filtered by the specific question type private IEnumerable<DropDownEntityControlType> GetDropDownEntityControls(AimDropDownEntityType dropDownType) { string tagName = GetTagName(dropDownType); foreach (Control control in this.Controls) { if (control != null && control is DropDownEntityControlType && string.Equals((string)control.Tag, tagName)) yield return (DropDownEntityControlType)control; } }
private void AddNewDropDownEntityControls(List<TemplateQuestion> dataList, ref int controlCnt, ref int startPtY, ref string currentHeading, AimDropDownEntityType ddeType, bool isIndented) { int startPtX = isIndented ? 25 : 3; // move X to the right if indentation is desired string codeTypeDescription = StringValueOf(ddeType); string controlTag = GetTagName(ddeType); foreach (TemplateQuestion question in dataList) { // Add Heading string questionHeading = GetQuestionHeading(question.Name); if (questionHeading != currentHeading) { Label lblHeading = new Label(); lblHeading.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; // lblHeading.AutoSize = true; lblHeading.AutoEllipsis = true; lblHeading.Location = new System.Drawing.Point(startPtX, startPtY); lblHeading.TextAlign = ContentAlignment.MiddleLeft; lblHeading.Font = new Font(lblHeading.Font.FontFamily, lblHeading.Font.Size + 3F, FontStyle.Bold); lblHeading.Text = questionHeading ?? "Empty Heading"; //lblHeading.BackColor = SystemColors.MenuHighlight; //lblHeading.ForeColor = SystemColors.MenuText; lblHeading.Size = new Size(this.Width - this.Margin.Horizontal - C_VerticalScrollbarWidth - (isIndented ? 20 : 0), lblHeading.Height); startPtY += lblHeading.Height + 3; controlCnt++; this.Controls.Add(lblHeading); currentHeading = questionHeading; } // Add Question Drop Down DropDownEntityControlType ddEnt = new DropDownEntityControlType(GetLabelForQuestion(question.Name, codeTypeDescription), question.Codes, question.Description, question.Codes.Count > 1, question.AllowMultipleAnswers); ddEnt.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; ddEnt.Location = new System.Drawing.Point(startPtX, startPtY); ddEnt.Name = "dddEnt" + controlCnt; ddEnt.Size = new Size(this.Width - this.Margin.Horizontal - C_VerticalScrollbarWidth - (isIndented ? 20 : 0), ddEnt.Height); ddEnt.TabIndex = controlCnt; ddEnt.Tag = controlTag; // "ImagingObservationCharacteristic"; ddEnt.SelectedAnswerChanged += OnSelectedFeatureChanged; // Do not display controls with a single answer, that will be selected by default if (question.Codes.Count > 1) startPtY += ddEnt.Height + 3; else ddEnt.Visible = false; controlCnt++; this.Controls.Add(ddEnt); } }