コード例 #1
0
        private void VoRegistrySearch(string keyword)
        {
            try
            {
                lastKeyword = keyword;
                string filename = string.Format(@"{0}\NVOREG.XML", Path.GetTempPath());
                string url      = String.Format("http://nvo.stsci.edu//vor10/NVORegInt.asmx/VOTCapabilityPredicate?predicate=(title%20like%20'%25{0}%25'%20or%20shortname%20like%20'%25{0}%25')&capability={1}", keyword, coneSearch ? "ConeSearch" : "SIAP");


                if (!FileDownload.DownloadFile(url, filename, true))
                {
                    return;
                }

                if (!File.Exists(filename))
                {
                    return;
                }


                string      data = File.ReadAllText(filename);
                XmlDocument doc  = new XmlDocument();
                doc.LoadXml(data);
                registry = new VoTable(doc);

                LoadRegistryResults();
            }
            catch
            {
                fromRegistry.Checked = false;
                fromRegistry.Enabled = false;
                ResourceList.Items.Add(new ListViewItem(Language.GetLocalizedText(915, "Can't access NVO Registry at this time")));
            }
        }
コード例 #2
0
 static void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     complete = true;
     if (dialog != null)
     {
         if (dialog.DownloadComplete != null)
         {
             dialog.DownloadComplete.Invoke(sender, e);
         }
         dialog = null;
     }
 }
コード例 #3
0
        public static void DownloadNewMPSCoreFile()
        {
            string filename = Properties.Settings.Default.CahceDirectory + "\\data\\MPCCORB.DAT.gz";
            string url      = "http://www.minorplanetcenter.net/iau/MPCORB/MPCORB.DAT.gz";

            if (!FileDownload.DownloadFile(url, filename, true))
            {
                return;
            }
            try
            {
                Stream fs = File.OpenRead(filename);
                Stream s  = new GZipStream(fs, CompressionMode.Decompress);
                MPCList.Clear();
                StreamReader sr        = new StreamReader(s);
                bool         dataFound = false;
                while (!sr.EndOfStream)
                {
                    string data = sr.ReadLine();
                    if (dataFound && data.Length > 150)
                    {
                        CAAEllipticalObjectElements ee = new CAAEllipticalObjectElements();

                        ee.a         = Convert.ToDouble(data.Substring(92, 11));
                        ee.e         = Convert.ToDouble(data.Substring(70, 9));
                        ee.i         = Convert.ToDouble(data.Substring(59, 9));
                        ee.omega     = Convert.ToDouble(data.Substring(48, 9));
                        ee.w         = Convert.ToDouble(data.Substring(37, 9));
                        ee.JDEquinox = UnpackEpoch(data.Substring(20, 5));
                        double M = Convert.ToDouble(data.Substring(26, 9));
                        double n = Convert.ToDouble(data.Substring(80, 11));
                        ee.T = ee.JDEquinox - (M / n);
                        MPCList.Add(ee);
                    }
                    else
                    {
                        if (data.Length > 3 && data.Substring(0, 4) == "----")
                        {
                            dataFound = true;
                        }
                    }
                }
                sr.Close();

                WriteBinaryMPCData(Properties.Settings.Default.CahceDirectory + "\\data\\mpc.bin");
            }
            catch
            {
                UiTools.ShowMessageBox(Language.GetLocalizedText(1003, "The image file did not download or is invalid."), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"));
            }
        }
コード例 #4
0
        public static bool DownloadFile(string url, string filename, bool forceDownload)
        {
            if (File.Exists(filename))
            {
                if (!forceDownload)
                {
                    return(true);
                }
                File.Delete(filename);
            }
            Uri uri = new Uri(url);

            if (uri.IsFile)
            {
                string source = uri.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped);
                File.Copy(source, filename);
                return(true);
            }
            complete = false;
            canceled = false;
            client.DownloadFileAsync(uri, filename);

            System.Threading.Thread.Sleep(250);
            if (!complete)
            {
                dialog = new FileDownload();
                dialog.ShowDialog();
            }
            if (canceled)
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
            }


            return(!canceled);
        }
コード例 #5
0
        public static bool DownloadFile(string url, string filename, bool forceDownload)
        {
            if (File.Exists(filename))
            {
                if (!forceDownload)
                {
                    return true;
                }
                File.Delete(filename);
            }
            Uri uri = new Uri(url);
            if (uri.IsFile)
            {
                string source = uri.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped);
                File.Copy(source, filename);
                return true;
            }
            complete = false;
            canceled = false;
            client.DownloadFileAsync( uri, filename);

            System.Threading.Thread.Sleep(250);
            if (!complete)
            {

                dialog = new FileDownload();
                dialog.ShowDialog();
            }
            if (canceled)
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
            }

            return !canceled;
        }
コード例 #6
0
ファイル: TourTab.cs プロジェクト: xx70235/wwt-windows-client
        private static void LaunchTour(ITourResult result)
        {
            string url = String.Format("http://www.worldwidetelescope.org/wwtweb/GetTour.aspx?GUID={0}", result.Id);

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

            string tempFile = Properties.Settings.Default.CahceDirectory + "tourcache\\" + result.Id.ToString() + ".wtt";

            if (FileDownload.DownloadFile(url, tempFile, false))
            {
                FileInfo fi = new FileInfo(tempFile);
                if (fi.Length == 0)
                {
                    File.Delete(tempFile);
                    MessageBox.Show("The tour file could not be downloaded and is not in cache.Check you network connection.", "WorldWide Telescope Tours");
                    return;
                }
                Earth3d.MainWindow.LoadTourFromFile(tempFile, false, result.Id);
            }
        }
