Esempio n. 1
0
        public void GetStringFromGzipBlob(System.Html.Data.Files.Blob blob, GzipStringReady dataReady)
        {
            // This method decompresses a blob into a string, and if the string cannot be decompressed
            // due to an invalid header, we assume the blob is not compressed and return the string
            // as-is.

            FileReader reader = new FileReader();

            reader.OnLoadEnd = delegate(System.Html.Data.Files.FileProgressEvent e)
            {
                string result = "";
                try {
                    result = (string)Script.Literal("pako.inflate(e.target.result, { to: 'string' })");
                }
                catch (Exception err)
                {
                    if (err.ToString() == "incorrect header check")
                    {
                        result = (string)Script.Literal("String.fromCharCode.apply(null, new Uint8Array(e.target.result))");
                    }
                    else
                    {
                        throw err;
                    }
                };
                dataReady(result);
            };
            reader.ReadAsArrayBuffer(blob);
        }
Esempio n. 2
0
        public void GetStringFromGzipBlob(System.Html.Data.Files.Blob blob, GzipStringReady dataReady)
        {
            FileReader reader = new FileReader();

            reader.OnLoadEnd = delegate(System.Html.Data.Files.FileProgressEvent e)
            {
                string result = (string)Script.Literal("pako.inflate(e.target.result, { to: 'string' })");
                dataReady(result);
            };
            reader.ReadAsArrayBuffer(blob);
        }
Esempio n. 3
0
        public static void GalaxyFileStateChange()
        {
            if (webFileGalaxy.State == StateType.Error)
            {
                Script.Literal("alert({0})", webFileGalaxy.Message);
            }
            else if (webFileGalaxy.State == StateType.Received)
            {
                System.Html.Data.Files.Blob mainBlob = (System.Html.Data.Files.Blob)webFileGalaxy.GetBlob();
                FileReader chunck = new FileReader();
                chunck.OnLoadEnd = delegate(System.Html.Data.Files.FileProgressEvent e)
                {
                    BinaryReader br = new BinaryReader(new Uint8Array(chunck.Result));


                    InitializeCosmos(br);
                };
                chunck.ReadAsArrayBuffer(mainBlob);
            }
        }
Esempio n. 4
0
        public override void LoadData(TourDocument tourDoc, string filename)
        {
            if (extension.ToLowerCase().StartsWith(".fit"))
            {
                System.Html.Data.Files.Blob blob = tourDoc.GetFileBlob(filename.Replace(".txt", extension));

                FitsImage fi = new FitsImage("image.fit", blob, DoneLoading);
                imageSet.WcsImage = fi;
                if (max > 0 || min > 0)
                {
                    fi.lastBitmapMax = max;
                    fi.lastBitmapMin = min;
                    fi.lastScale     = lastScale;
                }
            }
            else
            {
                loaded = true;
            }
        }
        public override void LoadData(TourDocument tourDoc, string filename)
        {
            if (extension.ToLowerCase().StartsWith(".fit"))
            {
                System.Html.Data.Files.Blob blob = tourDoc.GetFileBlob(filename.Replace(".txt", extension));

                FitsImage fi;
                if (RenderContext.UseGlVersion2)
                {
                    fi = new FitsImage(imageSet, "image.fit", blob, DoneLoading);
                }
                else
                {
                    fi = new FitsImageJs(imageSet, "image.fit", blob, DoneLoading);
                }
                imageSet.WcsImage = fi;
            }
            else
            {
                loaded = true;
            }
        }
Esempio n. 6
0
 public virtual void LoadData(System.Html.Data.Files.Blob blob)
 {
     return;
 }