Exemplo n.º 1
0
        private static void ReadFromBin()
        {
            MPCList = new List <CAAEllipticalObjectElements>();
            string filename = Properties.Settings.Default.CahceDirectory + "\\data\\mpc.bin";

            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?Q=mpcbin", filename, false, true);
            FileStream   fs  = new FileStream(filename, FileMode.Open);
            long         len = fs.Length;
            BinaryReader br  = new BinaryReader(fs);
            CAAEllipticalObjectElements ee;

            try
            {
                while (fs.Position < len)
                {
                    ee = new CAAEllipticalObjectElements(br);
                    MPCList.Add(ee);
                }
            }
            catch
            {
            }
            br.Close();
            fs.Close();
        }
Exemplo n.º 2
0
        public static Language[] GetAvailableLanguages()
        {
            string filename = string.Format(@"{0}\Data\Localization\Languages.xml", Properties.Settings.Default.CahceDirectory);

            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?X=Languages", filename, false, false);
            List <Language> list = new List <Language>();
            XmlDocument     doc  = new XmlDocument();

            doc.Load(filename);

            XmlNode root = doc["LanguagePacks"];

            if (root != null)
            {
                foreach (XmlNode child in root.ChildNodes)
                {
                    list.Add(new Language(child));
                }
            }

            // Add Local Langues Pack

            Language local = new Language("Load Local Language Pack", "", "ZZZZ", Properties.Settings.Default.ExploreRootUrl,
                                          Properties.Settings.Default.ImageSetUrl, "");

            list.Add(local);


            return(list.ToArray());
        }
Exemplo n.º 3
0
        static Constellations()
        {
            try
            {
                if (!Directory.Exists(Properties.Settings.Default.CahceDirectory))
                {
                    Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory);
                }

                if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"data"))
                {
                    Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"data");
                }
                ConstellationCentroids = new Dictionary <string, IPlace>();
                DataSetManager.DownloadFile("http://www.worldwidetelescope.org/data/constellationNames_RADEC_EN.txt", Properties.Settings.Default.CahceDirectory + @"data\constellationNamesRADEC.txt", true, true);
                FullNames     = new Dictionary <string, string>();
                Abbreviations = new Dictionary <string, string>();

                PictureBlendStates = new Dictionary <string, BlendState>();
                int id = 0;

                StreamReader sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\constellationNamesRADEC.txt");
                string       line;
                while (sr.Peek() >= 0)
                {
                    line = sr.ReadLine();
                    string[] data = line.Split(new char[] { ',' });

                    ConstellationFilter.BitIDs.Add(data[1], id++);
                    PictureBlendStates.Add(data[1], new BlendState(false, 1000, 0));

                    ConstellationCentroids.Add(data[1], new TourPlace(data[0], Convert.ToDouble(data[3]), Convert.ToDouble(data[2]), Classification.Constellation, data[1], ImageSetType.Sky, 360));
                }
                sr.Close();

                ConstellationNamePositions = new Dictionary <string, IPlace>();
                DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?q=ConstellationNamePositions_EN", Properties.Settings.Default.CahceDirectory + @"data\ConstellationNamePositions.txt", true, true);
                sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\ConstellationNamePositions.txt");
                while (sr.Peek() >= 0)
                {
                    line = sr.ReadLine();
                    string[] data = line.Split(new char[] { ',' });
                    ConstellationNamePositions.Add(data[1], new TourPlace(data[0], Convert.ToDouble(data[3]), Convert.ToDouble(data[2]), Classification.Constellation, data[1], ImageSetType.Sky, 360));
                }
                sr.Close();

                string path = ArtworkPath;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=hevelius", ArtworkPath + "default.wtml", false, true);
                AddAllNameMappings();
                ConstellationFilter.InitSets();
            }
            catch
            {
            }
        }
