public virtual void RequestImage() { if (Dataset.WcsImage != null) { texReady = true; Downloading = false; errored = false; ReadyToRender = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); return; } 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! } }
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 = URLHelpers.singleton.engineAssetUrl("StarProfileAlpha.png"); bool gotHeader = false; foreach (string line in lines) { if (gotHeader) { table.Add(line.Split("\t")); } else { header = line.Split("\t"); gotHeader = true; } } }
public ImageElement GetCachedTexture(string filename, Action callMe) { if (textureList == null) { textureList = new Dictionary <string, ImageElement>(); } if (textureList.ContainsKey(filename)) { callMe(); return(textureList[filename]); } string url = GetFileStream(filename); if (!string.IsNullOrWhiteSpace(url)) { ImageElement texture = (ImageElement)Document.CreateElement("img"); texture.Src = GetFileStream(filename); texture.AddEventListener("load", delegate { callMe(); }, false); textureList[filename] = texture; return(texture); } else { return(null); } }
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.SetAttribute("proxyattempt", true); string new_url = URLHelpers.singleton.activateProxy(URL); if (new_url != null) // null => don't bother: we know that the proxy won't help { ImageElement.Src = new_url; return; } } Downloading = false; Ready = false; Errored = true; }, false); xdomimg.crossOrigin = "anonymous"; ImageElement.Src = URL; } }
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; } }
public void Show(Vector2d position) { DivElement picker = Document.GetElementById <DivElement>("colorpicker"); picker.ClassName = "colorpicker"; picker.Style.Display = "block"; picker.Style.Left = position.X.ToString() + "px"; picker.Style.Top = position.Y.ToString() + "px"; Window.AddEventListener("click", NonMenuClick, true); ImageElement image = Document.GetElementById <ImageElement>("colorhex"); image.AddEventListener("mousedown", PickColor, false); }
public ImageElement LoadImage(string url, bool createMask) { if (_images.ContainsKey(url)) { return(_images[url]); } ImageElement image = (ImageElement)Document.CreateElement("IMG"); _resourcesToLoad++; _resourcesToLoadLabel.InnerHTML = _resourcesToLoad.ToString(); image.AddEventListener("load", createMask? _maskedResourceLoaded : _resourceLoaded, true); image.Src = url; _images[url] = image; return(image); }
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); }
//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 = "/webclient/images/StarProfileAlpha.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("/webclient/images/StarProfileAlpha.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; } }
public virtual void RequestImage() { if (Dataset.WcsImage != null) { texReady = true; Downloading = false; errored = false; ReadyToRender = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); return; } 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.SetAttribute("proxyattempt", true); // NOTE: `this.URL` is dynamically generated using // URLHelpers.rewrite(). Say that we request tiles from // example.com, which requires CORS proxying. Say also // that this callback is called for a request to a tile // that should in fact be available. If a different // request fails before this callback is called, // activateProxy() will be called on the example.com // domain, making it so that `this.URL` in the following // call goes through the proxy, making it so that // `new_url` is null, making it so that this tile is // erroneously marked as failed when it should not be. // The solution: make sure to check proxy activation // with the *original* request URL, `texture.Src`, not // the one that may have been updated, `this.URL`. string new_url = URLHelpers.singleton.activateProxy(texture.Src); if (new_url != null) { // null => don't bother: we know that the proxy won't help texture.Src = new_url; return; } } Downloading = false; ReadyToRender = false; errored = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); }, false); xdomimg.crossOrigin = "anonymous"; texture.Src = this.URL; } }
public virtual void RequestImage() { if (dataset.Extension.ToLowerCase().IndexOf("fits") > -1) { if (!Downloading && !ReadyToRender) { Downloading = true; if (RenderContext.UseGlVersion2) { fitsImage = new FitsImageTile(dataset, URL, delegate(WcsImage wcsImage) { Downloading = false; errored = fitsImage.errored; TileCache.RemoveFromQueue(this.Key, true); if (!fitsImage.errored) { // For a non-HiPS tiled FITS, this is our // mechanism for notifying the layer creator // that the initial FITS data have loaded and // the FitsProperties can be trusted. if (Level == 0) { dataset.FitsProperties.FireMainImageLoaded(fitsImage); fitsImage.ApplyDisplaySettings(); } texReady = true; ReadyToRender = texReady && (DemReady || !demTile); RequestPending = false; MakeTexture(); } }); } else { fitsImage = FitsImageJs.CreateTiledFits(dataset, URL, delegate(WcsImage wcsImage) { if (Level == 0) { dataset.FitsProperties.FireMainImageLoaded(fitsImage); } texReady = true; Downloading = false; errored = fitsImage.errored; ReadyToRender = texReady && (DemReady || !demTile); RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); texture2d = wcsImage.GetBitmap().GetTexture(); }); } } } else { if (Dataset.WcsImage != null) { texReady = true; Downloading = false; errored = false; ReadyToRender = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); return; } 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.SetAttribute("proxyattempt", true); // NOTE: `this.URL` is dynamically generated using // URLHelpers.rewrite(). Say that we request tiles from // example.com, which requires CORS proxying. Say also // that this callback is called for a request to a tile // that should in fact be available. If a different // request fails before this callback is called, // activateProxy() will be called on the example.com // domain, making it so that `this.URL` in the following // call goes through the proxy, making it so that // `new_url` is null, making it so that this tile is // erroneously marked as failed when it should not be. // The solution: make sure to check proxy activation // with the *original* request URL, `texture.Src`, not // the one that may have been updated, `this.URL`. string new_url = URLHelpers.singleton.activateProxy(texture.Src); if (new_url != null) { // null => don't bother: we know that the proxy won't help texture.Src = new_url; return; } } Downloading = false; ReadyToRender = false; errored = true; RequestPending = false; TileCache.RemoveFromQueue(this.Key, true); }, false); xdomimg.crossOrigin = "anonymous"; texture.Src = this.URL; } } }