Exemple #1
0
        /// <summary>
        /// Retrieves image for the given EveObject.
        /// </summary>
        private async Task GetImageAsync()
        {
            // Reset flags and cursor
            m_popUpActive  = false;
            toolTip.Active = false;
            pbImage.Cursor = Cursors.Default;

            if (m_item == null)
            {
                return;
            }

            ImageType     imageType = GetImageType(m_item);
            ImageTypeData typeData  = m_imageTypeAttributes[imageType];

            // Only display an image if the correct size is available
            if (!typeData.ValidSizes.Contains(m_imageSize))
            {
                return;
            }

            // Enable pop up if required
            if (PopUpEnabled && typeData.ValidSizes.Contains(EveImageSize.x256))
            {
                toolTip.Active = true;
                m_popUpActive  = true;
                pbImage.Cursor = Cursors.Hand;
            }

            await GetImageFromCCPAsync().ConfigureAwait(false);
        }
Exemple #2
0
        /// <summary>
        /// Gets the image from an alternative source [local or (http://eve.no-ip.de)].
        /// </summary>
        /// <param name="typeData">The type data.</param>
        private void GetImageFromAlternativeSource(ImageTypeData typeData)
        {
            // Set file & pathname variables
            string eveSize = String.Format(CultureConstants.DefaultCulture, "{0}_{0}", (int)m_imageSize);

            string imageWebName;
            string imageResourceName;

            if (typeData.imageNameFrom == ImageNameFrom.TypeID)
            {
                imageWebName      = m_item.ID.ToString();
                imageResourceName = String.Format("_{0}", imageWebName);
            }
            else
            {
                imageWebName      = String.Format("icon{0}", m_item.Icon);
                imageResourceName = imageWebName;
            }

            // Try and get image from a local optional resources file (probably don't used anymore, not sure)
            string localResources = String.Format("{1}Resources{0}Optional{0}{2}{3}.resources",
                                                  Path.DirectorySeparatorChar, AppDomain.CurrentDomain.BaseDirectory, typeData.localComponent, eveSize);

            // Try to get image from web (or local cache located in %APPDATA%\EVEMon if not found yet)
            if (!FetchImageResource(imageResourceName, localResources))
            {
                // Result should be like :
                // http://eve.no-ip.de/icons/32_32/icon22_08.png
                // http://eve.no-ip.de/icons/32_32/7538.png
                string imageURL = String.Format(NetworkConstants.CCPIcons, typeData.urlPath, eveSize, imageWebName);

                ImageService.GetImageAsync(imageURL, true, (img) => GotImage(m_item.ID, img, true));
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the image from CCP's image server (http://image.eveonline.com).
        /// </summary>
        /// <param name="typeData">The type data.</param>
        /// <returns></returns>
        private void GetImageFromCCP(ImageTypeData typeData)
        {
            string urlPath         = "inventorytype";
            bool   drawOverlayIcon = false;

            if ((int)m_imageSize > 64)
            {
                urlPath         = "render";
                drawOverlayIcon = true;
            }

            string imageURL = String.Format(NetworkConstants.CCPIconsFromImageServer, urlPath, m_item.ID, (int)m_imageSize);

            ImageService.GetImageAsync(imageURL, true, (img) =>
            {
                GotImage(m_item.ID, img, drawOverlayIcon);

                if (img == null)
                {
                    GetImageFromAlternativeSource(typeData);
                }
            });
        }
Exemple #4
0
        /// <summary>
        /// Retrieves image for the given EveObject
        /// </summary>
        private void GetImage()
        {
            // Set to black image initially
            ShowBlankImage();

            // Reset flags and cursor
            m_PopUpActive   = false;
            toolTip1.Active = false;
            pbImage.Cursor  = Cursors.Default;

            if (m_item != null)
            {
                ImageType     imageType = GetImageType(m_item);
                ImageTypeData typeData  = m_ImageTypeAttributes[imageType];

                // Only display an image if the correct size is available
                if (typeData.validSizes.Contains(m_ImageSize))
                {
                    // Set file & pathname variables
                    string eveSize = ((int)m_ImageSize).ToString() + "_" + ((int)m_ImageSize).ToString();

                    string imageWebName;
                    string imageResourceName;
                    if (typeData.imageNameFrom == ImageNameFrom.TypeID)
                    {
                        imageWebName      = m_item.ID.ToString();
                        imageResourceName = "_" + imageWebName;
                    }
                    else
                    {
                        imageWebName      = "icon" + m_item.Icon.ToString();
                        imageResourceName = imageWebName;
                    }

                    // Try and get image from a local optional resources file (probably don't used anymore, not sure)
                    string localResources = String.Format(
                        "{1}Resources{0}Optional{0}{2}{3}.resources",
                        Path.DirectorySeparatorChar,
                        System.AppDomain.CurrentDomain.BaseDirectory,
                        typeData.localComponent,
                        eveSize);

                    bool foundResource = false;
                    try
                    {
                        if (System.IO.File.Exists(localResources))
                        {
                            System.Resources.IResourceReader basic;
                            basic = new System.Resources.ResourceReader(localResources);
                            System.Collections.IDictionaryEnumerator basicx = basic.GetEnumerator();
                            while (basicx.MoveNext())
                            {
                                if (basicx.Key.ToString() == imageResourceName)
                                {
                                    pbImage.Image = (System.Drawing.Image)basicx.Value;
                                    foundResource = true;
                                    break;
                                }
                            }
                        }
                    }
                    catch
                    {
                    }


                    // Try to get image from web (or local cache located in %APPDATA%\EVEMon) if not found yet
                    if (!foundResource)
                    {
                        // Result should be like :
                        // http://eve.no-ip.de/icons/32_32/icon22_08.png
                        // http://eve.no-ip.de/icons/32_32/7538.png
                        string imageURL = String.Format(NetworkConstants.CCPIcons, typeData.urlPath, eveSize, imageWebName);

                        ImageService.GetImageAsync(imageURL, true, (img) => GotImage(m_item.ID, img));
                    }

                    // Enable pop up if required
                    if (m_PopUpEnabled && typeData.validSizes.Contains(EveImageSize.x256))
                    {
                        toolTip1.Active = true;
                        m_PopUpActive   = true;
                        pbImage.Cursor  = Cursors.Hand;
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets the image from an alternative source [local or (http://eve.no-ip.de)].
        /// </summary>
        /// <param name="typeData">The type data.</param>
        private void GetImageFromAlternativeSource(ImageTypeData typeData)
        {
            // Set file & pathname variables
            string eveSize = String.Format(CultureConstants.DefaultCulture, "{0}_{0}", (int)m_imageSize);

            string imageWebName;
            string imageResourceName;

            if (typeData.imageNameFrom == ImageNameFrom.TypeID)
            {
                imageWebName = m_item.ID.ToString();
                imageResourceName = String.Format("_{0}", imageWebName);
            }
            else
            {
                imageWebName = String.Format("icon{0}", m_item.Icon);
                imageResourceName = imageWebName;
            }

            // Try and get image from a local optional resources file (probably don't used anymore, not sure)
            string localResources = String.Format("{1}Resources{0}Optional{0}{2}{3}.resources",
                Path.DirectorySeparatorChar, AppDomain.CurrentDomain.BaseDirectory, typeData.localComponent, eveSize);

            // Try to get image from web (or local cache located in %APPDATA%\EVEMon if not found yet)
            if (!FetchImageResource(imageResourceName, localResources))
            {
                // Result should be like :
                // http://eve.no-ip.de/icons/32_32/icon22_08.png
                // http://eve.no-ip.de/icons/32_32/7538.png
                string imageURL = String.Format(NetworkConstants.CCPIcons, typeData.urlPath, eveSize, imageWebName);

                ImageService.GetImageAsync(imageURL, true, (img) => GotImage(m_item.ID, img, true));
            }
        }
Exemple #6
0
        /// <summary>
        /// Gets the image from CCP's image server (http://image.eveonline.com).
        /// </summary>
        /// <param name="typeData">The type data.</param>
        /// <returns></returns>
        private void GetImageFromCCP(ImageTypeData typeData)
        {
            string urlPath = "inventorytype";
            bool drawOverlayIcon = false;

            if ((int)m_imageSize > 64)
            {
                urlPath = "render";
                drawOverlayIcon = true;
            }

            string imageURL = String.Format(NetworkConstants.CCPIconsFromImageServer, urlPath, m_item.ID, (int)m_imageSize);

            ImageService.GetImageAsync(imageURL, true, (img) =>
                                        {
                                            GotImage(m_item.ID, img, drawOverlayIcon);
                                            
                                            if (img == null)
                                                GetImageFromAlternativeSource(typeData);
                                        });
        }