Exemplo n.º 4
0
        public static void LoadLocalizedStrings(Language l)
        {
            string path = string.Format(@"{0}\Data\Localization", Properties.Settings.Default.CahceDirectory);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string filename = string.Format(@"{0}\Data\Localization\lang_{1}.tdf", Properties.Settings.Default.CahceDirectory, Math.Abs(l.Url.GetHashCode32()));

            DataSetManager.DownloadFile(l.Url, filename, false, false);

            //Stream fs = (Stream)Assembly.GetExecutingAssembly().GetManifestResourceStream("IMDFrame.Localization." + string.Format("lang_{0}.tdf", l.Code));
            try
            {
                Stream       fs = File.Open(filename, FileMode.Open);
                StreamReader sr = new StreamReader(fs, Encoding.UTF8);


                localizedStrings = new Dictionary <int, string>();
                try
                {
                    while (!sr.EndOfStream)
                    {
                        try
                        {
                            string line = sr.ReadLine();

                            string[] split = line.Split(new char[1] {
                                '\t'
                            });
                            string text = split[1];
                            text = text.Replace("\\n", "\n");

                            localizedStrings.Add(Convert.ToInt32(split[0]), text);
                        }
                        catch
                        {
                        }
                    }
                }
                finally
                {
                    sr.Close();
                    fs.Close();
                }
            }
            catch
            {
                return;
            }
        }
