[Nasa-exp-checkins] SF.net SVN: nasa-exp: [4019] trunk/WorldWind/PluginSDK
Brought to you by:
baker99-bull,
vigilant
From: <isa...@us...> - 2008-07-03 14:45:30
|
Revision: 4019 http://nasa-exp.svn.sourceforge.net/nasa-exp/?rev=4019&view=rev Author: isaac_apogee Date: 2008-07-03 07:45:28 -0700 (Thu, 03 Jul 2008) Log Message: ----------- WW-888: Offline mode added. WebDownload is not called if World.Settings.WorkOffline is true. All future classes using WebDownload should deal with Offline mode themselves, as WebDownload will not. Modified Paths: -------------- trunk/WorldWind/PluginSDK/ConfigurationLoader.cs trunk/WorldWind/PluginSDK/DownloadableImageFromIconSet.cs trunk/WorldWind/PluginSDK/IconTexture.cs trunk/WorldWind/PluginSDK/ImageLayer.cs trunk/WorldWind/PluginSDK/LineFeature.cs trunk/WorldWind/PluginSDK/ModelFeature.cs trunk/WorldWind/PluginSDK/TiledWFSPlacenameSet.cs trunk/WorldWind/PluginSDK/WorldSettings.cs trunk/WorldWind/PluginSDK/WorldWind.Widgets.PictureBox.cs Modified: trunk/WorldWind/PluginSDK/ConfigurationLoader.cs =================================================================== --- trunk/WorldWind/PluginSDK/ConfigurationLoader.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/ConfigurationLoader.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -254,12 +254,16 @@ else layerFile = layerFile + "&BBOX=" + viewBBox; - WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(layerFile); - download.DownloadMemory(); + // Offline check + if (!World.Settings.WorkOffline) + { + WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(layerFile); + download.DownloadMemory(); - XmlReader docReader = XmlReader.Create(download.ContentStream, readerSettings); - docNav = new XPathDocument(docReader); - docReader.Close(); + XmlReader docReader = XmlReader.Create(download.ContentStream, readerSettings); + docNav = new XPathDocument(docReader); + docReader.Close(); + } } nav = docNav.CreateNavigator(); @@ -296,6 +300,10 @@ else redirect = redirect + "&BBOX=" + viewBBox; + // Offline check + if (World.Settings.WorkOffline) + throw new Exception(); + WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(redirect); string username = iter.Current.GetAttribute("username", ""); Modified: trunk/WorldWind/PluginSDK/DownloadableImageFromIconSet.cs =================================================================== --- trunk/WorldWind/PluginSDK/DownloadableImageFromIconSet.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/DownloadableImageFromIconSet.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -454,7 +454,12 @@ if(!Directory.Exists(Path.GetDirectoryName(this.saveTexturePath))) Directory.CreateDirectory(Path.GetDirectoryName(this.saveTexturePath)); - using( WebDownload dl = new WebDownload(imageUrl)) + + // Offline Check + if (World.Settings.WorkOffline) + throw new Exception(); + + using( WebDownload dl = new WebDownload(imageUrl)) { dl.ProgressCallback += new DownloadProgressHandler(UpdateProgress); dl.DownloadMemory(); Modified: trunk/WorldWind/PluginSDK/IconTexture.cs =================================================================== --- trunk/WorldWind/PluginSDK/IconTexture.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/IconTexture.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -86,9 +86,13 @@ savePath = BaseSavePath + @"\" + savePath + uri.AbsolutePath; savePath = savePath.Replace('/', '\\'); - WorldWind.Net.WebDownload webDownload = new WorldWind.Net.WebDownload(textureFileName); - webDownload.DownloadType = WorldWind.Net.DownloadType.Unspecified; - webDownload.DownloadFile(savePath); + // Offline check + if (!World.Settings.WorkOffline) + { + WorldWind.Net.WebDownload webDownload = new WorldWind.Net.WebDownload(textureFileName); + webDownload.DownloadType = WorldWind.Net.DownloadType.Unspecified; + webDownload.DownloadFile(savePath); + } // reset the texture file name for later use. textureFileName = savePath; Modified: trunk/WorldWind/PluginSDK/ImageLayer.cs =================================================================== --- trunk/WorldWind/PluginSDK/ImageLayer.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/ImageLayer.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -402,6 +402,10 @@ if(_imagePath!=null) Directory.CreateDirectory(Path.GetDirectoryName(this._imagePath)); + // Offline check + if (!World.Settings.WorkOffline) + return; + using(WebDownload downloadReq = new WebDownload(this._imageUrl)) { downloadReq.ProgressCallback += new DownloadProgressHandler(UpdateDownloadProgress); Modified: trunk/WorldWind/PluginSDK/LineFeature.cs =================================================================== --- trunk/WorldWind/PluginSDK/LineFeature.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/LineFeature.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -330,19 +330,23 @@ //load image if (m_imageUri.ToLower().StartsWith("http://")) { - string savePath = string.Format("{0}\\image", ConfigurationLoader.GetRenderablePathString(this)); - System.IO.FileInfo file = new System.IO.FileInfo(savePath); - if (!file.Exists) + // Offline check + if (!World.Settings.WorkOffline) { - WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(m_imageUri); + string savePath = string.Format("{0}\\image", ConfigurationLoader.GetRenderablePathString(this)); + System.IO.FileInfo file = new System.IO.FileInfo(savePath); + if (!file.Exists) + { + WorldWind.Net.WebDownload download = new WorldWind.Net.WebDownload(m_imageUri); - if (!file.Directory.Exists) - file.Directory.Create(); + if (!file.Directory.Exists) + file.Directory.Create(); - download.DownloadFile(file.FullName, WorldWind.Net.DownloadType.Unspecified); + download.DownloadFile(file.FullName, WorldWind.Net.DownloadType.Unspecified); + } + + m_texture = ImageHelper.LoadTexture(file.FullName); } - - m_texture = ImageHelper.LoadTexture(file.FullName); } else { Modified: trunk/WorldWind/PluginSDK/ModelFeature.cs =================================================================== --- trunk/WorldWind/PluginSDK/ModelFeature.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/ModelFeature.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -363,6 +363,10 @@ { try { + // Offline check + if (World.Settings.WorkOffline) + throw new Exception("Offline mode active."); + WebDownload request = new WebDownload(meshFileName); string cachefilename = request.GetHashCode() + extension; @@ -658,8 +662,8 @@ { if (isUpdating) return; - //refresh object position - if (m_refreshurl != null) + // refresh object position, check that not offline + if (m_refreshurl != null && !World.Settings.WorkOffline) { WebDownload dl = new WebDownload(m_refreshurl); dl.SavedFilePath = meshFileName.Replace(".x", ".txt"); Modified: trunk/WorldWind/PluginSDK/TiledWFSPlacenameSet.cs =================================================================== --- trunk/WorldWind/PluginSDK/TiledWFSPlacenameSet.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/TiledWFSPlacenameSet.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -677,6 +677,11 @@ if (!File.Exists(cachefilename)) { m_dlInProcess = true; + + // Offline check + if (World.Settings.WorkOffline) + throw new Exception("Offline mode active."); + WebDownload wfsdl = new WebDownload(this.wfsURL); wfsdl.BackgroundDownloadFile(cachefilename, new DownloadCompleteHandler(DownloadComplete)); } Modified: trunk/WorldWind/PluginSDK/WorldSettings.cs =================================================================== --- trunk/WorldWind/PluginSDK/WorldSettings.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/WorldSettings.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -534,7 +534,17 @@ set { useOfflineSearch = value; } } + internal int downloadQueuedColor = Color.FromArgb(50, 128, 168, 128).ToArgb(); + [XmlIgnore] + [Browsable(true), Category("UI")] + [Editor(typeof(ColorEditor), typeof(UITypeEditor))] + [Description("Color of queued for download image tile rectangles.")] + public Color DownloadQueuedColor + { + get { return Color.FromArgb(downloadQueuedColor); } + set { downloadQueuedColor = value.ToArgb(); } + } #endregion @@ -647,7 +657,7 @@ internal int skyColor = Color.FromArgb(115, 155, 185).ToArgb(); [XmlIgnore] - [Browsable(true), Category("UI")] + [Browsable(true), Category("World")] [Editor(typeof(ColorEditor), typeof(UITypeEditor))] [Description("Color of the sky at sea level.")] public Color SkyColor @@ -1269,8 +1279,28 @@ else verticalExaggeration = value; } - } + } + private TimeSpan terrainTileRetryInterval = TimeSpan.FromMinutes(30); + + [Browsable(true), Category("Terrain")] + [Description("Retry Interval for missing terrain tiles.")] + [XmlIgnore] + public TimeSpan TerrainTileRetryInterval + { + get + { + return terrainTileRetryInterval; + } + set + { + TimeSpan minimum = TimeSpan.FromMinutes(1); + if (value < minimum) + value = minimum; + terrainTileRetryInterval = value; + } + } + #endregion #region Measure tool @@ -1351,38 +1381,19 @@ } #endregion - private TimeSpan terrainTileRetryInterval = TimeSpan.FromMinutes(30); + private bool workOffline = false; - [Browsable(true), Category("Terrain")] - [Description("Retry Interval for missing terrain tiles.")] - [XmlIgnore] - public TimeSpan TerrainTileRetryInterval - { - get - { - return terrainTileRetryInterval; - } - set - { - TimeSpan minimum = TimeSpan.FromMinutes(1); - if (value < minimum) - value = minimum; - terrainTileRetryInterval = value; - } - } + [Browsable(true), Category("World")] + public bool WorkOffline + { + get { return workOffline; } + set + { + workOffline = value; + showDownloadIndicator = !value; + } + } - internal int downloadQueuedColor = Color.FromArgb(50, 128, 168, 128).ToArgb(); - - [XmlIgnore] - [Browsable(true), Category("UI")] - [Editor(typeof(ColorEditor), typeof(UITypeEditor))] - [Description("Color of queued for download image tile rectangles.")] - public Color DownloadQueuedColor - { - get { return Color.FromArgb(downloadQueuedColor); } - set { downloadQueuedColor = value.ToArgb(); } - } - #region Layers internal System.Collections.ArrayList loadedLayers = new System.Collections.ArrayList(); internal bool useDefaultLayerStates = true; Modified: trunk/WorldWind/PluginSDK/WorldWind.Widgets.PictureBox.cs =================================================================== --- trunk/WorldWind/PluginSDK/WorldWind.Widgets.PictureBox.cs 2008-07-03 14:44:40 UTC (rev 4018) +++ trunk/WorldWind/PluginSDK/WorldWind.Widgets.PictureBox.cs 2008-07-03 14:45:28 UTC (rev 4019) @@ -368,8 +368,10 @@ forceDownload = true; } System.IO.FileInfo saveFile = new System.IO.FileInfo(m_SaveFilePath); - - if (forceDownload || !saveFile.Exists || (m_RefreshTime > 0 && saveFile.LastWriteTime.Subtract(System.DateTime.Now) > TimeSpan.FromSeconds(m_RefreshTime))) + + // Offline check added + if (!World.Settings.WorkOffline && (forceDownload || !saveFile.Exists || + (m_RefreshTime > 0 && saveFile.LastWriteTime.Subtract(System.DateTime.Now) > TimeSpan.FromSeconds(m_RefreshTime)))) { //download it try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |