Esempio n. 1
0
        /// <summary>
        /// Asynchronously downloads an image from the provided url.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="useCache">if set to <c>true</c> [use cache].</param>
        /// <param name="callback">Callback that will be invoked on the UI thread.</param>
        public static void GetImageAsync(string url, bool useCache, GetImageCallback callback)
        {
            // Cache not to be used ?
            if (!useCache)
            {
                EveClient.HttpWebService.DownloadImageAsync(url, GotImage, callback);
                return;
            }

            // First check whether the image exists in cache.
            string cacheFileName = Path.Combine(ImageCacheDirectory, GetCacheName(url));
            if (File.Exists(cacheFileName))
            {
                try
                {
                    Image img = Image.FromFile(cacheFileName, true);
                    callback(img);
                }
                catch (Exception e)
                {
                    ExceptionHandler.LogException(e, false);
                }
            }

            // In last resort, downloads it.
            EveClient.HttpWebService.DownloadImageAsync(url, GotImage, (GetImageCallback)((img) =>
                {
                    if (img != null)
                        AddImageToCache(url, img);

                    callback(img);
                }));
        }
Esempio n. 2
0
    IEnumerator GetImageCoroutine(string url, GetImageCallback callback)
    {
        WWW www = new WWW(url);

        yield return(www);

        Texture2D texture = www.texture;

        callback(texture);
    }
Esempio n. 3
0
        /// <summary>
        /// Callback used when images are downloaded, it takes care to invoke another callback provided as our user state.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="state"></param>
        private static void GotImage(DownloadImageAsyncResult e, object state)
        {
            GetImageCallback callback = (GetImageCallback)state;

            if (e.Error == null)
            {
                // Invokes on the UI thread.
                Dispatcher.BeginInvoke(() => callback(e.Result));
            }
            else
            {
                ExceptionHandler.LogException(e.Error, true);
                callback(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Asynchronously downloads an image from the provided url.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="useCache">if set to <c>true</c> [use cache].</param>
        /// <param name="callback">Callback that will be invoked on the UI thread.</param>
        public static void GetImageAsync(string url, bool useCache, GetImageCallback callback)
        {
            // Cache not to be used ?
            if (!useCache)
            {
                EveClient.HttpWebService.DownloadImageAsync(url, GotImage, callback);
                return;
            }

            // First check whether the image exists in cache.
            string cacheFileName = Path.Combine(ImageCacheDirectory, GetCacheName(url));

            if (File.Exists(cacheFileName))
            {
                try
                {
                    Image img = Image.FromFile(cacheFileName, true);
                    callback(img);
                }
                catch (Exception e)
                {
                    ExceptionHandler.LogException(e, false);
                }
            }

            // In last resort, downloads it.
            EveClient.HttpWebService.DownloadImageAsync(url, GotImage, (GetImageCallback)((img) =>
            {
                if (img != null)
                {
                    AddImageToCache(url, img);
                }

                callback(img);
            }));
        }
Esempio n. 5
0
 public static extern IntPtr Online(string rtsp, GetImageCallback getImageCallback);
Esempio n. 6
0
 /// <summary>
 /// Asynchronously downloads a character portrait from its ID.
 /// </summary>
 /// <param name="charId"></param>
 /// <param name="callback">Callback that will be invoked on the UI thread.</param>
 public static void GetCharacterImageAsync(long charId, GetImageCallback callback)
 {
     GetImageAsync(String.Format(NetworkConstants.CCPPortraits, charId.ToString()), false, callback);
 }
Esempio n. 7
0
 public void GetImage(string url, GetImageCallback callback)
 {
     Debug.Log("Getting image from: " + url);
     StartCoroutine(GetImageCoroutine(url, callback));
 }
Esempio n. 8
0
 /// <summary>
 /// Asynchronously downloads a character portrait from its ID.
 /// </summary>
 /// <param name="charId"></param>
 /// <param name="callback">Callback that will be invoked on the UI thread.</param>
 public static void GetCharacterImageAsync(long charId, GetImageCallback callback)
 {
     GetImageAsync(String.Format(NetworkConstants.CCPPortraits, charId.ToString()), false, callback);
 }