Exemplo n.º 5
0
        static public Bitmap LoadThumbnailFromWeb(string url, string filename)
        {
            try
            {
                DataSetManager.DownloadFile(CacheProxy.GetCacheUrl(url), Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename, true, true);

                return(UiTools.LoadBitmap(Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename));
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        public DataSet(string name, string url, bool sky, DataSetType type)
        {
            this.dataSetType = type;

            this.Sky  = sky;
            this.name = name;
            this.url  = url;


            DataSetManager.DownloadFile(url, Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml", false, true);
            XmlDocument doc = new XmlDocument();

            doc.Load(Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml");

            dataSets = new Dictionary <string, Places>();


            XmlNode root         = doc["root"];
            XmlNode dataSetsNode = root.SelectSingleNode("dataset");

            this.groupingName = dataSetsNode.Attributes["Groups"].InnerXml;
            DataSetType dst = DataSetType.Place;

            if (dataSetsNode.Attributes["type"].Value != "place")
            {
                dst = DataSetType.Imageset;
            }
            foreach (XmlNode dataset in dataSetsNode.ChildNodes)
            {
                bool browsable = false;
                if (dataset.Attributes["Browseable"] != null)
                {
                    browsable = Convert.ToBoolean(dataset.Attributes["Browseable"].Value);
                }

                string thumbnailUrl = "";
                if (dataset.Attributes["Thumbnail"] != null)
                {
                    thumbnailUrl = dataset.Attributes["Thumbnail"].Value;
                }



                Places places = new Places(dataset.Attributes["name"].InnerXml, dataset.Attributes["url"].InnerXml, sky, thumbnailUrl, browsable, dst);
                dataSets.Add(places.Name, places);
            }
        }
Exemplo n.º 7
0
        private void SetDeviceImage(string url)
        {
            string downloadPath = Properties.Settings.Default.CahceDirectory + @"Imagery\Cache\";
            string downloadName = Properties.Settings.Default.CahceDirectory + @"Imagery\Cache\" + Math.Abs(url.GetHashCode32()).ToString() + ".png";

            if (!Directory.Exists(downloadPath))
            {
                Directory.CreateDirectory(downloadPath);
            }

            DataSetManager.DownloadFile(url, downloadName, true, true);



            ImageLoaded = false;
            DeviceImage.ImageLocation = downloadName;
        }
Exemplo n.º 8
0
        public static void LoadBackground()
        {
            if (loading)
            {
                return;
            }

            loading = true;
            string path     = Properties.Settings.Default.CahceDirectory + @"\mdl\155\";
            string filename = path + "mdl.zip";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            if (!File.Exists(filename))
            {
                DataSetManager.DownloadFile("http://www.worldwidetelescope.org/data/iss.zip", filename, false, true);
            }

            using (Stream s = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                ZipArchive zip = new ZipArchive(s);
                foreach (ZipEntry zFile in zip.Files)
                {
                    Stream output = File.Open(path + zFile.Filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                    Stream input  = zFile.GetFileStream();
                    CopyStream(input, output);
                    input.Close();
                    output.Close();
                }
            }

            filename = path + "mdl.3ds";
            if (File.Exists(filename))
            {
                Object3d o3d = new Object3d(filename, true, false, true, System.Drawing.Color.White);
                if (o3d != null)
                {
                    o3d.ISSLayer = true;
                    issmodel     = o3d;
                }
            }
        }
Exemplo n.º 9
0
        private void LoadTours()
        {
            Cursor.Current = Cursors.WaitCursor;

            resultsList.Clear();
            resultsList.Refresh();
            string filename = Properties.Settings.Default.CahceDirectory + @"data\tours.wtml";

            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/gettours.aspx", filename, false, false);

            Folder tours = Folder.LoadFromFile(filename);

            foreach (Tour result in tours.Tour)
            {
                resultsList.Add(result);
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 10
0
        public static Folder LoadFromUrl(string url, bool versionDependent)
        {
            String dir = Properties.Settings.Default.CahceDirectory + "Data\\WTMLCACHE\\";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string filename = dir + Math.Abs(url.GetHashCode32()).ToString() + ".wtml";

            DataSetManager.DownloadFile(url, filename, false, versionDependent);
            try
            {
                if (File.Exists(filename))
                {
                    Folder temp = LoadFromFile(filename, versionDependent);
                    return(temp);
                }
            }
            catch
            {
            }
            return(null);
        }
Exemplo n.º 11
0
        static FieldOfView()
        {
            Telescopes = new List <Telescope>();
            Cameras    = new List <Camera>();

            if (!Directory.Exists(Properties.Settings.Default.CahceDirectory))
            {
                Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory);
            }

            if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"data"))
            {
                Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"data");
            }

            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?X=instruments", Properties.Settings.Default.CahceDirectory + @"data\instruments.xml", false, true);
            XmlDocument doc = new XmlDocument();

            doc.Load(Properties.Settings.Default.CahceDirectory + @"data\instruments.xml");


            XmlNode root   = doc["root"];
            XmlNode scopes = root.SelectSingleNode("Telescopes");

            foreach (XmlNode child in scopes.ChildNodes)
            {
                Telescope scope = new Telescope(child.Attributes["Manufacturer"].Value, child.InnerText,
                                                Convert.ToDouble(child.Attributes["FocalLength"].Value.ToString()),
                                                Convert.ToDouble(child.Attributes["Aperture"].Value.ToString()),
                                                child.Attributes["ManufacturerUrl"].Value.ToString(),
                                                child.Attributes["MountType"].Value.ToString(),
                                                child.Attributes["OpticalDesign"].Value.ToString());
                Telescopes.Add(scope);
            }

            XmlNode cams = root.SelectSingleNode("Cameras");

            foreach (XmlNode child in cams.ChildNodes)
            {
                Camera camera = new Camera
                                (
                    child.Attributes["Manufacturer"].Value,
                    child.InnerText.Trim(),
                    child.Attributes["ManufacturersURL"].Value.ToString()
                                );
                foreach (XmlNode grandChild in child)
                {
                    if (grandChild.Name != "#text")
                    {
                        Imager imager = new Imager
                                        (
                            Convert.ToInt32(grandChild.Attributes["ID"].Value.ToString()),
                            grandChild.Attributes["Type"].Value.ToString(),
                            Convert.ToDouble(grandChild.Attributes["Width"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["Height"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["HorizontalPixels"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["VerticalPixels"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["CenterX"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["CenterY"].Value.ToString()),
                            Convert.ToDouble(grandChild.Attributes["Rotation"].Value.ToString()),
                            grandChild.Attributes["Filter"].Value.ToString());
                        camera.Chips.Add(imager);
                    }
                }
                Cameras.Add(camera);
            }
        }
Exemplo n.º 12
0
        public Constellations(string name, string url, bool boundry, bool noInterpollation)
        {
            instances.Add(this);

            if (boundry && !noInterpollation)
            {
                boundries = new Dictionary <string, Lineset>();
            }
            this.noInterpollation = noInterpollation;
            this.boundry          = boundry;
            lines     = new List <Lineset>();
            this.name = name;
            this.url  = url;
            if (!Directory.Exists(Properties.Settings.Default.CahceDirectory))
            {
                Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory);
            }

            if (boundry)
            {
                targetPath = Properties.Settings.Default.CahceDirectory + @"data\";
                extention  = ".wwtbnd";
            }
            else
            {
                targetPath = Properties.Settings.Default.CahceDirectory + @"data\figures\";
                extention  = ".wwtfig";
            }


            if (!Directory.Exists(targetPath))
            {
                Directory.CreateDirectory(targetPath);
            }

            if (!string.IsNullOrEmpty(url))
            {
                DataSetManager.DownloadFile(url, targetPath + name + extention, false, true);
            }

            Lineset lineSet = null;

            try
            {
                using (StreamReader sr = new StreamReader(targetPath + name + extention))
                {
                    string    line;
                    string    abrv;
                    string    abrvOld = "";
                    double    ra;
                    double    dec;
                    double    lastRa = 0;
                    PointType type   = PointType.Move;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        if (line.Substring(11, 2) == "- ")
                        {
                            line = line.Substring(0, 11) + " -" + line.Substring(13, (line.Length - 13));
                        }
                        if (line.Substring(11, 2) == "+ ")
                        {
                            line = line.Substring(0, 11) + " +" + line.Substring(13, (line.Length - 13));
                        }
                        dec = Convert.ToDouble(line.Substring(11, 10));
                        if (noInterpollation)
                        {
                            ra = Convert.ToDouble(line.Substring(0, 10));
                        }
                        else
                        {
                            ra = ((Convert.ToDouble(line.Substring(0, 10)) / 24.0 * 360) - 180);
                        }

                        abrv = line.Substring(23, 4).Trim();
                        if (!boundry)
                        {
                            if (line.Substring(28, 1).Trim() != "")
                            {
                                type = (PointType)Convert.ToInt32(line.Substring(28, 1));
                            }
                        }
                        else
                        {
                            if (this.noInterpollation && line.Substring(28, 1) != "O")
                            {
                                continue;
                            }
                        }

                        if (abrv != abrvOld)
                        {
                            type    = PointType.Start;
                            lineSet = new Lineset(abrv);
                            lines.Add(lineSet);
                            if (boundry && !noInterpollation)
                            {
                                boundries.Add(abrv, lineSet);
                            }
                            abrvOld = abrv;
                            lastRa  = 0;
                        }


                        if (this.noInterpollation)
                        {
                            if (Math.Abs(ra - lastRa) > 12)
                            {
                                ra = ra - (24 * Math.Sign(ra - lastRa));
                            }
                            lastRa = ra;
                        }
                        string starName = null;
                        if (line.Length > 30)
                        {
                            starName = line.Substring(30).Trim();
                        }

                        if (starName == null || starName != "Empty")
                        {
                            lineSet.Add(ra, dec, type, starName);
                        }
                        pointCount++;
                        type = PointType.Line;
                    }
                    sr.Close();
                }
            }
            catch
            {
            }
        }
Exemplo n.º 13
0
        private void TaxonomyTree_Load(object sender, EventArgs e)
        {
            Scope.Items.Add(new Scope(Language.GetLocalizedText(373, "Solar System"), "A"));
            Scope.Items.Add(new Scope(Language.GetLocalizedText(374, "Milky Way"), "B"));
            Scope.Items.Add(new Scope(Language.GetLocalizedText(375, "Local Universe"), "C"));
            Scope.Items.Add(new Scope(Language.GetLocalizedText(376, "Early Universe"), "D"));
            Scope.Items.Add(new Scope(Language.GetLocalizedText(377, "Unspecified"), "E"));
            Scope.Text = Language.GetLocalizedText(378, "Select a scope...");

            Stack <TreeNode> Parents = new Stack <TreeNode>();

            Parents.Push(null);
            string filename = Properties.Settings.Default.CahceDirectory + string.Format(@"data\taxonomy_{0}.txt", Language.CurrentLanguage.Code);

            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?Q=taxonomy&L=" + Language.CurrentLanguage.Code, filename, false, false);
            string taxonomy = File.ReadAllText(filename, Encoding.Unicode);

            StringReader sr = new StringReader(taxonomy);

            while (true)
            {
                string line = sr.ReadLine();
                if (line == null)
                {
                    break;
                }

                string[] fields = line.Split(new char[] { '\t' });
                if (fields.Length != 2)
                {
                    continue;
                }

                string id   = fields[0];
                string name = fields[1];

                TreeNode node = new TreeNode(name);
                node.Tag = id;



                if (Parents.Peek() != null)
                {
                    string parent = Parents.Peek().Tag.ToString();
                    int    len    = parent.Length;
                    if (id.Length > len)
                    {
                        // Child Node of parent
                        Parents.Peek().Nodes.Add(node);
                        Parents.Push(node);
                    }
                    else if (id.Length == len)
                    {
                        // Sibling of parent
                        Parents.Pop();
                        Parents.Peek().Nodes.Add(node);
                        Parents.Push(node);
                    }
                    else
                    {
                        while (Parents.Peek() != null && Parents.Peek().Tag.ToString().Length >= id.Length)
                        {
                            Parents.Pop();
                        }
                        if (Parents.Peek() != null)
                        {
                            Parents.Peek().Nodes.Add(node);
                            Parents.Push(node);
                        }
                        else
                        {
                            Parents.Push(node);
                            this.treeView1.Nodes.Add(node);
                        }
                    }
                }
                else
                {
                    Parents.Push(node);
                    this.treeView1.Nodes.Add(node);
                }
            }
            SetTaxonomy();
        }
Exemplo n.º 14
0
        public ArrayList GetPlaceList()
        {
            if (dataList == null || CheckExpiration())
            {
                dataList = new System.Collections.ArrayList();
                if (dataSetType == DataSetType.Place)
                {
                    DataSetManager.DownloadFile(url, Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt", false, true);


                    TourPlace    place;
                    StreamReader sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt");
                    string       line;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        place = new TourPlace(line, sky);
                        dataList.Add(place);
                    }
                    sr.Close();
                }
                else if (dataSetType == DataSetType.Imageset)
                {
                    string filename = Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml";

                    DataSetManager.DownloadFile(url, filename, false, true);



                    XmlDocument doc = new XmlDocument();
                    doc.Load(filename);

                    if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"thumbnails\"))
                    {
                        Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"thumbnails\");
                    }

                    XmlNode imageSets = doc["ImageSets"];
                    if (imageSets == null)
                    {
                        imageSets = doc["Folder"];
                    }

                    foreach (XmlNode imageset in imageSets.ChildNodes)
                    {
                        ImageSetHelper newImageset = ImageSetHelper.FromXMLNode(imageset);
                        if (newImageset != null)
                        {
                            TourPlace newPlace = new TourPlace(newImageset.Name, (newImageset.CenterY), (newImageset.CenterX) / 15, Classification.Unidentified, "Err", ImageSetType.Sky, newImageset.BaseTileDegrees * 10);
                            newPlace.StudyImageset = newImageset;

                            newPlace.ThumbNail = UiTools.LoadThumbnailFromWeb(newImageset.ThumbnailUrl);
                            dataList.Add(newPlace);
                            if (!String.IsNullOrEmpty(newImageset.AltUrl) && !Earth3d.ReplacementImageSets.ContainsKey(newImageset.AltUrl))
                            {
                                Earth3d.ReplacementImageSets.Add(newImageset.AltUrl, newImageset);
                            }
                        }
                    }
                }
            }
            return(dataList);
        }