Esempio n. 1
0
		public static ImageLayerInfo FromFile(string filePath)
		{
			using( FileStream stream = File.OpenRead(filePath) )
			using( BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.Unicode ) )
			{
				ImageLayerInfo imageLayerInfo = new ImageLayerInfo();
				imageLayerInfo.Id = reader.ReadString();
				string imageFileName = Path.GetFileName( reader.ReadString() );
				imageLayerInfo.ImageFilePath = Path.Combine( Path.GetDirectoryName( filePath ), imageFileName );
				if(!File.Exists(imageLayerInfo.ImageFilePath))
					throw new IOException("Cached image '" + imageLayerInfo.ImageFilePath + "' not found.");
				imageLayerInfo.Description = reader.ReadString();
				imageLayerInfo.South = reader.ReadSingle();
				imageLayerInfo.West = reader.ReadSingle();
				imageLayerInfo.North = reader.ReadSingle();
				imageLayerInfo.East = reader.ReadSingle();
				return imageLayerInfo;
			}
		}
Esempio n. 2
0
		/// <summary>
		/// Convert if requested and prepare downloaded data for display
		/// </summary>
		private void ProcessDownloadedImage(WMSDownload wdl, Stream dataStream)
		{
			try
			{
				string ddsFile = wdl.SavedFilePath + ".dds";
				if( wdl.Date.Length>0)
					UpdateStatusBar( "Converting " + wdl.Date );
				else
					UpdateStatusBar( "Converting... " );
				Directory.CreateDirectory(Path.GetDirectoryName(wdl.SavedFilePath));
				if (dataStream.Length==0)
					throw new WebException("Server returned no data.");
				ImageHelper.ConvertToDxt3(dataStream, ddsFile );
				if(this.animationState == AnimationState.Cancel || animationState == AnimationState.Stop)
					return;
		
				ImageLayerInfo imageLayerInfo = new ImageLayerInfo(wdl);
				imageLayerInfo.Save(wdl.SavedFilePath + ".wwi");
				lock(this.animationFrames.SyncRoot)
					animationFrames.Add(imageLayerInfo);
				
				if(this.animationState == AnimationState.Cancel || this.animationState == AnimationState.Stop)
					return;

				UpdateStatusBar( "" );
			}
			catch(Exception caught)
			{
				this.worldWindow.Caption = caught.Message;
				Log.Write( caught );
			}
		}