Пример #1
0
		public WMSDownload GetWmsRequest( string dateString, 
			WMSLayerStyle curStyle,
			decimal north,
			decimal south,
			decimal west,
			decimal east,
			string cacheDirectory)
		{
			string url =	GetWMSRequestUrl(dateString,
				(curStyle != null ? curStyle.name : null),
				north,
				south,
				west,
				east);

			WMSDownload wmsDownload = new WMSDownload( url );
		
			wmsDownload.North = north;
			wmsDownload.South = south;
			wmsDownload.West = west;
			wmsDownload.East =  east;

			//fix widening errors from conversion of float to decimal for upDown controls
			// TODO: Is this widening thing needed anymore?
			if(this._west > this._east)
			{
				if(wmsDownload.West > this._west)
					wmsDownload.West = this._west;
				if(wmsDownload.East < this._east)
					wmsDownload.East = this._east;
			}
			else
			{
				if(wmsDownload.West < this._west)
					wmsDownload.West = this._west;

				if(wmsDownload.East > this._east)
					wmsDownload.East = this._east;
			}

			if(wmsDownload.North > this._north)
				wmsDownload.North = this._north;
			if(wmsDownload.South < this._south)
				wmsDownload.South = this._south;

			wmsDownload.Title = this._title;
			if(curStyle != null)
				wmsDownload.Title += " (" + curStyle.title + ")";
			
			string path = Path.Combine( cacheDirectory , Path.Combine( 
				this._parentWMSList.Name,
				this._name + (curStyle != null ? curStyle.name : "")));	
			if(dateString!=null && dateString.Length>0)
			{
				wmsDownload.SavedFilePath = Path.Combine( path, dateString.Replace(":",""));
				wmsDownload.Title += "\n" + dateString;
			}
			else
				wmsDownload.SavedFilePath = Path.Combine( path, "Default" );	
			return wmsDownload;
		}
Пример #2
0
		private void buttonPlay_Click(object sender, System.EventArgs e)
		{
			if(this.animationState == AnimationState.Play)
			{
				animationState = AnimationState.Pause;
				buttonPlay.ImageIndex = 4;
				return;
			}

			if(this.animationState == AnimationState.Pause)
			{
				animationState = AnimationState.Play;
				buttonPlay.ImageIndex = 2;
				animationTimer.Start();
				return;
			}

			if(this.animationState == AnimationState.Stop)
			{
				MyWMSLayer curLayer = this.getCurrentlySelectedWMSLayer();
				if(curLayer == null)
					return;

				WMSLayerStyle curStyle = this.getCurrentlySelectedWMSLayerStyle();
				if(curLayer.Dates == null)
					return;

				this.curLoadedLayer = curLayer;
				this.curLoadedStyle = curStyle;
				
				buttonLegend.Enabled = curLayer.HasLegend;

				if(this.comboBoxAnimationStartTime.SelectedIndex == -1 ||
					this.comboBoxAnimationEndTime.SelectedIndex == -1)
					return;

				if(this.comboBoxAnimationStartTime.SelectedIndex > this.comboBoxAnimationEndTime.SelectedIndex)
				{
					// Swap start and end
					int start = comboBoxAnimationEndTime.SelectedIndex;
					comboBoxAnimationEndTime.SelectedIndex = comboBoxAnimationStartTime.SelectedIndex;
					comboBoxAnimationStartTime.SelectedIndex = start;
				}

				if(this.treeViewTableOfContents.SelectedNode.Tag == null) 
					//wms layer not properly selected
					return;

				this.Reset();

				this.groupBoxAnimationTimeFrame.Enabled = false;
				this.groupBoxExtents.Enabled = false;
		
				for(int i = this.comboBoxAnimationStartTime.SelectedIndex; i <= this.comboBoxAnimationEndTime.SelectedIndex; i++)
				{
					WMSDownload wmsDownload = curLayer.GetWmsRequest(
						curLayer.Dates[i],
						curStyle,
						this.numericUpDownNorth.Value,
						this.numericUpDownSouth.Value,
						this.numericUpDownWest.Value,
						this.numericUpDownEast.Value,
						CacheDirectory);

					EnqueueDownload(wmsDownload);
				}

				buttonPlay.ImageIndex = 2;
				animationState = AnimationState.Play;
				animationTimer.Start();
			}
		}
Пример #3
0
		private void buttonLoad_Click(object sender, System.EventArgs e)
		{
			MyWMSLayer curLayer = this.getCurrentlySelectedWMSLayer();
			if (curLayer==null || curLayer.Name == null)
				return;

			this.Reset();

			this.buttonLegend.Enabled = curLayer.HasLegend;
			string dateString = "";
			if(this.comboBoxTime.SelectedItem != null)
				dateString = (string)this.comboBoxTime.SelectedItem;

			WMSLayerStyle curStyle = this.getCurrentlySelectedWMSLayerStyle();

			WMSDownload wmsDownload = curLayer.GetWmsRequest( 
				dateString,
				curStyle,
				this.numericUpDownNorth.Value,
				this.numericUpDownSouth.Value,
				this.numericUpDownWest.Value,
				this.numericUpDownEast.Value,
				this.CacheDirectory);

			if(this.checkBoxLoadCache.Enabled && 
				this.checkBoxLoadCache.Checked &&
				File.Exists(wmsDownload.SavedFilePath + ".wwi") && 
				File.Exists(wmsDownload.SavedFilePath + ".dds"))
			{
				ImageLayerInfo imageLayerInfo = ImageLayerInfo.FromFile(wmsDownload.SavedFilePath + ".wwi");
				lock(this.animationFrames.SyncRoot)
				{
					this.animationFrames.Add(imageLayerInfo);
				}
			}
			else
			{
				EnqueueDownload(wmsDownload);
			}

			this.curLoadedLayer = curLayer;
			this.curLoadedStyle = curStyle;

			this.animationState = AnimationState.Single;
			this.animationTimer.Start();
		}
Пример #4
0
		private string GetCurrentCacheFilePath(MyWMSLayer curLayer, WMSLayerStyle curStyle )
		{
			string parentWmsPath = Path.Combine( this.CacheDirectory, curLayer.ParentWMSList.Name );
			string layerPath = parentWmsPath;
			if(curLayer.Name!=null)
				layerPath = Path.Combine( parentWmsPath, curLayer.Name );
			if(curStyle != null)
				layerPath = Path.Combine( layerPath, curStyle.name );

			string dateString = "Default";
			if (this.comboBoxTime.SelectedIndex > -1)
				dateString = (string) this.comboBoxTime.Items[this.comboBoxTime.SelectedIndex]; 

			string fileName = dateString.Replace(":","");

			string cacheFilePath = Path.Combine( layerPath, fileName+ ".wwi" );
			return cacheFilePath;
		}
Пример #5
0
		private WMSLayerStyle getCurrentlySelectedWMSLayerStyle()
		{
			if(this.treeViewTableOfContents.SelectedNode == null)
				return null;

			WMSLayerStyle someStyle = new WMSLayerStyle();
			if(this.treeViewTableOfContents.SelectedNode.Tag.GetType() == someStyle.GetType())
			{
				return (WMSLayerStyle)this.treeViewTableOfContents.SelectedNode.Tag;
			}

			return null;
		}