Example #1
0
        /// <summary>
        /// Gets the last known docked description.
        /// </summary>
        /// <returns></returns>
        public string GetLastKnownDockedText()
        {
            if (String.IsNullOrEmpty(LastKnownLocation))
            {
                return(EveMonConstants.UnknownText);
            }

            // Show the tooltip on when the user provides api key
            APIKey apiKey = Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.CharacterInfo);

            if (apiKey == null)
            {
                return(EveMonConstants.UnknownText);
            }

            // Check if in an NPC station or in an outpost
            Station station = LastKnownStation;

            // Not in any station ?
            if (station == null)
            {
                return(String.Empty);
            }

            ConquerableStation outpost = station as ConquerableStation;

            return(outpost?.FullName ?? station.Name);
        }
Example #2
0
        /// <summary>
        /// Gets the last known location description.
        /// </summary>
        /// <returns></returns>
        public string GetLastKnownLocationText()
        {
            if (String.IsNullOrEmpty(LastKnownLocation))
            {
                return(EveMonConstants.UnknownText);
            }

            // Show the tooltip on when the user provides api key
            APIKey apiKey = Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.CharacterInfo);

            if (apiKey == null)
            {
                return(EveMonConstants.UnknownText);
            }

            // Check if in an NPC station or in an outpost
            Station station = LastKnownStation;

            // In a station ?
            // Don't care if it's an outpost or regular station
            // as station name will be displayed in docking info
            if (station != null)
            {
                return($"{station.SolarSystem.FullLocation} ({station.SolarSystem.SecurityLevel:N1})");
            }

            // Has to be in a solar system at least
            SolarSystem system = LastKnownSolarSystem;

            // Not in a solar system ??? Then show default location
            return(system != null
                ? $"{system.FullLocation} ({system.SecurityLevel:N1})"
                : "Lost in space");
        }
Example #3
0
        /// <summary>
        /// Gets the EVE notification.
        /// </summary>
        public void GetNotificationText()
        {
            // Exit if we are already trying to download the mail message body text
            if (m_queryPending)
            {
                return;
            }

            m_queryPending = true;

            // Quits if access denied
            APIKey apiKey = m_ccpCharacter.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.MailingLists);

            if (apiKey == null)
            {
                return;
            }

            EveMonClient.APIProviders.CurrentProvider.QueryMethodAsync <SerializableAPINotificationTexts>(
                CCPAPICharacterMethods.NotificationTexts,
                apiKey.ID,
                apiKey.VerificationCode,
                m_ccpCharacter.CharacterID,
                NotificationID,
                OnEVENotificationTextDownloaded);
        }
Example #4
0
        /// <summary>
        /// Gets the attendees.
        /// </summary>
        public void GetEventAttendees()
        {
            // Exit if we are already trying to download the calendar event attendees
            if (m_queryPending)
            {
                return;
            }

            m_queryPending = true;

            // Quits if access denied
            APIKey apiKey = m_ccpCharacter.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.CalendarEventAttendees);

            if (apiKey == null)
            {
                return;
            }

            EveMonClient.APIProviders.CurrentProvider.QueryMethodAsync <SerializableAPICalendarEventAttendees>(
                CCPAPICharacterMethods.CalendarEventAttendees,
                apiKey.ID,
                apiKey.VerificationCode,
                m_ccpCharacter.CharacterID,
                m_eventID,
                OnCalendarEventAttendeesDownloaded);
        }
