/// <summary> /// Draws the list item for the given standing /// </summary> /// <param name="standing"></param> /// <param name="e"></param> private void DrawItem(Standing standing, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draw background g.FillRectangle(e.Index % 2 == 0 ? Brushes.White : Brushes.LightGray, e.Bounds); Skill diplomacySkill = Character.Skills[DBConstants.DiplomacySkillID]; Skill connectionsSkill = Character.Skills[DBConstants.ConnectionsSkillID]; SkillLevel diplomacySkillLevel = new SkillLevel(diplomacySkill, diplomacySkill.LastConfirmedLvl); SkillLevel connectionsSkillLevel = new SkillLevel(connectionsSkill, connectionsSkill.LastConfirmedLvl); // Texts string standingText = $"{standing.EntityName} {standing.EffectiveStanding:N2}"; string standingStatusText = $"({Standing.Status(standing.EffectiveStanding)})"; string standingsDetailsText = $"{(standing.StandingValue < 0 ? diplomacySkillLevel : connectionsSkillLevel)} " + $"raises your effective standing from {standing.StandingValue:N2}"; // Measure texts Size standingTextSize = TextRenderer.MeasureText(g, standingText, m_standingsBoldFont, Size.Empty, Format); Size standingStatusTextSize = TextRenderer.MeasureText(g, standingStatusText, m_standingsBoldFont, Size.Empty, Format); Size standingsDetailsTextSize = TextRenderer.MeasureText(g, standingsDetailsText, m_standingsFont, Size.Empty, Format); bool standingsDiffer = Math.Abs(standing.EffectiveStanding - standing.StandingValue) > double.Epsilon; // Draw texts TextRenderer.DrawText(g, standingText, m_standingsBoldFont, new Rectangle( e.Bounds.Left + standing.EntityImage.Width + 4, e.Bounds.Top + (standingsDiffer ? PadTop : (e.Bounds.Height - standingTextSize.Height) / 2), standingTextSize.Width + PadLeft, standingTextSize.Height), Color.Black); TextRenderer.DrawText(g, standingStatusText, m_standingsBoldFont, new Rectangle( e.Bounds.Left + standing.EntityImage.Width + 4 + standingTextSize.Width + PadRight, e.Bounds.Top + (standingsDiffer ? PadTop : (e.Bounds.Height - standingStatusTextSize.Height) / 2), standingStatusTextSize.Width + PadLeft, standingStatusTextSize.Height), GetStatusColor(Standing.Status(standing.EffectiveStanding))); if (standingsDiffer) { TextRenderer.DrawText(g, standingsDetailsText, m_standingsFont, new Rectangle( e.Bounds.Left + standing.EntityImage.Width + 4, e.Bounds.Top + PadTop + standingTextSize.Height, standingsDetailsTextSize.Width + PadLeft, standingsDetailsTextSize.Height), Color.Black); } // Draw the entity image if (Settings.UI.SafeForWork) { return; } g.DrawImage(standing.EntityImage, new Rectangle(e.Bounds.Left + PadLeft / 2, StandingDetailHeight / 2 - standing.EntityImage.Height / 2 + e.Bounds.Top, standing.EntityImage.Width, standing.EntityImage.Height)); }
/// <summary> /// Parses the notification text. /// </summary> /// <param name="notification">The notification.</param> /// <param name="pair">The pair.</param> /// <param name="parsedDict">The parsed dictionary.</param> public override void Parse(EveNotification notification, KeyValuePair <YamlNode, YamlNode> pair, IDictionary <string, string> parsedDict) { string key = pair.Key.ToString(), value = pair.Value.ToString(); long valueAsLong; decimal amount; double valueAsDouble; int typeID = notification.TypeID; DateTime timestamp = notification.SentDate; YamlSequenceNode typeIDs; // The value is often used as an int64 in the list below, simplify calculation if (!value.TryParseInv(out valueAsLong)) { valueAsLong = 0L; } switch (key.ToUpperInvariant()) { case "CHARID": case "SENDERCHARID": case "RECEIVERCHARID": case "OWNERID": case "LOCATIONOWNERID": case "DESTROYERID": case "INVOKINGCHARID": case "PODKILLERID": case "NEWCEOID": case "OLDCEOID": case "CORPID": case "VICTIMID": case "DECLAREDBYID": case "AGAINSTID": case "CREDITORID": case "FACTIONID": case "DEFENDERID": case "ENEMYID": case "AGGRESSORID": case "ALLYID": case "MERCID": case "AGGRESSORCORPID": case "AGGRESSORALLIANCEID": parsedDict[key] = EveIDToName.GetIDToName(valueAsLong); break; case "CLONESTATIONID": case "CORPSTATIONID": case "LOCATIONID": case "STRUCTUREID": case "EXTERNALID2": parsedDict[key] = EveIDToStation.GetIDToStation(valueAsLong)?.Name ?? EveMonConstants.UnknownText; break; case "SOLARSYSTEMID": // If it overflows the result will be invalid anyways parsedDict[key] = StaticGeography.GetSolarSystemName((int)valueAsLong); break; case "SHIPTYPEID": case "TYPEID": case "STRUCTURETYPEID": case "VICTIMSHIPTYPEID": // If it overflows the result will be invalid anyways parsedDict[key] = StaticItems.GetItemName((int)valueAsLong); break; case "MEDALID": var medal = notification.CCPCharacter.CharacterMedals.FirstOrDefault(x => (x.ID.ToString() == value)); parsedDict[key] = medal?.Title ?? EveMonConstants.UnknownText; parsedDict.Add("medalDescription", medal?.Description ?? EveMonConstants.UnknownText); break; case "AMOUNT": case "ISKVALUE": // Format as ISK amount if (value.TryParseInv(out amount)) { parsedDict[key] = amount.ToString("N2"); } break; case "ENDDATE": case "STARTDATE": case "DECLOAKTIME": case "DESTRUCTTIME": case "TIMEFINISHED": parsedDict[key] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy HH:mm} (EVE Time)", valueAsLong. WinTimeStampToDateTime()); break; case "NOTIFICATION_CREATED": parsedDict[key] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy HH:mm} (EVE Time)", timestamp); break; case "DUEDATE": case "ISSUEDATE": parsedDict[key] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy} (EVE Time)", valueAsLong.WinTimeStampToDateTime()); break; case "CAMPAIGNEVENTTYPE": switch (value) { case "1": parsedDict[key] = "Territorial Claim Unit"; break; case "2": parsedDict[key] = "Infrastructure Hub"; break; case "3": parsedDict[key] = "Station"; break; default: parsedDict[key] = EveMonConstants.UnknownText; break; } break; case "TYPEIDS": typeIDs = pair.Value as YamlSequenceNode; if (typeIDs != null && (typeID == 56 || typeID == 57)) { parsedDict[key] = BuildImplantList(typeIDs); } break; case "LISTOFTYPESANDQTY": typeIDs = pair.Value as YamlSequenceNode; if (typeIDs != null) { parsedDict[key] = BuildItemList(typeIDs); } break; case "ISHOUSEWARMINGGIFT": // Tritanium parsedDict[key] = StaticItems.GetItemName(typeID); break; case "LEVEL": if (value.TryParseInv(out valueAsDouble)) { parsedDict[key] = Standing.Status(valueAsDouble) + " Standing"; } break; case "SHIELDVALUE": case "ARMORVALUE": case "HULLVALUE": if (value.TryParseInv(out valueAsDouble)) { parsedDict[key] = (valueAsDouble * 100.0).ToString("N0"); } break; } }
/// <summary> /// Draws the list item for the given standing /// </summary> /// <param name="contact"></param> /// <param name="e"></param> private void DrawItem(Contact contact, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draw background g.FillRectangle(e.Index % 2 == 0 ? Brushes.White : Brushes.LightGray, e.Bounds); // Measure and draw contact name Size contactTextSize = TextRenderer.MeasureText(g, contact.Name, m_contactsBoldFont, Size.Empty, Format); TextRenderer.DrawText(g, contact.Name, m_contactsBoldFont, new Rectangle( e.Bounds.Left + contact.EntityImage.Width + 4, e.Bounds.Top + (contact.Group == ContactGroup.Agent ? PadTop : (e.Bounds.Height - contactTextSize.Height) / 2), contactTextSize.Width + PadLeft, contactTextSize.Height), Color.Black); // Draw text for agents if (contact.Group == ContactGroup.Agent) { Agent agent = StaticGeography.GetAgentByName(contact.Name); if (agent != null) { Station agentStation = agent.Station; string agentLocationText = agentStation != null ? agentStation.Name : agent.Station.Name; // Determine the agent level and division string agentLevelText = (agent.AgentType != AgentType.BasicAgent && agent.AgentType != AgentType.ResearchAgent) ? agent.AgentType. GetDescription() : $"Level {Skill.GetRomanFromInt(agent.Level)}"; string agentLevelDivisionText = $"( {agentLevelText} - {agent.Division} )"; // Calculate text size Size agentLocationTextSize = TextRenderer.MeasureText(g, agentLocationText, m_contactsFont, Size.Empty, Format); Size agentLevelDivisionTextSize = TextRenderer.MeasureText(g, agentLevelDivisionText, m_contactsFont, Size.Empty, Format); // Draw agent level and division text TextRenderer.DrawText(g, agentLevelDivisionText, m_contactsFont, new Rectangle(e.Bounds.Left + contact.EntityImage.Width + 4 + contactTextSize.Width + PadRight, e.Bounds.Top + PadTop, agentLevelDivisionTextSize.Width + PadLeft, agentLevelDivisionTextSize.Height), Color.Black, Format); // Draw agent location TextRenderer.DrawText(g, agentLocationText, m_contactsFont, new Rectangle( e.Bounds.Left + contact.EntityImage.Width + 4, e.Bounds.Top + PadTop + agentLevelDivisionTextSize.Height, agentLocationTextSize.Width + PadLeft, agentLocationTextSize.Height), Color.Black); } } else if (Settings.UI.SafeForWork) { string contactStandingStatusText = $"({Standing.Status(contact.Standing)})"; // Measure and draw standing text Size contactStandingStatusTextSize = TextRenderer.MeasureText(g, contactStandingStatusText, m_contactsFont, Size.Empty, Format); TextRenderer.DrawText(g, contactStandingStatusText, m_contactsFont, new Rectangle(e.Bounds.Left + contact.EntityImage.Width + 4 + contactTextSize.Width + PadRight, e.Bounds.Top + (e.Bounds.Height - contactStandingStatusTextSize.Height) / 2, contactStandingStatusTextSize. Width + PadLeft, contactStandingStatusTextSize.Height), Color.Black); // Draw watchlist text if (contact.IsInWatchlist) { const string ContactInWatchListText = " - Watching"; Size contactInWatchListTextSize = TextRenderer.MeasureText(g, ContactInWatchListText, m_contactsFont, Size.Empty, Format); TextRenderer.DrawText(g, ContactInWatchListText, m_contactsFont, new Rectangle(e.Bounds.Left + contact.EntityImage.Width + 4 + contactTextSize.Width + contactStandingStatusTextSize.Width + PadRight, e.Bounds.Top + (e.Bounds.Height - contactStandingStatusTextSize.Height) / 2, contactInWatchListTextSize.Width + PadLeft, contactInWatchListTextSize.Height), Color.Black); } } else { // Draw standing image Image standingImage = Standing.GetStandingImage((int)contact.Standing); g.DrawImage(standingImage, new Rectangle(e.Bounds.Left + contact.EntityImage. Width + 4 + contactTextSize.Width + PadRight * 2, e.Bounds.Top + (e.Bounds. Height - standingImage.Size.Height) / 2, standingImage.Width, standingImage.Height)); // Draw watchlist image if (contact.IsInWatchlist) { g.DrawImage(Resources.Watch, new Rectangle(e.Bounds.Left + contact. EntityImage.Width + 4 + contactTextSize.Width + standingImage.Width + PadRight * 3, e.Bounds.Top + (e.Bounds.Height - Resources.Watch. Height) / 2, Resources.Watch.Width, Resources.Watch.Height)); } } // Draw images if (!Settings.UI.SafeForWork) { g.DrawImage(contact.EntityImage, new Rectangle(e.Bounds.Left + PadLeft / 2, ContactDetailHeight / 2 - contact.EntityImage.Height / 2 + e.Bounds.Top, contact.EntityImage.Width, contact.EntityImage.Height)); } }
/// <summary> /// Updates the content. /// </summary> internal void UpdateContent() { // Returns if not visible if (!Visible) { return; } // When no character, we just hide the list if (Character == null) { noContactsLabel.Visible = true; lbContacts.Visible = false; return; } int scrollBarPosition = lbContacts.TopIndex; // Update the standings list lbContacts.BeginUpdate(); try { IList <Contact> contacts = Character.Contacts.ToList(); if (!ShowAllContacts && !ShowContactsInWatchList) { contacts = contacts.Where(contact => Standing.Status(contact.Standing) == ShowContactsWithStandings).ToList(); } if (ShowContactsInWatchList) { contacts = contacts.Where(contact => contact.IsInWatchlist).ToList(); } IEnumerable <IGrouping <ContactGroup, Contact> > groups = contacts.GroupBy(x => x.Group).OrderBy(x => (int)x.Key); // Scroll through groups lbContacts.Items.Clear(); foreach (IGrouping <ContactGroup, Contact> group in groups) { string groupHeaderText = $"{@group.Key.GetDescription()} ({@group.Count()})"; lbContacts.Items.Add(groupHeaderText); // Add items in the group when it's not collapsed if (m_collapsedGroups.Contains(groupHeaderText)) { continue; } foreach (Contact contact in group.OrderBy(contact => contact.Name)) { contact.ContactImageUpdated += contact_ContactImageUpdated; lbContacts.Items.Add(contact); } } // Display or hide the "no contacts" label. noContactsLabel.Visible = !contacts.Any(); lbContacts.Visible = contacts.Any(); // Invalidate display lbContacts.Invalidate(); } finally { lbContacts.EndUpdate(); lbContacts.TopIndex = scrollBarPosition; } }
public override void Parse(EveNotification notification, KeyValuePair <YamlNode, YamlNode> pair, IDictionary <string, string> parsedDict) { switch (pair.Key.ToString().ToUpperInvariant()) { case "CHARID": case "SENDERCHARID": case "RECEIVERCHARID": case "OWNERID": case "LOCATIONOWNERID": case "DESTROYERID": case "INVOKINGCHARID": case "CORPID": case "PODKILLERID": case "NEWCEOID": case "OLDCEOID": { parsedDict[pair.Key.ToString()] = EveIDToName.GetIDToName(pair.Value.ToString()); break; } case "CLONESTATIONID": case "CORPSTATIONID": case "LOCATIONID": { parsedDict[pair.Key.ToString()] = Station.GetByID(int.Parse(pair.Value.ToString())).Name; break; } case "SHIPTYPEID": case "TYPEID": { parsedDict[pair.Key.ToString()] = StaticItems.GetItemByID(int.Parse(pair.Value.ToString())).Name; break; } case "MEDALID": { var medal = notification.CCPCharacter.CharacterMedals .FirstOrDefault(x => x.ID.ToString() == pair.Value.ToString()); parsedDict[pair.Key.ToString()] = medal == null ? EveMonConstants.UnknownText : medal.Title ?? EveMonConstants.UnknownText; parsedDict.Add("medalDescription", medal == null ? EveMonConstants.UnknownText : medal.Description ?? EveMonConstants.UnknownText); break; } case "ENDDATE": case "STARTDATE": { parsedDict[pair.Key.ToString()] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy HH:mm} (EVE Time)", long.Parse(pair.Value.ToString()) .WinTimeStampToDateTime()); break; } case "NOTIFICATION_CREATED": { parsedDict[pair.Key.ToString()] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy} (EVE Time)", long.Parse(pair.Value.ToString()) .WinTimeStampToDateTime()); break; } case "TYPEIDS": { YamlSequenceNode typeIDs = pair.Value as YamlSequenceNode; if (typeIDs == null) { break; } switch (notification.TypeID) { case 56: case 57: { if (!typeIDs.Any()) { parsedDict[pair.Key.ToString()] = "None were in the clone"; } else { StringBuilder sb = new StringBuilder(); foreach (var typeID in typeIDs) { sb .AppendLine() .AppendLine($"Type: {StaticItems.GetItemByID(int.Parse(typeID.ToString())).Name}"); } parsedDict[pair.Key.ToString()] = sb.ToString(); } } break; } break; } case "ISHOUSEWARMINGGIFT": { if (!Convert.ToBoolean(pair.Value)) { break; } switch (notification.TypeID) { case 34: // Tritanium parsedDict[pair.Key.ToString()] = StaticItems.GetItemByID(34).Name; break; } break; } case "LEVEL": { parsedDict[pair.Key.ToString()] = $"{Standing.Status(double.Parse(pair.Value.ToString()))} Standing"; break; } } }
/// <summary> /// Parses the notification text. /// </summary> /// <param name="notification">The notification.</param> /// <param name="pair">The pair.</param> /// <param name="parsedDict">The parsed dictionary.</param> public override void Parse(EveNotification notification, KeyValuePair <YamlNode, YamlNode> pair, IDictionary <string, string> parsedDict) { string key = pair.Key.ToString(), value = pair.Value.ToString(); switch (key.ToUpperInvariant()) { case "CHARID": case "SENDERCHARID": case "RECEIVERCHARID": case "OWNERID": case "LOCATIONOWNERID": case "DESTROYERID": case "INVOKINGCHARID": case "PODKILLERID": case "NEWCEOID": case "OLDCEOID": case "CORPID": case "VICTIMID": parsedDict[key] = EveIDToName.GetIDToName(long.Parse(value)); break; case "CLONESTATIONID": case "CORPSTATIONID": case "LOCATIONID": parsedDict[key] = EveIDToStation.GetIDToStation(long.Parse(value))?.Name ?? EveMonConstants.UnknownText; break; case "SOLARSYSTEMID": parsedDict[key] = StaticGeography.GetSolarSystemName(int.Parse(value)); break; case "SHIPTYPEID": case "TYPEID": case "STRUCTURETYPEID": case "VICTIMSHIPTYPEID": parsedDict[key] = StaticItems.GetItemName(int.Parse(value)); break; case "MEDALID": var medal = notification.CCPCharacter.CharacterMedals.FirstOrDefault(x => (x.ID.ToString() == value)); parsedDict[key] = medal?.Title ?? EveMonConstants.UnknownText; parsedDict.Add("medalDescription", medal?.Description ?? EveMonConstants.UnknownText); break; case "ENDDATE": case "STARTDATE": case "DECLOAKTIME": parsedDict[key] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy HH:mm} (EVE Time)", long.Parse(value). WinTimeStampToDateTime()); break; case "NOTIFICATION_CREATED": parsedDict[key] = string.Format(CultureConstants.InvariantCulture, "{0:dddd, MMMM d, yyyy} (EVE Time)", long.Parse(value). WinTimeStampToDateTime()); break; case "CAMPAIGNEVENTTYPE": switch (value) { case "1": parsedDict[key] = "Territorial Claim Unit"; break; case "2": parsedDict[key] = "Infrastructure Hub"; break; case "3": parsedDict[key] = "Station"; break; default: parsedDict[key] = EveMonConstants.UnknownText; break; } break; case "TYPEIDS": YamlSequenceNode typeIDs = pair.Value as YamlSequenceNode; if (typeIDs == null) { break; } switch (notification.TypeID) { case 56: case 57: { if (!typeIDs.Any()) { parsedDict[key] = "None were in the clone"; } else { StringBuilder sb = new StringBuilder(); foreach (var typeID in typeIDs) { int type = 0; int.TryParse(typeID.ToString(), out type); sb.AppendLine().AppendLine($"Type: {StaticItems.GetItemName(type)}"); } parsedDict[key] = sb.ToString(); } } break; } break; case "ISHOUSEWARMINGGIFT": if (Convert.ToBoolean(pair.Value) && notification.TypeID == 34) { // Tritanium parsedDict[key] = StaticItems.GetItemName(notification.TypeID); } break; case "LEVEL": parsedDict[key] = $"{Standing.Status(double.Parse(value))} Standing"; break; } }