private void DataToControls(ALotOrALittle data) { switch (data.Category) { case ALotOrAlittleElements.EducationalValue: lbSectionTitle.Text = "Educational Value"; pbCategory.Image = Properties.Resources.educational_value; break; case ALotOrAlittleElements.PositiveMessages: lbSectionTitle.Text = "Positive Messages"; pbCategory.Image = Properties.Resources.positive_messages; break; case ALotOrAlittleElements.PositiveRoleModelsAndRepresentations: lbSectionTitle.Text = "Positive Role Models && Representations"; pbCategory.Image = Properties.Resources.positive_role_models; break; case ALotOrAlittleElements.ViolenceAndScariness: lbSectionTitle.Text = "Violence && Scariness"; pbCategory.Image = Properties.Resources.violence; break; case ALotOrAlittleElements.SexyStuff: lbSectionTitle.Text = "Sexy Stuff"; pbCategory.Image = Properties.Resources.sexy_stuff; break; case ALotOrAlittleElements.Language: lbSectionTitle.Text = "Language"; pbCategory.Image = Properties.Resources.language; break; case ALotOrAlittleElements.Consumerism: lbSectionTitle.Text = "Consumerism"; pbCategory.Image = Properties.Resources.consumerism; break; case ALotOrAlittleElements.DrinkingDrugsAndSmoking: lbSectionTitle.Text = "Drinking, Drugs && Smoking"; pbCategory.Image = Properties.Resources.drinking_druge_smoking; break; } if (data.Rating > 0) { pbRating.Visible = true; GraphicsHelpers.DrawRating(data.Rating, pbRating, new Font("Microsoft Sans Serif", 20, FontStyle.Regular), "●"); } lbExplanation.Text = data.Description; }
private void DataToControls(CSMScrapeResult csmData) { lbGreenAge.Text = csmData.GreenAge; GraphicsHelpers.DrawRating(csmData.Rating, pbCSMRating, new Font("Microsoft Sans Serif", 24, FontStyle.Regular), "⋆"); var tt = new ToolTip(); tt.IsBalloon = true; tt.AutoPopDelay = 20000; tt.SetToolTip( pbInfo, string.Format( "The ratings are based on child{0}development best practices.{0}We display the minimum age{0}for which content is{0}developmentally appropriate.{0}The star rating reflects overall{0}quality.", Environment.NewLine) ); lbShortDescription.Text = csmData.ShortDescription; if (string.IsNullOrEmpty(csmData.AdultRecomendedAge)) { lbAdultRecommendedAge.Text = "No reviews yet"; lbInfo1.Visible = false; } else { lbAdultRecommendedAge.Text = csmData.AdultRecomendedAge; GraphicsHelpers.DrawRating(csmData.AdultRating, pbAdultRating, new Font("Microsoft Sans Serif", 20, FontStyle.Regular), "⋆"); } if (string.IsNullOrEmpty(csmData.ChildRecomendedAge)) { lbKidsRecommendedAge.Text = "No reviews yet"; lbInfo2.Visible = false; } else { lbKidsRecommendedAge.Text = csmData.ChildRecomendedAge; GraphicsHelpers.DrawRating(csmData.ChildRating, pbKidsRating, new Font("Microsoft Sans Serif", 20, FontStyle.Regular), "⋆"); } var scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.EducationalValue); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbEducationalValue_Rating, lbEducationalValue_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.PositiveMessages); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbPositiveMessages_Rating, lbPosiviteMessages_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.PositiveRoleModelsAndRepresentations); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbPositiveRoles_Rating, lbPositiveRoles_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.ViolenceAndScariness); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbViolenceScariness_Rating, lbViolenceScariness_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.SexyStuff); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbSexyStuff_Rating, lbSexyStuff_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.Language); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbLanguage_Rating, lbLanguage_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.Consumerism); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbConsumerism_Rating, lbConsumerism_Expl); } scrapedDataObj = csmData.ALotOrALittle.FirstOrDefault(_ => _.Category == ALotOrAlittleElements.DrinkingDrugsAndSmoking); if (scrapedDataObj != null) { SetDataToControls(scrapedDataObj, pbDrinkingSmoking_Rating, lbDrinkingSmoking_Expl); } void SetDataToControls(ALotOrALittle dataObj, PictureBox pbCtrl, Label detailsLabelCtrl) { if (dataObj.Rating > 0) { pbCtrl.Visible = true; GraphicsHelpers.DrawRating(dataObj.Rating, pbCtrl, new Font("Microsoft Sans Serif", 16, FontStyle.Regular), "●"); } if (!string.IsNullOrEmpty(dataObj.Description)) { detailsLabelCtrl.Visible = true; detailsLabelCtrl.Click += (sender, e) => { var frmDetails = new FrmALotOrALittle_Explanation(dataObj); frmDetails.Owner = this; frmDetails.ShowDialog(); }; } } lbWhatParentsNeedToKnow.Text = csmData.Review; pWhatParentsNeedToKnow.Height = (lbWhatParentsNeedToKnow.Location.Y * 2) + lbWhatParentsNeedToKnow.Height; lbWhatsTheStory.Text = csmData.Story; pWhatsTheStory.Height = (lbWhatsTheStory.Location.Y * 2) + lbWhatsTheStory.Height; lbIsItAnyGood.Text = csmData.IsItAnyGood; pIsItAnyGood.Height = (lbIsItAnyGood.Location.Y * 2) + lbIsItAnyGood.Height; var totalHeight = 0; foreach (var item in csmData.TalkWithKidsAbout) { var p = new Panel(); p.Dock = DockStyle.Top; //the "Fill" must go fist! var p_text = new Panel(); p_text.Dock = DockStyle.Fill; p_text.Margin = new Padding(0); p.Controls.Add(p_text); var p_bullet = new Panel(); p_bullet.Dock = DockStyle.Left; p_bullet.Margin = new Padding(0); //p_bullet.BackColor = Color.Yellow; p_bullet.Width = 20; p.Controls.Add(p_bullet); var l_text = new Label(); l_text.AutoSize = true; l_text.Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); l_text.Location = new System.Drawing.Point(0, 8); l_text.MaximumSize = new System.Drawing.Size(570, 0); l_text.Text = item; p_text.Controls.Add(l_text); var l_bullet = new Label(); l_bullet.AutoSize = true; //l_bullet.BackColor = Color.Green; l_bullet.Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); l_bullet.Location = new System.Drawing.Point(7, 8); l_bullet.Text = "●"; p_bullet.Controls.Add(l_bullet); p.Height = l_text.Location.Y + l_text.Height; totalHeight += p.Height; pTalkAbout.Controls.Add(p); } pTalkAbout.Height = totalHeight + 8; }