Example #5
0
        /// <summary>
        /// Gets the contract items.
        /// </summary>
        private void GetContractItems()
        {
            // Exit if we are already trying to download
            if (m_queryPending)
            {
                return;
            }

            m_queryPending = true;

            // Special condition to identify corporation contracts in character query
            APIKey apiKey = IssuedFor == IssuedFor.Corporation && CCPAPICorporationMethods.CorporationContracts.Equals(m_method)
                ? Character.Identity.FindAPIKeyWithAccess(CCPAPICorporationMethods.CorporationContracts)
                : Character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.Contracts);

            // Quits if access denied
            if (apiKey == null)
            {
                return;
            }

            // Special condition to identify corporation contracts in character query and determine the correct api method to call
            m_apiMethod = IssuedFor == IssuedFor.Corporation && CCPAPICorporationMethods.CorporationContracts.Equals(m_method)
                ? CCPAPIGenericMethods.CorporationContractItems
                : CCPAPIGenericMethods.ContractItems;

            EveMonClient.APIProviders.CurrentProvider.QueryMethodAsync <SerializableAPIContractItems>(
                m_apiMethod, apiKey.ID, apiKey.VerificationCode, Character.CharacterID, ID, OnContractItemsDownloaded);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        /// <exception cref="System.ArgumentNullException">apiKey</exception>
        public ApiKeyDeletionWindow(APIKey apiKey)
            : this()
        {
            apiKey.ThrowIfNull(nameof(apiKey), "API key can't be null");

            m_apiKey = apiKey;
        }
Example #7
0
        public void UpdateAccountStatus()
        {
            APIKey apiKey = Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.AccountStatus);

            if (apiKey != null)
            {
                CharacterStatus = new AccountStatus(apiKey);
            }
            else if (CharacterStatus == null)
            {
                CharacterStatus = new AccountStatus(AccountStatusType.Unknown);
            }
        }
Example #8
0
 /// <summary>
 /// Creates an AccountStatus object from APIKey
 /// </summary>
 /// <param name="statusType">Type (Alpha, Omega, Unknown).</param>
 public AccountStatus(APIKey apiKey)
 {
     if (apiKey == null ||
         (apiKey != null && apiKey.Expiration < DateTime.UtcNow && apiKey.Expiration != DateTime.MinValue))
     {
         CurrentStatus = AccountStatusType.Unknown;
     }
     else
     {
         CurrentStatus = apiKey.AccountExpires > DateTime.UtcNow ?
                         AccountStatusType.Omega :
                         AccountStatusType.Alpha;
     }
 }
Example #9
0
        /// <summary>
        /// Gets the colony links.
        /// </summary>
        private void GetColonyLinks()
        {
            // Exit if we are already trying to download
            if (m_queryLinksPending)
            {
                return;
            }

            m_queryLinksPending = true;

            // Find the API key associated with planeatry pins
            APIKey apiKey = Character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.AssetList);

            // Quits if access denied
            if (apiKey == null)
            {
                return;
            }

            EveMonClient.APIProviders.CurrentProvider.QueryMethodAsync <SerializableAPIPlanetaryLinks>(
                CCPAPIGenericMethods.PlanetaryLinks, apiKey.ID, apiKey.VerificationCode, Character.CharacterID, PlanetID,
                OnPlanetaryLinksUpdated);
        }
 /// <summary>
 /// Constructor for editing existing API credentials.
 /// </summary>
 /// <param name="apiKey"></param>
 public ApiKeyUpdateOrAdditionWindow(APIKey apiKey)
     : this()
 {
     m_apiKey = apiKey;
     m_updateMode = m_apiKey != null;
 }
        /// <summary>
        /// Validates the operation and closes the window.
        /// </summary>
        private void Complete()
        {
            if (m_creationArgs == null)
                return;

            m_apiKey = m_creationArgs.CreateOrUpdate();

            // Takes care of the ignore list
            foreach (ListViewItem item in CharactersListView.Items)
            {
                CharacterIdentity id = (CharacterIdentity)item.Tag;
                // If it's a newly created API key, character monitoring has been already been set
                // We only need to deal with those coming out of the ignore list
                if (item.Checked)
                {
                    if (m_apiKey.IdentityIgnoreList.Contains(id))
                    {
                        m_apiKey.IdentityIgnoreList.Remove(id);
                        id.CCPCharacter.Monitored = true;
                    }
                    continue;
                }

                // Add character in ignore list if not already
                if (!m_apiKey.IdentityIgnoreList.Contains(id))
                    m_apiKey.IdentityIgnoreList.Add(id.CCPCharacter);
            }

            // Closes the window
            Close();
        }
