/// <summary> /// Updates the recommendations. /// </summary> /// <param name="newItems">The new items list.</param> /// <param name="rSplCont">The right splitter container.</param> private void UpdateRecommendations(List <Control> newItems, PersistentSplitContainer rSplCont) { rightSplitContainer.Panel2.Controls.Clear(); if (newItems.Count != 0) { newItems.Reverse(); rSplCont.Panel2.Controls.AddRange(newItems.ToArray()); } else { Label tsl = new Label(); tsl.Dock = DockStyle.Fill; tsl.Text = "No Recommendations"; tsl.Enabled = false; tsl.TextAlign = ContentAlignment.MiddleCenter; rSplCont.Panel2.Controls.Add(tsl); Size tslTextSize = TextRenderer.MeasureText(tsl.Text, Font); rSplCont.Panel2MinSize = tslTextSize.Width + HPad; rSplCont.SplitterDistance = rSplCont.Width - rSplCont.Panel2MinSize; } }
/// <summary> /// Updates the content. /// </summary> private void UpdateContent() { // When no certificate class is selected, we just hide the right panel. if (m_selectedCertificate == null) { // View help message lblHelp.Visible = true; panelRight.Visible = false; return; } // Hide help message lblHelp.Visible = false; // Updates controls visibility panelRight.Visible = true; lblName.Text = m_selectedCertificate.Name; lblCategory.Text = m_selectedCertificate.Category.Name; textboxDescription.Text = m_selectedCertificate.Certificate.Description; // Training time per certificate level for (int i = 1; i <= 5; i++) { UpdateLevelLabel(panelHeader.Controls.OfType <Label>() .First(label => label.Name == $"lblLevel{i}Time"), i); } // Only read the recommendations from one level, because they are all the same PersistentSplitContainer rSplCont = rightSplitContainer; List <Control> newItems = new List <Control>(); SortedList <string, Item> ships = new SortedList <string, Item>(); foreach (Item ship in m_selectedCertificate.Certificate.Recommendations) { ships.Add(ship.Name, ship); } Label tempLabel = null; try { tempLabel = new Label(); tempLabel.Font = new Font(tempLabel.Font, FontStyle.Bold); tempLabel.AutoSize = true; tempLabel.Dock = DockStyle.Top; tempLabel.Text = @"Recommended For"; tempLabel.Padding = new Padding(5); Label tsl = tempLabel; tempLabel = null; newItems.Add(tsl); Size tslTextSize = TextRenderer.MeasureText(tsl.Text, Font); int panelMinSize = rSplCont.Panel2MinSize; rSplCont.Panel2MinSize = panelMinSize > tslTextSize.Width + HPad ? panelMinSize : tslTextSize.Width + HPad; rSplCont.SplitterDistance = rSplCont.Width - rSplCont.Panel2MinSize; } finally { tempLabel?.Dispose(); } foreach (LinkLabel linkLabel in ships.Values .Select(ship => { LinkLabel linkLabel; LinkLabel tempLinkLabel = null; try { tempLinkLabel = new LinkLabel(); tempLinkLabel.LinkBehavior = LinkBehavior.HoverUnderline; tempLinkLabel.Padding = new Padding(16, 0, 0, 0); tempLinkLabel.Dock = DockStyle.Top; tempLinkLabel.Text = ship.Name; tempLinkLabel.Tag = ship; linkLabel = tempLinkLabel; tempLinkLabel = null; } finally { tempLinkLabel?.Dispose(); } return(linkLabel); })) { linkLabel.MouseClick += recommendations_MenuItem; newItems.Add(linkLabel); } // Updates the recommendations for this certificate UpdateRecommendations(newItems, rSplCont); // Update the menus and such UpdateEligibility(); // Update the certificates tree display certDisplayControl.CertificateClass = m_selectedCertificate; }
/// <summary> /// Updates the recommendations. /// </summary> /// <param name="newItems">The new items list.</param> /// <param name="rSplCont">The right splitter container.</param> private void UpdateRecommendations(List<Control> newItems, PersistentSplitContainer rSplCont) { rightSplitContainer.Panel2.Controls.Clear(); if (newItems.Count != 0) { newItems.Reverse(); rSplCont.Panel2.Controls.AddRange(newItems.ToArray()); } else { Label tsl = new Label(); tsl.Dock = DockStyle.Fill; tsl.Text = "No Recommendations"; tsl.Enabled = false; tsl.TextAlign = ContentAlignment.MiddleCenter; rSplCont.Panel2.Controls.Add(tsl); Size tslTextSize = TextRenderer.MeasureText(tsl.Text, Font); rSplCont.Panel2MinSize = tslTextSize.Width + HPad; rSplCont.SplitterDistance = rSplCont.Width - rSplCont.Panel2MinSize; } }