コード例 #7
0
ファイル: View.cs プロジェクト: xx70235/wwt-windows-client
        private void showMinorPlanets_CheckedChanged(object sender, EventArgs e)
        {
            if (ignoreChanges)
            {
                return;
            }
            if (this.showMinorPlanets.Checked && !File.Exists(Properties.Settings.Default.CahceDirectory + "\\data\\mpc.bin"))
            {
                if (UiTools.ShowMessageBox("WorldWide Telescope needs to download the latest Minor Planet Center data file (about 12MB). Do you want to proceed?", "Minor Planet Center Data Download", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    this.showMinorPlanets.Checked = false;
                    return;
                }
                string filename = Properties.Settings.Default.CahceDirectory + "\\data\\mpc.bin";

                if (!FileDownload.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?Q=mpcbin", filename, true))
                {
                    this.showMinorPlanets.Checked = false;
                    return;
                }
            }

            Properties.Settings.Default.SolarSystemMinorPlanets.TargetState = this.showMinorPlanets.Checked;
        }
コード例 #8
0
 static void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     complete = true;
     if (dialog != null)
     {
         if (dialog.DownloadComplete != null)
         {
             dialog.DownloadComplete.Invoke(sender, e);
         }
         dialog = null;
     }
 }
コード例 #9
0
        private void ShowCapababilities(bool download)
        {
            if (ServerList.SelectedIndex < 0)
            {
                return;
            }

            add.Enabled = false;

            LayersTree.Nodes.Clear();
            Abstract.Text = "";

            WmsServerEntry wse = (WmsServerEntry)ServerList.SelectedItem;
            string         req = "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.3.0";

            if (wse.Url.Contains("?"))
            {
                req = "&" + req;
            }
            else
            {
                req = "?" + req;
            }

            string url = wse.Url + req;

            string filename      = Properties.Settings.Default.CahceDirectory + "data\\wms\\" + ((uint)url.GetHashCode32()).ToString() + ".xml";
            string tiledFilename = Properties.Settings.Default.CahceDirectory + "data\\wms\\" + ((uint)url.GetHashCode32()).ToString() + ".tiled.xml";

            if (!File.Exists(filename) && !download)
            {
                LayersTree.Nodes.Add(Language.GetLocalizedText(910, "Not loaded -  Click Get Layers to download now"));
                return;
            }

            if (!FileDownload.DownloadFile(url, filename, download))
            {
                return;
            }

            bool   tiled    = false;
            string tiledUrl = "";

            try
            {
                using (Stream stream = File.Open(filename, FileMode.Open))
                {
                    WMS_Capabilities caps = WMS_Capabilities.LoadFromSream(stream);

                    serviceUrl = caps.Capability.Request.GetMap.DCPType[0].HTTP.Get.OnlineResource.href;
                    if (!serviceUrl.Contains("?"))
                    {
                        serviceUrl += "?";
                    }
                    wmsVersion = caps.version;
                    stream.Close();

                    if (caps.Capability.Request.GetTileService != null && !string.IsNullOrEmpty(caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href))
                    {
                        tiled      = true;
                        tiledUrl   = caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href + "request=GetTileService";
                        serviceUrl = caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href;
                        if (!serviceUrl.Contains("?"))
                        {
                            serviceUrl += "?";
                        }
                    }

                    if (!tiled)
                    {
                        AddChildren(caps.Capability.Layer, LayersTree.Nodes);
                    }
                }
            }
            catch
            {
                try
                {
                    using (Stream stream = File.Open(filename, FileMode.Open))
                    {
                        WMT_MS_Capabilities caps = WMT_MS_Capabilities.LoadFromSream(stream);

                        serviceUrl = caps.Capability.Request.GetMap.DCPType[0].HTTP.Get.OnlineResource.href;
                        if (!serviceUrl.Contains("?"))
                        {
                            serviceUrl += "?";
                        }
                        wmsVersion = caps.version;
                        stream.Close();
                        if (caps.Capability.Request.GetTileService != null && !string.IsNullOrEmpty(caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href))
                        {
                            tiled      = true;
                            tiledUrl   = caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href + "request=GetTileService";
                            serviceUrl = caps.Capability.Request.GetTileService.DCPType[0].HTTP.Get.OnlineResource.href;
                            if (!serviceUrl.Contains("?"))
                            {
                                serviceUrl += "?";
                            }
                        }

                        if (!tiled)
                        {
                            AddChildren(caps.Capability.Layer, LayersTree.Nodes);
                        }
                    }
                }
                catch
                {
                }
            }
            // Add Tiled if supported
            try
            {
                if (tiled)
                {
                    if (!FileDownload.DownloadFile(tiledUrl, tiledFilename, false))
                    {
                        return;
                    }
                    using (Stream stream = File.Open(tiledFilename, FileMode.Open))
                    {
                        WMS_Tile_Service wts = WMS_Tile_Service.LoadFromSream(stream);
                        AddChildren(wts.TiledPatterns[0].TiledGroup, LayersTree.Nodes);
                    }
                }
            }
            catch
            {
            }
        }