public void RequestImage(string sUrl, RequestImageCallbackHandler richCallback, object objContext = null)
        {
            if (m_dctCache.ContainsKey(sUrl))
            {
                if (m_dctCache[sUrl].Result == null)
                    m_dctCache[sUrl].Callbacks.Add(new AsyncContentCallback(richCallback, null));
                else
                    richCallback(this, (Bitmap)m_dctCache[sUrl].Result, objContext);
            }
            else
            {
                AsyncContent acCur = new AsyncContent()
                {
                    Url = sUrl,
                    Type = AsyncContent.ContentType.Image,
                    HitCount = 1
                };

                acCur.Callbacks.Add(new AsyncContentCallback(richCallback, objContext));
                m_qWorkQueue.Enqueue(acCur);
                m_dctCache.Add(sUrl, acCur);

                Cleanup();
            }
        }
Пример #2
0
        public void RequestImage(string sUrl, RequestImageCallbackHandler richCallback, object objContext = null)
        {
            if (m_dctCache.ContainsKey(sUrl))
            {
                if (m_dctCache[sUrl].Result == null)
                {
                    m_dctCache[sUrl].Callbacks.Add(new AsyncContentCallback(richCallback, null));
                }
                else
                {
                    richCallback(this, (Bitmap)m_dctCache[sUrl].Result, objContext);
                }
            }
            else
            {
                AsyncContent acCur = new AsyncContent()
                {
                    Url      = sUrl,
                    Type     = AsyncContent.ContentType.Image,
                    HitCount = 1
                };

                acCur.Callbacks.Add(new AsyncContentCallback(richCallback, objContext));
                m_qWorkQueue.Enqueue(acCur);
                m_dctCache.Add(sUrl, acCur);

                Cleanup();
            }
        }
Пример #3
0
        private void WorkOnImage(AsyncContent acImage, WebClient wcClient)
        {
            Bitmap bmpImage;

            //@TODO: for production, don't look in desktop dir (duh!)
            if (File.Exists(Path.Combine("../../../../Documents/test/avatars", Path.GetFileName(acImage.Url))))
            {
                bmpImage = (Bitmap)Bitmap.FromFile(Path.Combine("../../../../Documents/test/avatars", Path.GetFileName(acImage.Url)));
            }
            else
            {
                Stream stmImage = wcClient.OpenRead(acImage.Url);
                bmpImage = (Bitmap)Bitmap.FromStream(stmImage);
                stmImage.Close();
            }

            //bmpImage.Save("C:/Users/le grand fromage/Desktop/avatars/" + Path.GetFileName(acImage.Url));

            for (int i = 0; i < acImage.Callbacks.Count; i++)
            {
                acImage.Callbacks[i].Callback.DynamicInvoke(this, bmpImage, acImage.Callbacks[i].Context);
            }

            acImage.Result = bmpImage;
        }
        private void WorkOnImage(AsyncContent acImage, WebClient wcClient)
        {
            Bitmap bmpImage;

            //@TODO: for production, don't look in desktop dir (duh!)
            if (File.Exists(Path.Combine("../../../../Documents/test/avatars", Path.GetFileName(acImage.Url))))
                bmpImage = (Bitmap)Bitmap.FromFile(Path.Combine("../../../../Documents/test/avatars", Path.GetFileName(acImage.Url)));
            else
            {
                Stream stmImage = wcClient.OpenRead(acImage.Url);
                bmpImage = (Bitmap)Bitmap.FromStream(stmImage);
                stmImage.Close();
            }

            //bmpImage.Save("C:/Users/le grand fromage/Desktop/avatars/" + Path.GetFileName(acImage.Url));

            for (int i = 0; i < acImage.Callbacks.Count; i ++)
                acImage.Callbacks[i].Callback.DynamicInvoke(this, bmpImage, acImage.Callbacks[i].Context);

            acImage.Result = bmpImage;
        }