public static void LoadBackground() { if (loading) { return; } loading = true; var path = Properties.Settings.Default.CahceDirectory + @"\mdl\155\"; var 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)) { var zip = new ZipArchive(s); foreach (var zFile in zip.Files) { Stream output = File.Open(path+zFile.Filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None); var input = zFile.GetFileStream(); CopyStream(input, output); input.Close(); output.Close(); } } filename = path + "mdl.3ds"; if (File.Exists(filename)) { var o3d = new Object3d(filename, true, false, true, Color.White); if (o3d != null) { o3d.ISSLayer = true; issmodel = o3d; } } }
public KmlRoot(string filename, KmlRoot owner) { TimeSpan = new KmlTimeSpan(); // Set high and low points. TimeSpan.BeginTime = new DateTime(3999, 1, 1); TimeSpan.EndTime = new DateTime(1, 1, 1); Owner = owner; if (Uri.IsWellFormedUriString(filename, UriKind.Absolute)) { BaseUri = new Uri(filename); } if (!File.Exists(filename) && owner != null & owner.BaseUri != null) { Uri newUri = new Uri(owner.BaseUri, filename); filename = newUri.ToString(); } XmlDocument doc = new XmlDocument(); XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(doc.NameTable); NamespaceManager.AddNamespace("atom", "http://www.w3.org/2005/Atom"); if (filename.ToLower().Contains(".kmz")) { if (Uri.IsWellFormedUriString(filename, UriKind.Absolute)) { Stream fs = UiTools.GetMemoryStreamFromUrl(filename); Archive = new ZipArchive(fs); foreach (ZipEntry entry in Archive.Files) { if (entry.Filename.ToLower().EndsWith(".kml")) { doc.Load(entry.GetFileStream()); } } } else { // using (FileStream fs = new FileStream(filename, FileMode.Open)) FileStream fs = new FileStream(filename, FileMode.Open); { ZipArchive archive = new ZipArchive(fs); foreach (ZipEntry entry in archive.Files) { if (entry.Filename.ToLower().EndsWith(".kml")) { doc.Load(entry.GetFileStream()); Archive = archive; } } } } } else { try { //todo this really needs to be fixed. doc.Load(filename); } catch { } } XmlNode kml = doc["kml"]; if (kml == null) { return; } if (kml.Attributes["hint"] != null) { if (kml.Attributes["hint"].InnerText.ToLower().Contains("sky")) { sky = true; } } LoadDetails(kml); LoadStatus = KmlLoadStatus.Loaded; }