Example #12
0
 /// <summary>
 /// Associates the account info.
 /// </summary>
 /// <param name="apiKey">The API key.</param>
 private static void AssociateAccountInfo(APIKey apiKey)
 {
     foreach (APIKey apiKeyWithAccountStatusInfo in EveMonClient.CharacterIdentities.Where(
         id => id.APIKeys.Contains(apiKey)).Select(id => id.APIKeys.FirstOrDefault(
             apikey => apikey.AccountCreated != DateTime.MinValue)).Where(
                 apiKeyWithAccountStatusInfo => apiKeyWithAccountStatusInfo != null))
     {
         apiKey.AccountCreated = apiKeyWithAccountStatusInfo.AccountCreated;
         apiKey.AccountExpires = apiKeyWithAccountStatusInfo.AccountExpires;
     }
 }
Example #13
0
 /// <summary>
 /// Gets the icon.
 /// </summary>
 /// <param name="apiKey">The API key.</param>
 /// <returns></returns>
 private static Image GetIcon(APIKey apiKey)
 {
     Image icon;
     switch (apiKey.Type)
     {
         default:
             icon = Resources.KeyWrong32;
             break;
         case CCPAPIKeyType.Character:
             icon = Resources.DefaultCharacterImage32;
             break;
         case CCPAPIKeyType.Corporation:
             icon = Resources.DefaultCorporationImage32;
             break;
         case CCPAPIKeyType.Account:
             icon = Resources.AccountWide32;
             break;
     }
     return icon;
 }
Example #14
0
        /// <summary>
        /// Draws the texts.
        /// </summary>
        /// <param name="top">The top.</param>
        /// <param name="g">The g.</param>
        /// <param name="apiKey">The API key.</param>
        /// <param name="left">The left.</param>
        /// <param name="fontBrush">The font brush.</param>
        /// <param name="icon">The icon.</param>
        private void DrawTexts(Graphics g, APIKey apiKey, int left, int top, Brush fontBrush, Image icon)
        {
            // Draws the texts on the upper third
            left += icon.Width + Margin.Left;

            // Api key ID
            string apiKeyId = apiKey.ID.ToString(CultureConstants.InvariantCulture);
            g.DrawString(apiKeyId, m_boldFont, fontBrush, new Point(left, top + 2));
            int indentedLeft = left + g.MeasureString(apiKeyId, m_boldFont).ToSize().Width + Margin.Left * 2;

            // Api key verification code
            g.DrawString(apiKey.VerificationCode, Font, fontBrush, new Point(indentedLeft, top));
            indentedLeft += g.MeasureString(apiKey.VerificationCode, Font).ToSize().Width + Margin.Left * 2;

            // Api key expiration date
            string expirationDateText = apiKey.Expiration != DateTime.MinValue
                ? apiKey.Expiration.ToLocalTime().ToString(CultureConstants.DefaultCulture)
                : "Never";
            string apiKeyExpiration = $"Expires: {expirationDateText}";

            g.DrawString(apiKeyExpiration, Font, fontBrush, new Point(indentedLeft, top));

            // Draw the texts on the middle third
            top += g.MeasureString(apiKeyExpiration, Font).ToSize().Height;

            // Account header
            string accountHeader = "Account";
            g.DrawString(accountHeader, m_boldFont, fontBrush, new Point(left, top));
            indentedLeft = left + g.MeasureString(accountHeader, m_boldFont).ToSize().Width + Margin.Left * 2;

            // Account created
            string accountCreatedText = apiKey.AccountCreated != DateTime.MinValue
                ? apiKey.AccountCreated.ToLocalTime().ToString(CultureConstants.DefaultCulture)
                : "-";
            string accountCreated = $"Created: {accountCreatedText}";

            g.DrawString(accountCreated, m_middleFont, fontBrush, new Point(indentedLeft, top));
            indentedLeft += g.MeasureString(accountCreated, m_middleFont).ToSize().Width + Margin.Left * 2;

            // Account paid until
            string accountPaidUntilText = apiKey.AccountExpires != DateTime.MinValue
                ? apiKey.AccountExpires.ToLocalTime().ToString(CultureConstants.DefaultCulture)
                : "-";
            string accountPaidUntil = $"Paid Until: {accountPaidUntilText}";
            g.DrawString(accountPaidUntil, m_middleFont, fontBrush, new Point(indentedLeft, top));
            indentedLeft += g.MeasureString(accountPaidUntil, m_middleFont).ToSize().Width + Margin.Left * 2;

            // Account status header
            string accountStatusHeader = "Status: ";
            g.DrawString(accountStatusHeader, m_middleFont, fontBrush, new Point(indentedLeft, top));
            indentedLeft += g.MeasureString(accountStatusHeader, m_middleFont).ToSize().Width;

            // Account status body
            string accountStatusBody = apiKey.AccountExpires != DateTime.MinValue
                ? apiKey.AccountExpires > DateTime.UtcNow
                    ? "Active"
                    : "Expired"
                : "-";
            Brush accountStatusBrush = apiKey.AccountExpires != DateTime.MinValue
                ? new SolidBrush(apiKey.AccountExpires > DateTime.UtcNow ? Color.DarkGreen : Color.Red)
                : fontBrush;
            g.DrawString(accountStatusBody, m_middleFont, accountStatusBrush, new Point(indentedLeft, top));

            // Draws the texts on the lower third
            top += g.MeasureString(accountCreated, m_middleFont).ToSize().Height;
            bool isFirst = true;

            foreach (CharacterIdentity identity in apiKey.CharacterIdentities)
            {
                // Draws "; " between ids
                if (!isFirst)
                {
                    g.DrawString("; ", m_smallFont, fontBrush, new Point(left, top));
                    left += g.MeasureString("; ", Font).ToSize().Width;
                }
                isFirst = false;

                // Selects font
                Font font = m_smallFont;
                CCPCharacter ccpCharacter = identity.CCPCharacter;
                if (apiKey.IdentityIgnoreList.Contains(identity))
                    font = m_strikeoutFont;
                else if (ccpCharacter != null && ccpCharacter.Monitored)
                    font = m_smallBoldFont;

                // Draws character's name
                g.DrawString(identity.CharacterName, font, fontBrush, new Point(left, top));
                left += g.MeasureString(identity.CharacterName, font).ToSize().Width;
            }
        }
