AddEventListener() public method

public AddEventListener ( ImageElementEvents type, System.Action listener ) : void
type ImageElementEvents
listener System.Action
return void
Ejemplo n.º 1
0
 public static void LoadImageFromUrl(string tileMapFile, Action<ImageElement> loaded)
 {
     ImageElement element = new ImageElement();
     element.Me().crossOrigin = "anonymous"; //FFFFUUUUU CORS!
     element.AddEventListener("load", e => { loaded(element); }, false);
     element.Src = tileMapFile;
 }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        //int imageCount = 0;
        //int imageLoadCount = 0;
        //bool imagesLoaded = false;
        //bool downloading = false;
        //ImageElement LoadImageElement(string url)
        //{
        //    imageCount++;
        //    imagesLoaded = false;
        //    downloading = true;
        //    ImageElement temp = (ImageElement)Document.CreateElement("img");
        //    temp.Src = url;
        //    temp.AddEventListener("load", delegate(ElementEvent e)
        //    {
        //        ImageLoadCount++;
        //        if (imageLoadCount == imageCount)
        //        {
        //            downloading = false;
        //            ImagesLoaded = true;
        //           // Refresh();
        //        }
        //    }, false);
        //    return temp;
        //}
        public void LoadImages()
        {
            if (!ImagesLoaded && !downloading)
            {
                ImageLoadCount = 0;
                ImagesLoaded = false;
                downloading = true;
                bmpBackground = (ImageElement)Document.CreateElement("img");
                bmpBackground.Src = "images/thumbBackground.png";
                bmpBackground.AddEventListener("load", delegate(ElementEvent e)
                {
                    ImageLoadCount++;
                    if (ImageLoadCount == 5)
                    {
                        downloading = false;
                        ImagesLoaded = true;
                        Refresh();
                    }
                }, false);

                bmpBackgroundHover = (ImageElement)Document.CreateElement("img");
                bmpBackgroundHover.Src = "images/thumbBackgroundHover.png";
                bmpBackgroundHover.AddEventListener("load", delegate(ElementEvent e)
                {
                    ImageLoadCount++;
                    if (ImageLoadCount == 5)
                    {
                        downloading = false;
                        ImagesLoaded = true;
                        Refresh();
                    }
                }, false);
                bmpBackgroundWide = (ImageElement)Document.CreateElement("img");
                bmpBackgroundWide.Src = "images/thumbBackgroundWide.png";
                bmpBackgroundWide.AddEventListener("load", delegate(ElementEvent e)
                {
                    ImageLoadCount++;
                    if (ImageLoadCount == 5)
                    {
                        downloading = false;
                        ImagesLoaded = true;
                        Refresh();
                    }
                }, false);
                bmpBackgroundWideHover = (ImageElement)Document.CreateElement("img");
                bmpBackgroundWideHover.Src = "images/thumbBackgroundWideHover.png";
                bmpBackgroundWideHover.AddEventListener("load", delegate(ElementEvent e)
                {
                    ImageLoadCount++;
                    if (ImageLoadCount == 5)
                    {
                        downloading = false;
                        ImagesLoaded = true;
                        Refresh();
                    }
                }, false);
                bmpDropInsertMarker = (ImageElement)Document.CreateElement("img");
                bmpDropInsertMarker.Src = "images/dragInsertMarker.png";
                bmpDropInsertMarker.AddEventListener("load", delegate(ElementEvent e)
                {
                    ImageLoadCount++;
                    if (ImageLoadCount == 5)
                    {
                        downloading = false;
                        ImagesLoaded = true;
                        Refresh();
                    }
                }, false);
            }
        }
Ejemplo n.º 4
0
        public void Load(string data)
        {
            string[] lines = data.Split("\r\n");

            starProfile = (ImageElement)Document.CreateElement("img");
            starProfile.AddEventListener("load", delegate(ElementEvent e)
            {
                imageReady = true;
            }, false);
            starProfile.Src = "images/starProfile.png";
            bool gotHeader = false;
            foreach (string line in lines)
            {
                if (gotHeader)
                {
                    table.Add(line.Split("\t"));
                }
                else
                {
                    header = line.Split("\t");
                    gotHeader = true;
                }
            }
        }
Ejemplo n.º 5
0
        public override void Init(LampPlayer[] players, CanvasContext2D context)
        {
            myPlayers = players;

            someImage = new ImageElement();
            someImage.AddEventListener("load",
                                       e => {
                                           //idk do something when the image is loaded
                                       },
                                       false);
            someImage.Src = "http://dested.com/lamp/Games/ZombieGame/assets/LostGarden+WoodTiles.png";
        }
 public void Ready()
 {
     return;
     ImageElement image = new ImageElement();
     image.AddEventListener("load",
                            e => {
                                Image = image;
                                ImageReady = true;
                            },
                            false);
     image.Src = Canvas.Me().toDataURL();
 }
Ejemplo n.º 7
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!
            }
        }
Ejemplo n.º 8
0
        //const double jBase = 2455198.0;
        void InitBuffer(RenderContext renderContext)
        {
            if (!init)
            {
                if (renderContext.gl == null)
                {
                    starProfile = (ImageElement)Document.CreateElement("img");
                    starProfile.AddEventListener("load", delegate(ElementEvent e)
                    {
                        imageReady = true;
                    }, false);

                    starProfile.Src = "/images/starProfile.png";

                    worldList = new Vector3d[points.Count];
                    transformedList = new Vector3d[points.Count];

                    int index = 0;
                    foreach (Vector3d pnt in points)
                    {
                        // todo filter by date
                        DataItem item = new DataItem();
                        item.Location = pnt;
                        item.Tranformed = new Vector3d();
                        item.Size = sizes[index];
                        item.Color = colors[index];
                        worldList[index] = item.Location;
                        transformedList[index] = item.Tranformed;
                        items.Add(item);
                        index++;
                    }
                }
                else
                {
                    if (pointBuffers.Count == 0)
                    {
                        if (starTexture == null)
                        {
                            starTexture = Planets.LoadPlanetTexture("/images/starProfile.png");
                        }

                        int count = this.points.Count;

                        TimeSeriesPointVertexBuffer pointBuffer = null;
                        TimeSeriesPointVertex[] pointList = null;

                        int countLeft = count;
                        int index = 0;
                        int counter = 0;
                        foreach (Vector3d point in points)
                        {
                            if (counter >= 100000 || pointList == null)
                            {
                                if (pointBuffer != null)
                                {
                                    pointBuffer.Unlock();
                                }
                                int thisCount = Math.Min(100000, countLeft);

                                countLeft -= thisCount;
                                pointBuffer = new TimeSeriesPointVertexBuffer(thisCount);

                                pointList = (TimeSeriesPointVertex[])pointBuffer.Lock(); // Lock the buffer (which will return our structs)

                                pointBuffers.Add(pointBuffer);
                                pointBufferCounts.Add(thisCount);
                                counter = 0;
                            }
                            pointList[counter] = new TimeSeriesPointVertex();
                            pointList[counter].Position = point;
                            pointList[counter].PointSize = sizes[index];
                            pointList[counter].Tu = (float)(dates[index].StartDate );
                            pointList[counter].Tv = (float)(dates[index].EndDate );
                            pointList[counter].Color = colors[index];
                            index++;
                            counter++;
                        }

                        if (pointBuffer != null)
                        {
                            pointBuffer.Unlock();
                        }
                    }
                }

                init = true;
            }
        }