Esempio n. 1
0
        public void Load(string url)
        {
            URL = url;
            if (!Downloading)
            {
                Downloading = true;
                ImageElement = (ImageElement)Document.CreateElement("img");
                CrossDomainImage xdomimg = (CrossDomainImage)(object)ImageElement;

                ImageElement.AddEventListener("load", delegate(ElementEvent e)
                {
                    Ready = true;
                    Downloading = false;
                    Errored = false;
                    MakeTexture();
                }, false);

                ImageElement.AddEventListener("error", delegate(ElementEvent e)
                {
                    if (!ImageElement.HasAttribute("proxyattempt"))
                    {
                        ImageElement.Src = Util.GetProxiedUrl(URL);
                        ImageElement.SetAttribute("proxyattempt", true);
                    }
                    else
                    {
                        Downloading = false;
                        Ready = false;
                        Errored = true;
                    }
                }, false);

                xdomimg.crossOrigin = "anonymous";
              //              texture.Src = this.URL.Replace("cdn.", "www.");

                ImageElement.Src = URL;
            }
        }
Esempio n. 2
0
        public virtual void RequestImage()
        {
            if (!Downloading && !ReadyToRender)
            {
                Downloading = true;
                texture = (ImageElement)Document.CreateElement("img");
                CrossDomainImage xdomimg = (CrossDomainImage)(object)texture;

                texture.AddEventListener("load", delegate(ElementEvent e)
                {
                    texReady = true;
                    Downloading = false;
                    errored = false;
                    ReadyToRender = texReady && (DemReady || !demTile);
                    RequestPending = false;
                    TileCache.RemoveFromQueue(this.Key, true);
                    MakeTexture();
                }, false);

                texture.AddEventListener("error", delegate(ElementEvent e)
                {
                    if (!texture.HasAttribute("proxyattempt"))
                    {
                        texture.Src = Util.GetProxiedUrl(URL);
                        texture.SetAttribute("proxyattempt", true);
                    }
                    else
                    {
                        Downloading = false;
                        ReadyToRender = false;
                        errored = true;
                        RequestPending = false;
                        TileCache.RemoveFromQueue(this.Key, true);
                    }

                }, false);

                xdomimg.crossOrigin = "anonymous";
                texture.Src = this.URL.Replace("cdn.","www.");
                //texture.Src = "dss.png";

                // TODO add event listener for failed!
            }
        }