Example #15
0
        /// <summary>
        /// Called when an account status has been updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnAccountStatusUpdated(APIKey apiKey)
        {
            if (Closed)
                return;

            Trace(apiKey.ToString());
            AccountStatusUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Example #16
0
        /// <summary>
        /// Called when the API key info updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnAPIKeyInfoUpdated(APIKey apiKey)
        {
            if (Closed)
                return;

            Trace(apiKey.ToString());
            Settings.Save();
            APIKeyInfoUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Example #17
0
        /// <summary>
        /// Creates the or update.
        /// </summary>
        /// <returns></returns>
        public APIKey CreateOrUpdate()
        {
            // Checks whether this API key already exists to update it
            APIKey apiKey = EveMonClient.APIKeys[ID];
            if (apiKey != null)
            {
                apiKey.Update(this);

                // Fires the event regarding the API key info update
                EveMonClient.OnAPIKeyInfoUpdated(apiKey);
            }
            else
            {
                apiKey = new APIKey(ID);
                apiKey.Update(this);
                EveMonClient.APIKeys.Add(apiKey);
            }

            return apiKey;
        }
Example #18
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="apiKey"></param>
 public APIKeyInfoChangedEventArgs(APIKey apiKey)
 {
     APIKey = apiKey;
 }
Example #19
0
        /// <summary>
        /// Called when all characters, exposed throu the API key, 'skill in training' check has been updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnCharactersSkillInTrainingUpdated(APIKey apiKey)
        {
            if (Closed)
                return;

            Trace(apiKey.ToString());
            CharactersSkillInTrainingUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Example #20
0
        /// <summary>
        /// Called when the character list updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnCharacterListUpdated(APIKey apiKey)
        {
            if (Closed)
                return;

            Trace(apiKey.ToString());
            Settings.Save();
            CharacterListUpdated?.ThreadSafeInvoke(null, new APIKeyInfoChangedEventArgs(apiKey));
        }