/// <summary> /// Tries the assign missing title and description. /// </summary> /// <returns></returns> public bool TryAssignMissingTitleAndDescription() { if (!String.IsNullOrEmpty(Title) && !String.IsNullOrEmpty(Description)) { return(true); } // Find the related medal in the corporation's medals Medal corporationMedal = m_ccpCharacter.CorporationMedals.SingleOrDefault(corpMedal => corpMedal.ID == ID); if (corporationMedal == null) { return(false); } if (String.IsNullOrEmpty(Title)) { Title = corporationMedal.Title; } if (String.IsNullOrEmpty(Description)) { Description = corporationMedal.Description; } return(true); }
/// <summary> /// Displays the tooltip for the given item (medal). /// </summary> /// <param name="item"></param> private void DisplayTooltip(Medal item) { if (ttToolTip.Active && m_lastTooltipItem != null && m_lastTooltipItem == item) return; m_lastTooltipItem = item; ttToolTip.Active = false; ttToolTip.SetToolTip(lbMedals, GetTooltipText(item)); ttToolTip.Active = true; }
/// <summary> /// Gets the tooltip text. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> private static string GetTooltipText(Medal item) { StringBuilder toolTip = new StringBuilder(); toolTip .Append($"Issuer: {item.Issuer}") .AppendLine() .Append($"Issued: {item.Issued.ToLocalTime()}") .AppendLine(); if (item.Group == MedalGroup.OtherCorporation) { toolTip .Append($"Corporation: {item.CorporationName}") .AppendLine(); } toolTip.Append($"Reason: {item.Reason.WordWrap(50)}"); return toolTip.ToString(); }
/// <summary> /// Draws the list item for the given medal /// </summary> /// <param name="medal"></param> /// <param name="e"></param> private void DrawItem(Medal medal, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draw background g.FillRectangle(e.Index % 2 == 0 ? Brushes.White : Brushes.LightGray, e.Bounds); // Texts string medalTitleText = medal.Title; string medalDescriptionText = medal.Description; string medalStatusText = medal.Status.ToTitleCase(); string medalTimesAwardedText = $"Number of times awarded: {medal.TimesAwarded:N0}"; // Measure texts Size medalTitleTextSize = TextRenderer.MeasureText(g, medalTitleText, m_medalsBoldFont, Size.Empty, Format); Size medalDescriptionTextSize = TextRenderer.MeasureText(g, medalDescriptionText, m_medalsFont, Size.Empty, Format); Size medalStatusTextSize = TextRenderer.MeasureText(g, medalStatusText, m_medalsBoldFont, Size.Empty, Format); Size medalTimesAwardedTextSize = TextRenderer.MeasureText(g, medalTimesAwardedText, m_medalsFont, Size.Empty, Format); // Draw texts TextRenderer.DrawText(g, medalTitleText, m_medalsBoldFont, new Rectangle(e.Bounds.Left + m_medalImage.Width + 4 + PadRight, e.Bounds.Top + PadTop, medalTitleTextSize.Width + PadLeft, medalTitleTextSize.Height), Color.Black); TextRenderer.DrawText(g, medalTimesAwardedText, m_medalsFont, new Rectangle(e.Bounds.Left + m_medalImage.Width + 4 + PadRight * 3 + medalTitleTextSize.Width, e.Bounds.Top + PadTop, medalTimesAwardedTextSize.Width + PadLeft, medalTimesAwardedTextSize.Height), Color.Black); TextRenderer.DrawText(g, medalStatusText, m_medalsBoldFont, new Rectangle(e.Bounds.Right - PadRight - medalStatusTextSize.Width, e.Bounds.Top + PadTop, medalStatusTextSize.Width + PadLeft, medalStatusTextSize.Height), Color.Black); TextRenderer.DrawText(g, medalDescriptionText, m_medalsFont, new Rectangle(e.Bounds.Left + m_medalImage.Width + 4 + PadRight, e.Bounds.Top + PadTop + medalTitleTextSize.Height, medalDescriptionTextSize.Width + PadLeft, medalDescriptionTextSize.Height), Color.Black); // Draw images if (Settings.UI.SafeForWork) return; // Draw the medal image g.DrawImage(m_medalImage, new Rectangle(e.Bounds.Left + PadLeft / 2, MedalDetailHeight / 2 - m_medalImage.Height / 2 + e.Bounds.Top, m_medalImage.Width, m_medalImage.Height)); }