コード例 #1
0
        private RenderableObject getRenderableObjectListFromLayerSet(World curWorld, LayerSet.Type_LayerSet curLayerSet, string layerSetFile)//ref TreeNode treeNode)
        {
            RenderableObjectList rol = null;

            // If the layer set has icons, use the icon list layer as parent
            if (curLayerSet.HasIcon())
            {
                rol = new Icons(curLayerSet.Name.Value);
                rol.RenderPriority = RenderPriority.Icons;
            }
            else
            {
                rol = new RenderableObjectList(curLayerSet.Name.Value);
            }

            if (curLayerSet.HasShowOnlyOneLayer())
            {
                rol.ShowOnlyOneLayer = curLayerSet.ShowOnlyOneLayer.Value;
            }

            // HACK: This should be part of the settings
            if (curLayerSet.Name.ToString().ToUpper() == "PLACENAMES")
            {
                rol.RenderPriority = RenderPriority.Placenames;
            }

            if (curLayerSet.HasExtendedInformation())
            {
                if (curLayerSet.ExtendedInformation.HasToolBarImage())
                {
                    rol.MetaData.Add("ToolBarImagePath", curLayerSet.ExtendedInformation.ToolBarImage.Value);
                }
            }
            if (curLayerSet.HasImageLayer())
            {
                for (int i = 0; i < curLayerSet.ImageLayerCount; i++)
                {
                    LayerSet.Type_ImageLayer curImageLayerType = curLayerSet.GetImageLayerAt(i);

                    // <TexturePath> could contain Url, relative path, or absolute path
                    string imagePath = null;
                    string imageUrl  = null;
                    if (curImageLayerType.TexturePath.Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).StartsWith(("http://")))
                    {
                        imageUrl = curImageLayerType.TexturePath.Value;
                    }
                    else
                    {
                        imagePath = curImageLayerType.TexturePath.Value;
                        if (!Path.IsPathRooted(imagePath))
                        {
                            imagePath = Path.Combine(PluginEngineGlobal.DirectoryPath, imagePath);
                        }
                    }

                    int transparentColor = 0;

                    if (curImageLayerType.HasTransparentColor())
                    {
                        transparentColor = System.Drawing.Color.FromArgb(
                            curImageLayerType.TransparentColor.Red.Value,
                            curImageLayerType.TransparentColor.Green.Value,
                            curImageLayerType.TransparentColor.Blue.Value).ToArgb();
                    }

                    ImageLayer newImageLayer = new ImageLayer(
                        curImageLayerType.Name.Value,
                        curWorld,
                        (float)curImageLayerType.DistanceAboveSurface.Value,
                        imagePath,
                        (float)curImageLayerType.BoundingBox.South.Value2.DoubleValue(),
                        (float)curImageLayerType.BoundingBox.North.Value2.DoubleValue(),
                        (float)curImageLayerType.BoundingBox.West.Value2.DoubleValue(),
                        (float)curImageLayerType.BoundingBox.East.Value2.DoubleValue(),
                        (byte)curImageLayerType.Opacity.Value,
                        (curImageLayerType.TerrainMapped.Value ? curWorld.TerrainAccessor : null));

                    newImageLayer.ImageUrl         = imageUrl;
                    newImageLayer.TransparentColor = transparentColor;
                    newImageLayer.IsOn             = curImageLayerType.ShowAtStartup.Value;
                    if (curImageLayerType.HasLegendImagePath())
                    {
                        newImageLayer.LegendImagePath = curImageLayerType.LegendImagePath.Value;
                    }

                    if (curImageLayerType.HasExtendedInformation() && curImageLayerType.ExtendedInformation.HasToolBarImage())
                    {
                        newImageLayer.MetaData.Add("ToolBarImagePath", Path.Combine(PluginEngineGlobal.DirectoryPath, curImageLayerType.ExtendedInformation.ToolBarImage.Value));
                    }

                    rol.Add(newImageLayer);
                }
            }

            if (curLayerSet.HasQuadTileSet())
            {
                for (int i = 0; i < curLayerSet.QuadTileSetCount; i++)
                {
                    LayerSet.Type_QuadTileSet2 curQtsType = curLayerSet.GetQuadTileSetAt(i);
                }
            }

            if (curLayerSet.HasPathList())
            {
                for (int i = 0; i < curLayerSet.PathListCount; i++)
                {
                    LayerSet.Type_PathList2 newPathList = curLayerSet.GetPathListAt(i);

                    PathList pl = new PathList(
                        newPathList.Name.Value,
                        curWorld,
                        newPathList.MinDisplayAltitude.DoubleValue(),
                        newPathList.MaxDisplayAltitude.DoubleValue(),
                        PluginEngineGlobal.DirectoryPath + "//" + newPathList.PathsDirectory.Value,
                        newPathList.DistanceAboveSurface.DoubleValue(),
                        (newPathList.HasWinColorName() ? System.Drawing.Color.FromName(newPathList.WinColorName.Value) : System.Drawing.Color.FromArgb(newPathList.RGBColor.Red.Value, newPathList.RGBColor.Green.Value, newPathList.RGBColor.Blue.Value)),
                        curWorld.TerrainAccessor);

                    pl.IsOn = newPathList.ShowAtStartup.Value;

                    if (newPathList.HasExtendedInformation() && newPathList.ExtendedInformation.HasToolBarImage())
                    {
                        pl.MetaData.Add("ToolBarImagePath", Path.Combine(PluginEngineGlobal.DirectoryPath, newPathList.ExtendedInformation.ToolBarImage.Value));
                    }

                    rol.Add(pl);
                }
            }

            if (curLayerSet.HasShapeFileLayer())
            {
                for (int i = 0; i < curLayerSet.ShapeFileLayerCount; i++)
                {
                    LayerSet.Type_ShapeFileLayer2 newShapefileLayer = curLayerSet.GetShapeFileLayerAt(i);
                    Microsoft.DirectX.Direct3D.FontDescription fd   = Global.GetLayerFontDescription(newShapefileLayer.DisplayFont);
                    Microsoft.DirectX.Direct3D.Font            font = worldWindow.DrawArgs.CreateFont(fd);
                    ShapeLayer sp = new ShapeLayer(
                        newShapefileLayer.Name.Value,
                        curWorld,
                        newShapefileLayer.DistanceAboveSurface.DoubleValue(),
                        newShapefileLayer.MasterFilePath.Value,
                        newShapefileLayer.MinimumViewAltitude.DoubleValue(),
                        newShapefileLayer.MaximumViewAltitude.DoubleValue(),
                        font,
                        (newShapefileLayer.HasWinColorName() ? System.Drawing.Color.FromName(newShapefileLayer.WinColorName.Value) : System.Drawing.Color.FromArgb(newShapefileLayer.RGBColor.Red.Value, newShapefileLayer.RGBColor.Green.Value, newShapefileLayer.RGBColor.Blue.Value)),
                        (newShapefileLayer.HasScalarKey() ? newShapefileLayer.ScalarKey.Value : null),
                        (newShapefileLayer.HasShowBoundaries() ? newShapefileLayer.ShowBoundaries.Value : false),
                        (newShapefileLayer.HasShowFilledRegions() ? newShapefileLayer.ShowFilledRegions.Value : false));

                    sp.IsOn = newShapefileLayer.ShowAtStartup.BoolValue();

                    if (newShapefileLayer.HasExtendedInformation() && newShapefileLayer.ExtendedInformation.HasToolBarImage())
                    {
                        sp.MetaData.Add("ToolBarImagePath", Path.Combine(PluginEngineGlobal.DirectoryPath, newShapefileLayer.ExtendedInformation.ToolBarImage.Value));
                    }

                    rol.Add(sp);
                }
            }

            if (curLayerSet.HasIcon())
            {
                Icons icons = (Icons)rol;

                for (int i = 0; i < curLayerSet.IconCount; i++)
                {
                    LayerSet.Type_Icon newIcon = curLayerSet.GetIconAt(i);

                    string textureFullPath = newIcon.TextureFilePath.Value;
                    if (textureFullPath.Length > 0 && !Path.IsPathRooted(textureFullPath))
                    {
                        // Use absolute path to icon image
                        textureFullPath = Path.Combine(PluginEngineGlobal.DirectoryPath, newIcon.TextureFilePath.Value);
                    }

                    WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
                        newIcon.Name.Value,
                        (float)newIcon.Latitude.Value2.DoubleValue(),
                        (float)newIcon.Longitude.Value2.DoubleValue(),
                        (float)newIcon.DistanceAboveSurface.DoubleValue());

                    ic.TextureFileName = textureFullPath;
                    ic.Width           = newIcon.IconWidthPixels.Value;
                    ic.Height          = newIcon.IconHeightPixels.Value;
                    ic.IsOn            = newIcon.ShowAtStartup.Value;
                    if (newIcon.HasDescription())
                    {
                        ic.Description = newIcon.Description.Value;
                    }
                    if (newIcon.HasClickableUrl())
                    {
                        ic.ClickableActionURL = newIcon.ClickableUrl.Value;
                    }
                    if (newIcon.HasMaximumDisplayAltitude())
                    {
                        ic.MaximumDisplayDistance = (float)newIcon.MaximumDisplayAltitude.Value;
                    }
                    if (newIcon.HasMinimumDisplayAltitude())
                    {
                        ic.MinimumDisplayDistance = (float)newIcon.MinimumDisplayAltitude.Value;
                    }

                    icons.Add(ic);
                }
            }

            if (curLayerSet.HasTiledPlacenameSet())
            {
                for (int i = 0; i < curLayerSet.TiledPlacenameSetCount; i++)
                {
                    LayerSet.Type_TiledPlacenameSet2 newPlacenames = curLayerSet.GetTiledPlacenameSetAt(i);

                    string filePath = newPlacenames.PlacenameListFilePath.Value;
                    if (!Path.IsPathRooted(filePath))
                    {
                        filePath = Path.Combine(PluginEngineGlobal.DirectoryPath, filePath);
                    }

                    Microsoft.DirectX.Direct3D.FontDescription fd = Global.GetLayerFontDescription(newPlacenames.DisplayFont);
                    TiledPlacenameSet tps = new TiledPlacenameSet(
                        newPlacenames.Name.Value,
                        curWorld,
                        newPlacenames.DistanceAboveSurface.DoubleValue(),
                        newPlacenames.MaximumDisplayAltitude.DoubleValue(),
                        newPlacenames.MinimumDisplayAltitude.DoubleValue(),
                        filePath,
                        fd,
                        (newPlacenames.HasWinColorName() ? System.Drawing.Color.FromName(newPlacenames.WinColorName.Value) : System.Drawing.Color.FromArgb(newPlacenames.RGBColor.Red.Value, newPlacenames.RGBColor.Green.Value, newPlacenames.RGBColor.Blue.Value)),
                        (newPlacenames.HasIconFilePath() ? newPlacenames.IconFilePath.Value : null));

                    if (newPlacenames.HasExtendedInformation() && newPlacenames.ExtendedInformation.HasToolBarImage())
                    {
                        tps.MetaData.Add("ToolBarImagePath", Path.Combine(PluginEngineGlobal.DirectoryPath, newPlacenames.ExtendedInformation.ToolBarImage.Value));
                    }

                    tps.IsOn = newPlacenames.ShowAtStartup.Value;
                    rol.Add(tps);
                }
            }

            if (curLayerSet.HasChildLayerSet())
            {
                for (int i = 0; i < curLayerSet.ChildLayerSetCount; i++)
                {
                    LayerSet.Type_LayerSet ls = curLayerSet.GetChildLayerSetAt(i);

                    rol.Add(getRenderableObjectListFromLayerSet(curWorld, ls, layerSetFile));
                }
            }

            rol.IsOn = curLayerSet.ShowAtStartup.Value;
            return(rol);
        }
コード例 #2
0
ファイル: WorldWind.cs プロジェクト: jpespartero/WorldWind
		private RenderableObject getRenderableObjectListFromLayerSet(World curWorld, LayerSet.Type_LayerSet curLayerSet, string layerSetFile)//ref TreeNode treeNode)
		{
			RenderableObjectList rol = null;

			// If the layer set has icons, use the icon list layer as parent
			if(curLayerSet.HasIcon())
			{
				rol = new Icons(curLayerSet.Name.Value);
				rol.RenderPriority = RenderPriority.Icons;
			}
			else
				rol = new RenderableObjectList(curLayerSet.Name.Value);
			
			if(curLayerSet.HasShowOnlyOneLayer())
				rol.ShowOnlyOneLayer = curLayerSet.ShowOnlyOneLayer.Value;

			// HACK: This should be part of the settings
			if(curLayerSet.Name.ToString().ToUpper(System.Globalization.CultureInfo.InvariantCulture)=="PLACENAMES")
				rol.RenderPriority = RenderPriority.Placenames;

			if(curLayerSet.HasExtendedInformation())
			{
				if(curLayerSet.ExtendedInformation.HasToolBarImage())
					rol.MetaData.Add("ToolBarImagePath", curLayerSet.ExtendedInformation.ToolBarImage.Value);
			}
			if(curLayerSet.HasImageLayer())
			{
				for(int i = 0; i < curLayerSet.ImageLayerCount; i++)
				{
					LayerSet.Type_ImageLayer curImageLayerType = curLayerSet.GetImageLayerAt(i);
					
					// <TexturePath> could contain Url, relative path, or absolute path
					string imagePath = null;
					string imageUrl = null;
                    if (curImageLayerType.TexturePath.Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).StartsWith(("http://")))
					{
						imageUrl = curImageLayerType.TexturePath.Value;
					}
					else
					{
						imagePath = curImageLayerType.TexturePath.Value;
						if(!Path.IsPathRooted(imagePath))
							imagePath = Path.Combine(DirectoryPath, imagePath);
					}

					int transparentColor = 0;

					if(curImageLayerType.HasTransparentColor())
					{
						transparentColor = System.Drawing.Color.FromArgb(
							curImageLayerType.TransparentColor.Red.Value,
							curImageLayerType.TransparentColor.Green.Value,
							curImageLayerType.TransparentColor.Blue.Value).ToArgb();

					}

					ImageLayer newImageLayer = new ImageLayer(
						curImageLayerType.Name.Value,
						curWorld,
						(float)curImageLayerType.DistanceAboveSurface.Value,
						imagePath,
						(float)curImageLayerType.BoundingBox.South.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.North.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.West.Value2.DoubleValue(),
						(float)curImageLayerType.BoundingBox.East.Value2.DoubleValue(),
						(byte)curImageLayerType.Opacity.Value,
						(curImageLayerType.TerrainMapped.Value ? curWorld.TerrainAccessor : null));

					newImageLayer.ImageUrl = imageUrl;
					newImageLayer.TransparentColor = transparentColor;
					newImageLayer.IsOn = curImageLayerType.ShowAtStartup.Value;
					if(curImageLayerType.HasLegendImagePath())
						newImageLayer.LegendImagePath = curImageLayerType.LegendImagePath.Value;
					
					if(curImageLayerType.HasExtendedInformation() && curImageLayerType.ExtendedInformation.HasToolBarImage())
						newImageLayer.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, curImageLayerType.ExtendedInformation.ToolBarImage.Value));

					rol.Add(newImageLayer);
				}
			}

			if(curLayerSet.HasQuadTileSet())
			{
				for(int i = 0; i < curLayerSet.QuadTileSetCount; i++)
				{
					LayerSet.Type_QuadTileSet2 curQtsType = curLayerSet.GetQuadTileSetAt(i);

					/*ImageAccessor imageAccessor = null;

					string permDirPath = null;
					if(curQtsType.ImageAccessor.HasPermanantDirectory())
					{
						permDirPath = curQtsType.ImageAccessor.PermanantDirectory.Value;
						if(!Path.IsPathRooted(permDirPath))
							permDirPath = Path.Combine( DirectoryPath, permDirPath );
					}

					string cacheDirPath = Path.Combine(worldWindow.Cache.CacheDirectory,
						Path.Combine(curWorld.Name,
						Path.Combine(rol.Name, curQtsType.Name.Value )));

					int transparentColor = 0;
					if(curQtsType.HasTransparentColor())
					{
						transparentColor = System.Drawing.Color.FromArgb(
							curQtsType.TransparentColor.Red.Value,
							curQtsType.TransparentColor.Green.Value,
							curQtsType.TransparentColor.Blue.Value).ToArgb();

					}
					if(curQtsType.ImageAccessor.HasWMSAccessor())
					{
						WMSLayerAccessor wmsLayerAccessor = null;
						wmsLayerAccessor = new WMSLayerAccessor();
						wmsLayerAccessor.ImageFormat = curQtsType.ImageAccessor.WMSAccessor.ImageFormat.Value;
						wmsLayerAccessor.IsTransparent = curQtsType.ImageAccessor.WMSAccessor.UseTransparency.Value;
						wmsLayerAccessor.ServerGetMapUrl = curQtsType.ImageAccessor.WMSAccessor.ServerGetMapUrl.Value;
						wmsLayerAccessor.Version = curQtsType.ImageAccessor.WMSAccessor.Version.Value;
						wmsLayerAccessor.WMSLayerName = curQtsType.ImageAccessor.WMSAccessor.WMSLayerName.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasUsername())
							wmsLayerAccessor.Username = curQtsType.ImageAccessor.WMSAccessor.Username.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasPassword())
							wmsLayerAccessor.Password = curQtsType.ImageAccessor.WMSAccessor.Password.Value;

						if(curQtsType.ImageAccessor.WMSAccessor.HasWMSLayerStyle())
							wmsLayerAccessor.WMSLayerStyle = curQtsType.ImageAccessor.WMSAccessor.WMSLayerStyle.Value;
						else
							wmsLayerAccessor.WMSLayerStyle = "";

						if(curQtsType.ImageAccessor.WMSAccessor.HasServerLogoFilePath())
						{
							string logoPath = Path.Combine(DirectoryPath, curQtsType.ImageAccessor.WMSAccessor.ServerLogoFilePath.Value);
							if(File.Exists(logoPath))
								wmsLayerAccessor.LogoFilePath = logoPath;
						}

						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							wmsLayerAccessor);
					}
					else if(curQtsType.ImageAccessor.HasImageTileService())
					{
						string logoPath = null;
						if(curQtsType.ImageAccessor.ImageTileService.HasServerLogoFilePath())
							logoPath = Path.Combine( DirectoryPath, curQtsType.ImageAccessor.ImageTileService.ServerLogoFilePath.Value);

						ImageTileService imageTileService = new ImageTileService(
							curQtsType.ImageAccessor.ImageTileService.DataSetName.Value,
							curQtsType.ImageAccessor.ImageTileService.ServerUrl.Value,
							logoPath );

						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							imageTileService);
					}
					else if(curQtsType.ImageAccessor.HasDuplicateTilePath())
					{
						string dupePath = curQtsType.ImageAccessor.DuplicateTilePath.Value;
						if(!Path.IsPathRooted(dupePath))
							dupePath = Path.Combine(DirectoryPath, dupePath);
						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath,
							dupePath);
					}
					else
					{
						imageAccessor = new ImageAccessor(
							permDirPath,
							curQtsType.ImageAccessor.TextureSizePixels.Value,
							curQtsType.ImageAccessor.LevelZeroTileSizeDegrees.DoubleValue(),
							curQtsType.ImageAccessor.NumberLevels.Value,
							curQtsType.ImageAccessor.ImageFileExtension.Value,
							cacheDirPath);
					}

					QuadTileSet qts = new QuadTileSet(
						curQtsType.Name.Value,
						curWorld,
						curQtsType.DistanceAboveSurface.DoubleValue(),
						curQtsType.BoundingBox.North.Value2.DoubleValue(),
						curQtsType.BoundingBox.South.Value2.DoubleValue(),
						curQtsType.BoundingBox.West.Value2.DoubleValue(),
						curQtsType.BoundingBox.East.Value2.DoubleValue(),
						(curQtsType.TerrainMapped.Value ? curWorld.TerrainAccessor : null),
						imageAccessor);

					qts.TransparentColor = transparentColor;

					if(curQtsType.ShowAtStartup.Value)
						qts.IsOn = true;
					else
						qts.IsOn = false;


					if(curQtsType.HasExtendedInformation() && curQtsType.ExtendedInformation.HasToolBarImage())
					{
						try
						{
							string fileName = Path.Combine(DirectoryPath, curQtsType.ExtendedInformation.ToolBarImage.Value);
							if (File.Exists(fileName))
								qts.MetaData.Add("ToolBarImagePath", fileName);
						}
						catch
						{
							// TODO: Log or display warning
						}
					}

					rol.Add(qts);*/
				}
			}

			if(curLayerSet.HasPathList())
			{
				for(int i = 0; i < curLayerSet.PathListCount; i++)
				{
					LayerSet.Type_PathList2 newPathList = curLayerSet.GetPathListAt(i);

					PathList pl = new PathList(
						newPathList.Name.Value,
						curWorld,
						newPathList.MinDisplayAltitude.DoubleValue(),
						newPathList.MaxDisplayAltitude.DoubleValue(),
						DirectoryPath + "//" + newPathList.PathsDirectory.Value,
						newPathList.DistanceAboveSurface.DoubleValue(),
						(newPathList.HasWinColorName() ? System.Drawing.Color.FromName(newPathList.WinColorName.Value) : System.Drawing.Color.FromArgb(newPathList.RGBColor.Red.Value, newPathList.RGBColor.Green.Value, newPathList.RGBColor.Blue.Value)),
						curWorld.TerrainAccessor);

					pl.IsOn = newPathList.ShowAtStartup.Value;

					if(newPathList.HasExtendedInformation() && newPathList.ExtendedInformation.HasToolBarImage())
						pl.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newPathList.ExtendedInformation.ToolBarImage.Value));
					
					rol.Add(pl);
				}
			}

			if(curLayerSet.HasShapeFileLayer())
			{
				for(int i = 0; i < curLayerSet.ShapeFileLayerCount; i++)
				{
					LayerSet.Type_ShapeFileLayer2 newShapefileLayer = curLayerSet.GetShapeFileLayerAt(i);
					Microsoft.DirectX.Direct3D.FontDescription fd = GetLayerFontDescription(newShapefileLayer.DisplayFont);
					Microsoft.DirectX.Direct3D.Font font = worldWindow.DrawArgs.CreateFont( fd );
					ShapeLayer sp = new ShapeLayer(
						newShapefileLayer.Name.Value,
						curWorld,
						newShapefileLayer.DistanceAboveSurface.DoubleValue(),
						newShapefileLayer.MasterFilePath.Value,
						newShapefileLayer.MinimumViewAltitude.DoubleValue(),
						newShapefileLayer.MaximumViewAltitude.DoubleValue(),
						font,
						(newShapefileLayer.HasWinColorName() ? System.Drawing.Color.FromName(newShapefileLayer.WinColorName.Value) : System.Drawing.Color.FromArgb(newShapefileLayer.RGBColor.Red.Value, newShapefileLayer.RGBColor.Green.Value, newShapefileLayer.RGBColor.Blue.Value)),
						(newShapefileLayer.HasScalarKey() ? newShapefileLayer.ScalarKey.Value : null),
						(newShapefileLayer.HasShowBoundaries() ? newShapefileLayer.ShowBoundaries.Value : false),
						(newShapefileLayer.HasShowFilledRegions() ? newShapefileLayer.ShowFilledRegions.Value : false));

					sp.IsOn = newShapefileLayer.ShowAtStartup.BoolValue();

					if(newShapefileLayer.HasExtendedInformation() && newShapefileLayer.ExtendedInformation.HasToolBarImage())
						sp.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newShapefileLayer.ExtendedInformation.ToolBarImage.Value));

					rol.Add(sp);
				}
			}

			if(curLayerSet.HasIcon())
			{
				Icons icons = (Icons)rol;

				for(int i = 0; i < curLayerSet.IconCount; i++)
				{
					LayerSet.Type_Icon newIcon = curLayerSet.GetIconAt(i);

					string textureFullPath = newIcon.TextureFilePath.Value;
					if (textureFullPath.Length > 0 && !Path.IsPathRooted(textureFullPath))
						// Use absolute path to icon image
						textureFullPath = Path.Combine( DirectoryPath, newIcon.TextureFilePath.Value );

					WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
						newIcon.Name.Value,
						(float)newIcon.Latitude.Value2.DoubleValue(),
						(float)newIcon.Longitude.Value2.DoubleValue(),
						(float)newIcon.DistanceAboveSurface.DoubleValue() );
					
					ic.TextureFileName = textureFullPath;
					ic.Width =	newIcon.IconWidthPixels.Value;
					ic.Height = newIcon.IconHeightPixels.Value;
					ic.IsOn = newIcon.ShowAtStartup.Value;
					if(newIcon.HasDescription())
						ic.Description = newIcon.Description.Value;
					if(newIcon.HasClickableUrl())
						ic.ClickableActionURL = newIcon.ClickableUrl.Value;
					if(newIcon.HasMaximumDisplayAltitude())
						ic.MaximumDisplayDistance = (float)newIcon.MaximumDisplayAltitude.Value;
					if(newIcon.HasMinimumDisplayAltitude())
						ic.MinimumDisplayDistance = (float)newIcon.MinimumDisplayAltitude.Value;

					icons.Add(ic);
				}
			}

			if(curLayerSet.HasTiledPlacenameSet())
			{
				for(int i = 0; i < curLayerSet.TiledPlacenameSetCount; i++)
				{
					LayerSet.Type_TiledPlacenameSet2 newPlacenames = curLayerSet.GetTiledPlacenameSetAt(i);

					string filePath = newPlacenames.PlacenameListFilePath.Value;
					if(!Path.IsPathRooted(filePath))
						filePath = Path.Combine(DirectoryPath, filePath);

					Microsoft.DirectX.Direct3D.FontDescription fd = GetLayerFontDescription(newPlacenames.DisplayFont);
					TiledPlacenameSet tps = new TiledPlacenameSet(
						newPlacenames.Name.Value,
						curWorld,
						newPlacenames.DistanceAboveSurface.DoubleValue(),
						newPlacenames.MaximumDisplayAltitude.DoubleValue(),
						newPlacenames.MinimumDisplayAltitude.DoubleValue(),
						filePath,
						fd,
						(newPlacenames.HasWinColorName() ? System.Drawing.Color.FromName(newPlacenames.WinColorName.Value) : System.Drawing.Color.FromArgb(newPlacenames.RGBColor.Red.Value, newPlacenames.RGBColor.Green.Value, newPlacenames.RGBColor.Blue.Value)),
						(newPlacenames.HasIconFilePath() ? newPlacenames.IconFilePath.Value : null));

					if(newPlacenames.HasExtendedInformation() && newPlacenames.ExtendedInformation.HasToolBarImage())
						tps.MetaData.Add("ToolBarImagePath", Path.Combine(DirectoryPath, newPlacenames.ExtendedInformation.ToolBarImage.Value));

					tps.IsOn = newPlacenames.ShowAtStartup.Value;
					rol.Add(tps);
				}
			}

			if(curLayerSet.HasChildLayerSet())
			{
				for(int i = 0; i < curLayerSet.ChildLayerSetCount; i++)
				{
					LayerSet.Type_LayerSet ls = curLayerSet.GetChildLayerSetAt(i);

					rol.Add( getRenderableObjectListFromLayerSet( curWorld, ls, layerSetFile));
				}
			}

			rol.IsOn = curLayerSet.ShowAtStartup.Value;
			return rol;
		}
コード例 #3
0
        public void DownloadData(string SEARCHMETHOD1_Text, string SYEAR_Text, string SMONTH_Text, string SDAY_Text, string EYEAR_Text, string EMONTH_Text, string EDAY_Text, string LMAG_Text, string UMAG_Text, string NDEP1_Text, string NDEP2_Text, string SLAT2_Text, string SLAT1_Text, string SLON2_Text, string SLON1_Text, string CLAT_Text, string CLON_Text, string CRAD_Text)
        {
            // Download the queried data
            string USGSUrl = "http://eqint.cr.usgs.gov/neic/cgi-bin/epic/epic.cgi?SEARCHMETHOD=" + SEARCHMETHOD1_Text + "&FILEFORMAT=6&SEARCHRANGE=HH&SYEAR=" + SYEAR_Text + "&SMONTH=" + SMONTH_Text + "&SDAY=" + SDAY_Text + "&EYEAR=" + EYEAR_Text + "&EMONTH=" + EMONTH_Text + "&EDAY=" + EDAY_Text + "&LMAG=" + LMAG_Text + "&UMAG=" + UMAG_Text + "&NDEP1=" + NDEP1_Text + "&NDEP2=" + NDEP2_Text + "&IO1=&IO2=&SLAT2=" + SLAT2_Text + "&SLAT1=" + SLAT1_Text + "&SLON2=" + SLON2_Text + "&SLON1=" + SLON1_Text + "&CLAT=" + CLAT_Text + "&CLON=" + CLON_Text + "&CRAD=" + CRAD_Text + "&SUBMIT=Submit+Search";
            //MessageBox.Show("Submited URL: "+USGSUrl);

            ClearIcons();

            owner.EQIcons.IsOn = true;

            WebDownload dl = new WebDownload(USGSUrl);
            dl.DownloadMemory(WorldWind.Net.DownloadType.Unspecified);

            CultureInfo icy = CultureInfo.InvariantCulture;

            // Create a reader to read the response from the server
            StreamReader reader = new StreamReader(dl.ContentStream);
            string line;

            // Find the 1/3 break point for the date range
            DateTime CStartDate = new DateTime(int.Parse(SYEAR_Text, icy), int.Parse(SMONTH_Text, icy), int.Parse(SDAY_Text, icy));
            DateTime CEndDate = new DateTime(int.Parse(EYEAR_Text, icy), int.Parse(EMONTH_Text, icy), int.Parse(EDAY_Text, icy));
            TimeSpan diff = TimeSpan.FromDays((CEndDate - CStartDate).TotalDays / 3);

            // Counting Earthquakes
            int QuakeCount = 0;
            int CountSmall = 0;
            int CountMedium = 0;
            int CountLarge = 0;
            int CountMajor = 0;

            ArrayList quakeList = new ArrayList();

            while ((line = reader.ReadLine()) != null)
            {

                string[] fields = line.Trim().Split(',');
                if ((fields.Length < 8) || (fields.Length > 0 && fields[0] == "Year"))
                    continue;


                // The rest is for displaying the earthquake markers
                string Q_Date = fields[1] + "/" + fields[2] + "/" + fields[0];// Pulls out the date of the Earthquake
                string Q_Time = fields[3];// Get the Earthquake even time
                float Latitude = float.Parse(fields[4], icy);// Get the Latitude
                float Longitude = float.Parse(fields[5], icy);// Get the Longitude
                float Magnitude = 0;
                if (fields[6].Trim().Length > 0)
                    Magnitude = float.Parse(fields[6], icy);// Get the Magnitude
                float Depth = float.Parse(fields[7], icy);// Get the Depth of the Earthquake


                DateTime DateCompare = new DateTime(int.Parse(fields[0], icy), int.Parse(fields[1], icy), int.Parse(fields[2], icy));

                QuakeItem curQuakeItem = new QuakeItem();
                curQuakeItem.Depth = Depth;
                curQuakeItem.Latitude = Latitude;
                curQuakeItem.Longitude = Longitude;
                curQuakeItem.Magnitude = Magnitude;
                curQuakeItem.Q_Date = Q_Date;
                curQuakeItem.Q_Time = Q_Time;
                curQuakeItem.DateCompare = DateCompare;

                quakeList.Add(curQuakeItem);

                int IconWidth = 20;
                int IconHeight = 20;
                string bitmapShape = "circle";
                string bitmapColor = "red";

                if (DateCompare < (CStartDate + diff))
                    bitmapColor = "green";
                else if (DateCompare > (CEndDate - diff))
                    bitmapColor = "red";
                else
                    bitmapColor = "yellow";


                if (Depth <= 40) // Shallow Depth
                {
                    bitmapShape = "circle";
                }
                else if ((Depth == 41) || (Depth <= 70)) // Medium Depth
                {
                    bitmapShape = "triangle";
                }
                else if ((Depth == 71) || (Depth <= 200)) // Deep Depth
                {
                    bitmapShape = "square";
                }
                else // Ultra Deep
                {
                    bitmapShape = "star";
                }

                if (Magnitude <= 3.5) // Small Icons
                {
                    CountSmall = CountSmall + 1;
                    IconWidth = 20;
                    IconHeight = 20;
                }
                else if ((Magnitude == 3.6) || (Magnitude <= 5.5)) // Medium Icons
                {
                    CountMedium = CountMedium + 1;
                    IconWidth = 33;
                    IconHeight = 33;
                }
                else if ((Magnitude == 5.6) || (Magnitude <= 7.0)) // Large Icons
                {
                    CountLarge = CountLarge + 1;
                    IconWidth = 48;
                    IconHeight = 48;
                }
                else // Major Icons
                {
                    CountMajor = CountMajor + 1;
                    IconWidth = 60;
                    IconHeight = 60;
                }

                string bitmapFileName = String.Format("{0}_{1}.png", bitmapShape, bitmapColor);
                string bitmapFullPath = Path.Combine(owner.PluginDirectory, bitmapFileName);

                // Increase the count
                QuakeCount = QuakeCount + 1;

                // Disply the icon and related data
                WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
                    Q_Date + " - " + Magnitude, // name
                    Latitude,
                    Longitude,
                    0); // DistanceAboveSurface
                ic.Description = "Earthquake Details: \n  Date: " + Q_Date + "\n  Time: " + Q_Time + " UTC\n  Magnitude: " + Magnitude + "\n  Depth: " + Depth + " Km"; // description
                ic.TextureFileName = bitmapFullPath; // textureFullPath
                ic.Width = IconWidth;  // IconWidthPixels
                ic.Height = IconHeight;  //IconHeightPixels    
                ic.ClickableActionURL = ""; //ClickableUrl

                // Add the icon to the layer
                owner.EQIcons.AddIcon(ic);
            }

            // show count 
            //MessageBox.Show("Number of Earthquakes Found: "+ QuakeCount);
            this.QuakesFoundNumber.Text = QuakeCount.ToString();
            this.MajorQuakeNumber.Text = CountMajor.ToString();
            this.LargeQuakeNumber.Text = CountLarge.ToString();
            this.MediumQuakeNumber.Text = CountMedium.ToString();
            this.SmallQuakeNumber.Text = CountSmall.ToString();

            //check the top five quakes
            quakesMagSortList.Clear();

            foreach (QuakeItem curQuakeItem in quakeList)
            {
                bool quakeAdded = false;
                for (int i = 0; i < quakesMagSortList.Count; i++)
                {
                    QuakeItem quakeItem = (QuakeItem)quakesMagSortList[i];

                    if (curQuakeItem.Magnitude >= quakeItem.Magnitude)
                    {
                        quakesMagSortList.Insert(i, curQuakeItem);
                        quakeAdded = true;
                        break;
                    }
                }

                if (!quakeAdded)
                {
                    quakesMagSortList.Add(curQuakeItem);
                }
            }

            int numberTopQuakes = 5;
            if (quakesMagSortList.Count < numberTopQuakes)
                numberTopQuakes = quakesMagSortList.Count;

            for (int i = 0; i < numberTopQuakes; i++)
            {
                QuakeItem quakeItem = (QuakeItem)quakesMagSortList[i];
                switch (i)
                {
                    case 0:
                        TQlink1.BeginInvoke(new SetControlTextDelegate(SetControlText), new object[] { TQlink1, string.Format("{0} - {1}", quakeItem.Q_Date, quakeItem.Magnitude) });
                        break;
                    case 1:
                        TQlink2.BeginInvoke(new SetControlTextDelegate(SetControlText), new object[] { TQlink2, string.Format("{0} - {1}", quakeItem.Q_Date, quakeItem.Magnitude) });
                        break;
                    case 2:
                        TQlink3.BeginInvoke(new SetControlTextDelegate(SetControlText), new object[] { TQlink3, string.Format("{0} - {1}", quakeItem.Q_Date, quakeItem.Magnitude) });
                        break;
                    case 3:
                        TQlink4.BeginInvoke(new SetControlTextDelegate(SetControlText), new object[] { TQlink4, string.Format("{0} - {1}", quakeItem.Q_Date, quakeItem.Magnitude) });
                        break;
                    case 4:
                        TQlink5.BeginInvoke(new SetControlTextDelegate(SetControlText), new object[] { TQlink5, string.Format("{0} - {1}", quakeItem.Q_Date, quakeItem.Magnitude) });
                        break;
                }
            }

            if (numberTopQuakes < 5)
            {
                if (numberTopQuakes == 4)
                    TQlink4.Text = "";

                if (numberTopQuakes < 4)
                    TQlink3.Text = "";

                if (numberTopQuakes < 3)
                    TQlink2.Text = "";

                if (numberTopQuakes < 1)
                    TQlink1.Text = "";
            }

        }
コード例 #4
0
		private static void addScreenOverlaysToIcon(XPathNodeIterator iter, World parentWorld, Icon icon, Cache cache)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					string name = getInnerTextFromFirstChild(iter.Current.Select("Name"));
					string imageUri = getInnerTextFromFirstChild(iter.Current.Select("ImageUri"));
					string startXString = getInnerTextFromFirstChild(iter.Current.Select("StartX"));
					string startYString = getInnerTextFromFirstChild(iter.Current.Select("StartY"));
					string widthString = getInnerTextFromFirstChild(iter.Current.Select("Width"));
					string heightString = getInnerTextFromFirstChild(iter.Current.Select("Height"));
					string opacityString = getInnerTextFromFirstChild(iter.Current.Select("Opacity"));
					string showHeaderString = getInnerTextFromFirstChild(iter.Current.Select("ShowHeader"));
					string refreshTimeString = iter.Current.GetAttribute("Refresh", "");
					string alignmentString = getInnerTextFromFirstChild(iter.Current.Select("Alignment"));
					string clickableUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
					string hideBorderString = getInnerTextFromFirstChild(iter.Current.Select("HideBorder"));

					if(startXString != null && startYString != null)
					{
						int startX = int.Parse(startXString);
						int startY = int.Parse(startYString);

						WorldWind.Renderable.ScreenOverlay overlay = new ScreenOverlay(name, startX, startY, imageUri);
					
						if(widthString != null)
						{
							overlay.Width = int.Parse(widthString);
						}
						if(heightString != null)
						{
							overlay.Height = int.Parse(heightString);
						}

						if(alignmentString != null)
						{
                            if (alignmentString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("left"))
							{
								overlay.Alignment = ScreenAlignment.Left;
							}
                            else if (alignmentString.ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("right"))
							{
								overlay.Alignment = ScreenAlignment.Right;
							}
						}

						if(clickableUrl != null && clickableUrl.Length > 0)
						{
							overlay.ClickableUrl = clickableUrl;
						}

						if(hideBorderString != null && hideBorderString.Length > 0)
							overlay.HideBorder = ParseBool(hideBorderString);

						string cachePath = String.Format("{0}{1}{2}{1}{3}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(icon), name);

						if(refreshTimeString != null && refreshTimeString.Length > 0)
						{
							overlay.RefreshTimeSec = ParseDouble(refreshTimeString);
						}

						string description = getInnerTextFromFirstChild(iter.Current.Select("Description"));
						if(description != null && description.Length > 0)
							overlay.Description = description;

						overlay.SaveFilePath = cachePath;
						addExtendedInformation(iter.Current.Select("ExtendedInformation"), overlay);

						string infoUri = iter.Current.GetAttribute("InfoUri", "");

						if(infoUri != null && infoUri.Length > 0)
						{
							if(overlay.MetaData.Contains("InfoUri"))
							{
								overlay.MetaData["InfoUri"] = infoUri;
							}
							else
							{
								overlay.MetaData.Add("InfoUri", infoUri);
							}
						}

						overlay.MetaData.Add("XmlSource", (string)icon.MetaData["XmlSource"]);
						overlay.ParentList = icon.ParentList;
						if(opacityString != null)
						{
							overlay.Opacity = byte.Parse(opacityString);
						}

						if(showHeaderString != null)
						{
							overlay.ShowHeader = ParseBool(showHeaderString);
						}

						if(World.Settings.useDefaultLayerStates)
						{
							overlay.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
						}
						else
						{
							overlay.IsOn = IsLayerOn(overlay);
						}

						icon.AddOverlay(overlay);
					}
				}
			}
		}
コード例 #5
0
		private static void addIcon(XPathNodeIterator iter, World parentWorld, RenderableObjectList parentRenderable, Cache cache)
		{
			if(iter.Count > 0)
			{
				while(iter.MoveNext())
				{
					XPathNodeIterator nameIter = iter.Current.Select("Name");
					string name = getInnerTextFromFirstChild(nameIter);
		
					double distanceAboveSurface = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("DistanceAboveSurface")));
					double latitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("Latitude/Value")));
					double longitude = ParseDouble(getInnerTextFromFirstChild(iter.Current.Select("Longitude/Value")));
					
					string refreshString = iter.Current.GetAttribute("Refresh", "");
					string description = getInnerTextFromFirstChild(iter.Current.Select("Description"));

					string isRotatedString = getInnerTextFromFirstChild(iter.Current.Select("IsRotated"));
					string rotationDegreesString =  getInnerTextFromFirstChild(iter.Current.Select("RotationDegrees"));

					string minimumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MinimumDisplayAltitude"));
					string maximumDisplayAltitudeString = getInnerTextFromFirstChild(iter.Current.Select("MaximumDisplayAltitude"));

					string clickableUrl = getInnerTextFromFirstChild(iter.Current.Select("ClickableUrl"));
					
					string textureFilePath = getInnerTextFromFirstChild(iter.Current.Select("TextureFilePath"));

                    if (textureFilePath.Length > 0 && !Path.IsPathRooted(textureFilePath) && !textureFilePath.ToLower(System.Globalization.CultureInfo.InvariantCulture).StartsWith("http://"))
						// Use absolute path to icon image
						textureFilePath = Path.Combine( 
							Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), textureFilePath );

					if(!Path.IsPathRooted(textureFilePath))
					{
						Path.Combine(
							Path.GetDirectoryName(
							System.Windows.Forms.Application.ExecutablePath),
							textureFilePath);
					}
					
					WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(
						name,
						latitude,
						longitude,
						distanceAboveSurface );
					
					string nameAlwaysVisibleString = nameIter.Current.GetAttribute("AlwaysVisible", "");
					if(nameAlwaysVisibleString != null && nameAlwaysVisibleString.Length > 0)
					{
						ic.NameAlwaysVisible = ParseBool(nameAlwaysVisibleString);
					}

					ic.TextureFileName = textureFilePath;
					ic.Width =	int.Parse(getInnerTextFromFirstChild(iter.Current.Select("IconWidthPixels")));
					ic.Height = int.Parse(getInnerTextFromFirstChild(iter.Current.Select("IconHeightPixels")));
					
					if(refreshString != null && refreshString.Length > 0)
					{
						ic.RefreshInterval = TimeSpan.FromSeconds(ParseDouble(refreshString));
					}

					string infoUri = iter.Current.GetAttribute("InfoUri", "");

					if(infoUri != null && infoUri.Length > 0)
					{
						if(ic.MetaData.Contains("InfoUri"))
						{
							ic.MetaData["InfoUri"] = infoUri;
						}
						else
						{
							ic.MetaData.Add("InfoUri", infoUri);
						}
					}

					if(description != null)
						ic.Description = description;

					if(clickableUrl != null)
						ic.ClickableActionURL = clickableUrl;

					if(maximumDisplayAltitudeString != null)
						ic.MaximumDisplayDistance = ParseDouble(maximumDisplayAltitudeString);

					if(minimumDisplayAltitudeString != null)
						ic.MinimumDisplayDistance = ParseDouble(minimumDisplayAltitudeString);

					string onClickZoomAltString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomAltitude"));
					string onClickZoomHeadingString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomHeading"));
					string onClickZoomTiltString = getInnerTextFromFirstChild(iter.Current.Select("OnClickZoomTilt"));
					
					if(onClickZoomAltString != null)
						ic.OnClickZoomAltitude = ParseDouble(onClickZoomAltString);

					if(onClickZoomHeadingString != null)
						ic.OnClickZoomHeading = ParseDouble(onClickZoomHeadingString);

					if(onClickZoomTiltString != null)
						ic.OnClickZoomTilt = ParseDouble(onClickZoomTiltString);

					if(isRotatedString != null)
					{
						ic.IsRotated = ParseBool(isRotatedString);
					}

					if(rotationDegreesString != null)
					{
						if(!ic.IsRotated)
							ic.IsRotated = true;

						ic.Rotation = Angle.FromDegrees(ParseDouble(rotationDegreesString));
					}

					addExtendedInformation(iter.Current.Select("ExtendedInformation"), ic);
					
					ic.ParentList = parentRenderable;

					string cachePath = String.Format("{0}{1}{2}{1}{3}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(parentRenderable), name);

					ic.SaveFilePath = cachePath;

					if(World.Settings.useDefaultLayerStates)
					{
						ic.IsOn = ParseBool(iter.Current.GetAttribute("ShowAtStartup", ""));
					}
					else
					{
						ic.IsOn = IsLayerOn(ic);
					}
					ic.MetaData["XmlSource"] = (string)parentRenderable.MetaData["XmlSource"];

					Icons parentIconList = (Icons)parentRenderable;

					parentIconList.Add(ic);

					addScreenOverlaysToIcon(iter.Current.Select("ScreenOverlay"), parentWorld, ic, cache);
				}
			}
		}
コード例 #6
0
        private void ParseGeometry(OGR.Geometry geom, string keyStringValue, double keyNumericValue, string labelValue)
        {
            int geomType = geom.GetGeometryType();

            if (geomType == ogr.wkbUnknown)
            {
                return;
            }

            // points
            else if (geomType == ogr.wkbPoint || geomType == ogr.wkbPoint25D)
            {
                bool dataSubListExists = false;

                foreach (Icons l in styleSubList.ChildObjects)
                {
                    if (l.Name == keyStringValue)
                    {
                        dataSubList       = l;
                        dataSubListExists = true;
                    }
                }

                if (!dataSubListExists)
                {
                    dataSubList = new Icons(keyStringValue);
                    //subSubList.DisableExpansion = true;
                    styleSubList.Add(dataSubList);
                }

                double[] p = { geom.GetX(0), geom.GetY(0) };
                if (needsTransformation)
                {
                    coordTransform.TransformPoint(p);
                }

                WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(labelValue, p[1], p[0], 0);
                //ic.TextureFileName = Path.Combine(this.PluginDirectory, "icon.png");
                ic.TextureFileName = "";
                //ic.Width = 12;
                //ic.Height = 12;

                dataSubList.Add(ic);
                //Console.WriteLine("  Found point, contains " + geom.GetPointCount());
                waitMessage.Text += "\nFound " + geom.GetGeometryName();
            }


            // linestring or multi-line
            else if (geomType == ogr.wkbLineString ||
                     geomType == ogr.wkbLineString25D)
            {
                //Console.WriteLine("  Found " + geom.GetGeometryName() + ", contains " + geom.GetPointCount() + "points, " + geom.GetGeometryCount() + " sub-geometries");
                waitMessage.Text += "\nFound " + geom.GetGeometryName() + ", contains " + geom.GetPointCount() + " points, " + geom.GetGeometryCount() + " sub-geometries";
                bool dataSubListExists = false;

                foreach (Icons l in styleSubList.ChildObjects)
                {
                    if (l.Name == keyStringValue)
                    {
                        dataSubList       = l;
                        dataSubListExists = true;
                    }
                }

                if (!dataSubListExists)
                {
                    dataSubList = new Icons(keyStringValue);
                    //subSubList.DisableExpansion = true;
                    styleSubList.Add(dataSubList);
                }

                int       pointCount = geom.GetPointCount();
                Point3d[] p          = new Point3d[pointCount];

                //TODO: handle 2.5/3D?
                for (int i = 0; i < pointCount; i++)
                {
                    double[] point = { geom.GetX(i), geom.GetY(i) };
                    if (needsTransformation)
                    {
                        coordTransform.TransformPoint(point);
                    }

                    p[i] = new Point3d(point[0], point[1], 0);
                }

                //Color lineColor = Color.FromArgb(infoSelector.LineAlpha, infoSelector.LineColor);
                Color lineColor = InterpolateColor(keyNumericValue, true);

                LineFeature lf = new LineFeature(labelValue,
                                                 world,
                                                 p,
                                                 lineColor);
                lf.LineWidth = infoSelector.NumericMinStyle.LineWidth;
                dataSubList.Add(lf);
            }

            // polygon...
            else if (geomType == ogr.wkbPolygon || geomType == ogr.wkbPolygon25D)
            {
                bool dataSubListExists = false;

                foreach (Icons l in styleSubList.ChildObjects)
                {
                    if (l.Name == keyStringValue)
                    {
                        dataSubList       = l;
                        dataSubListExists = true;
                    }
                }

                if (!dataSubListExists)
                {
                    dataSubList = new Icons(keyStringValue);
                    //subSubList.DisableExpansion = true;
                    styleSubList.Add(dataSubList);
                }

                //Console.WriteLine("  Found " + geom.GetGeometryName() + ", contains " + geom.GetGeometryCount() + " sub-geometries");
                waitMessage.Text += "\nFound " + geom.GetGeometryName() + ", contains " + geom.GetPointCount() + " points, " + geom.GetGeometryCount() + " sub-geometries";

                int numInnerRings = geom.GetGeometryCount() - 1;

                LinearRing[] innerRings;
                if (numInnerRings != 0)
                {
                    innerRings = new LinearRing[numInnerRings];
                }
                else
                {
                    innerRings = null;
                }

                LinearRing outerRing = new LinearRing();

                OGR.Geometry ring;

                //outer ring...
                ring              = geom.GetGeometryRef(0);
                waitMessage.Text += "\nFound " + ring.GetGeometryName() + ", contains " + ring.GetPointCount() + " points, " + ring.GetGeometryCount() + " sub-geometries";

                int       pointCount = ring.GetPointCount();
                Point3d[] p          = new Point3d[pointCount];

                for (int k = 0; k < pointCount; k++)
                {
                    double   x     = ring.GetX(k);
                    double   y     = ring.GetY(k);
                    double[] point = { x, y };
                    if (needsTransformation)
                    {
                        coordTransform.TransformPoint(point);
                    }

                    p[k] = new Point3d(point[0], point[1], 0);
                }

                outerRing.Points = p;

                //inner rings...
                if (innerRings != null)
                {
                    for (int i = 1; i < geom.GetGeometryCount(); i++)
                    {
                        ring              = geom.GetGeometryRef(i);
                        waitMessage.Text += "\nFound " + ring.GetGeometryName() + ", contains " + ring.GetPointCount() + " points, " + ring.GetGeometryCount() + " sub-geometries";
                        for (int j = 0; j < ring.GetPointCount(); j++)
                        {
                            int       innerRingPointCount = ring.GetPointCount();
                            Point3d[] q = new Point3d[innerRingPointCount];

                            for (int k = 0; k < innerRingPointCount; k++)
                            {
                                double   x     = ring.GetX(k);
                                double   y     = ring.GetY(k);
                                double[] point = { x, y };
                                if (needsTransformation)
                                {
                                    coordTransform.TransformPoint(point);
                                }

                                q[k] = new Point3d(point[0], point[1], 0);
                            }

                            LinearRing r = new LinearRing();
                            r.Points = q;

                            innerRings[i - 1] = r;
                        }
                    }
                }

                Color fillColor = InterpolateColor(keyNumericValue, false);
                Color lineColor = InterpolateColor(keyNumericValue, true);

                PolygonFeature pf = new PolygonFeature(
                    labelValue,
                    world,
                    outerRing,
                    innerRings,
                    fillColor);

                pf.Outline      = infoSelector.NumericMinStyle.OutlinePolygons;
                pf.OutlineColor = lineColor;
                dataSubList.Add(pf);
            }

            else if (geomType == ogr.wkbMultiPoint ||
                     geomType == ogr.wkbMultiPoint25D ||
                     geomType == ogr.wkbMultiLineString ||
                     geomType == ogr.wkbMultiLineString25D ||
                     geomType == ogr.wkbMultiPolygon ||
                     geomType == ogr.wkbMultiPolygon25D)
            {
                waitMessage.Text += "\nFound " + geom.GetGeometryName() + ", contains " + geom.GetGeometryCount() + " sub-geometries";
                ParseGeometry(geom, keyStringValue, keyNumericValue, labelValue);
            }
        }
コード例 #7
0
ファイル: FlickrPlugin.cs プロジェクト: Fav/testww
        /// <summary>
        /// This method updates the Icons to reflect only those in view
        /// </summary>
        /// <param name="drawArgs"></param>
        public override void Update(WorldWind.DrawArgs drawArgs)
        {
            base.Update(drawArgs);

            double distance = WorldWind.World.ApproxAngularDistance(drawArgs.WorldCamera.Latitude,
                                                                    drawArgs.WorldCamera.Longitude, this.lastUpdatelat, this.lastUpdatelon).Degrees;
            double altchange = Math.Abs(this.lastUpdatealt - drawArgs.WorldCamera.Altitude);


            if (distance > 10 || altchange < 10000.0 || m_needsupdate)
            {
                this.lastUpdatelon = drawArgs.WorldCamera.Longitude;
                this.lastUpdatelat = drawArgs.WorldCamera.Latitude;
                this.lastUpdatealt = drawArgs.WorldCamera.Altitude;
                this.m_needsupdate = false;

                double viewNorth = drawArgs.WorldCamera.Latitude.Degrees + drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewSouth = drawArgs.WorldCamera.Latitude.Degrees - drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewWest  = drawArgs.WorldCamera.Longitude.Degrees - drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewEast  = drawArgs.WorldCamera.Longitude.Degrees + drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;



                //Need lock on the folder
                lock (this)
                {
                    //TODO: Implement temporary caching and redownload on request
                    PhotoCollection allPhotos = GetPhotoCollection(viewWest, viewSouth,
                                                                   viewEast, viewNorth);

                    this.RemoveAll();
                    foreach (Photo photo in allPhotos)
                    {
                        double photolat = Convert.ToDouble(photo.Latitude);
                        double photolon = Convert.ToDouble(photo.Longitude);
                        WorldWind.Renderable.Icon ic = new WorldWind.Renderable.Icon(photo.Title, photolat
                                                                                     , photolon);
                        ic.Image  = Image;
                        ic.Width  = 16;
                        ic.Height = 16;
                        //ic.MinimumDisplayDistance = 100000;
                        //WorldWind.Renderable.ScreenOverlay overlay
                        //= new WorldWind.Renderable.ScreenOverlay(ic.Name,0.0f,0.0f,photo.ThumbnailUrl);
                        //ic.AddOverlay(overlay);
                        ic.isSelectable = true;
                        ic.Description  = "<img src=\"" + photo.ThumbnailUrl + "\"/><br>" +
                                          photo.License + "<br>" +
                                          photo.DateTaken;
                        double distanceToIcon = Vector3.Length(ic.Position - drawArgs.WorldCamera.Position);

                        //If Camera is far render as icon
                        //if(ic.MinimumDisplayDistance < distanceToIcon)
                        this.Add(ic);
                        //if Camera is near render as textured polygon

                        /*
                         * else
                         * {
                         *  Point3d[] lineends = new Point3d[2];
                         *  lineends[0].X = photolon - 0.1;
                         *  lineends[0].Y = photolat - 0.1;
                         *  lineends[0].Z = 1000;
                         *  lineends[1].X = photolon + 0.1;
                         *  lineends[1].Y = photolat + 0.1;
                         *  lineends[1].Z = 1000;
                         *
                         *  WorldWind.LineFeature line = new LineFeature(photo.Title,
                         *      m_world,lineends,photo.ThumbnailUrl);
                         *  line.AltitudeMode = AltitudeMode.RelativeToGround;
                         *  line.DistanceAboveSurface = 0;
                         *  line.Extrude = true;
                         *
                         *  this.Add(line);
                         * }
                         */

                        //Console.WriteLine("Photos title is " + photo.Title + photo.Latitude + photo.Longitude);
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Draw the icon
        /// </summary>
        protected virtual void Render(DrawArgs drawArgs, Icon icon, Vector3 projectedPoint)
        {
            if (!icon.Inited)
            {
                icon.Initialize(drawArgs);
            }

            if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position))
            {
                return;
            }

            // Check icons for within "visual" range
            double distanceToIcon = Vector3.Length(icon.Position - drawArgs.WorldCamera.Position);

            if (distanceToIcon > icon.MaximumDisplayDistance)
            {
                return;
            }
            if (distanceToIcon < icon.MinimumDisplayDistance)
            {
                return;
            }

            IconTexture iconTexture = GetTexture(icon);
            bool        isMouseOver = icon == mouseOverIcon;

            if (isMouseOver)
            {
                // Mouse is over
                isMouseOver = true;

                if (icon.IsSelectable)
                {
                    DrawArgs.MouseCursor = CursorType.Hand;
                }

                string description = icon.Description;
                if (description == null)
                {
                    description = icon.ClickableActionURL;
                }
                if (description != null)
                {
                    // Render description field
                    DrawTextFormat descFormat = DrawTextFormat.NoClip | DrawTextFormat.WordBreak | DrawTextFormat.Bottom;
                    int            left       = drawArgs.ScreenWidth - 256 - 10;
                    //if(World.Settings.showLayerManager)
                    //    left += World.Settings.layerManagerWidth;
                    Rectangle descRect = Rectangle.FromLTRB(left, 10, drawArgs.ScreenWidth - 10, drawArgs.ScreenHeight - 10);

                    // Draw outline
                    drawArgs.DefaultDrawingFont.DrawText(m_sprite, description, descRect, descFormat, 0xb0 << 24);

                    descRect.Offset(2, 0);
                    drawArgs.DefaultDrawingFont.DrawText(m_sprite, description, descRect, descFormat, 0xb0 << 24);

                    descRect.Offset(0, 2);
                    drawArgs.DefaultDrawingFont.DrawText(m_sprite, description, descRect, descFormat, 0xb0 << 24);

                    descRect.Offset(-2, 0);
                    drawArgs.DefaultDrawingFont.DrawText(m_sprite, description, descRect, descFormat, 0xb0 << 24);

                    // Draw description
                    descRect.Offset(1, -1);
                    drawArgs.DefaultDrawingFont.DrawText(m_sprite, description, descRect, descFormat, descriptionColor);
                }
            }

            int color = isMouseOver ? hotColor : normalColor;

            if (iconTexture == null || isMouseOver)
            {
                // Render label
                if (icon.Name != null)
                {
                    // Render name field
                    const int labelWidth = 1000;                     // Dummy value needed for centering the text
                    if (iconTexture == null)
                    {
                        // Center over target as we have no bitmap
                        Rectangle rect = new Rectangle((int)projectedPoint.X - (labelWidth >> 1), (int)(projectedPoint.Y - (drawArgs.DefaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.ScreenHeight);

                        drawArgs.DefaultDrawingFont.DrawText(m_sprite, icon.Name, rect, DrawTextFormat.Center, color);
                    }
                    else
                    {
                        // Adjust text to make room for icon
                        int spacing = (int)(icon.Width * 0.3f);
                        if (spacing > 10)
                        {
                            spacing = 10;
                        }
                        int offsetForIcon = (icon.Width >> 1) + spacing;

                        Rectangle rect = new Rectangle((int)projectedPoint.X + offsetForIcon, (int)(projectedPoint.Y - (drawArgs.DefaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.ScreenHeight);

                        drawArgs.DefaultDrawingFont.DrawText(m_sprite, icon.Name, rect, DrawTextFormat.WordBreak, color);
                    }
                }
            }

            if (iconTexture != null)
            {
                // Render icon
                float xscale = (float)icon.Width / iconTexture.Width;
                float yscale = (float)icon.Height / iconTexture.Height;
                m_sprite.Transform = Matrix.Scaling(xscale, yscale, 0);

                if (icon.IsRotated)
                {
                    m_sprite.Transform *= Matrix.RotationZ((float)icon.Rotation.Radians - (float)drawArgs.WorldCamera.Heading.Radians);
                }

                m_sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0);
                m_sprite.Draw(iconTexture.Texture, new Vector3(iconTexture.Width >> 1, iconTexture.Height >> 1, 0), Vector3.Empty, color);

                // Reset transform to prepare for text rendering later
                m_sprite.Transform = Matrix.Identity;
            }
        }
コード例 #9
0
        private void refreshTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (isUpdating)
            {
                return;
            }
            isUpdating = true;
            try {
                for (int i = 0; i < this.ChildObjects.Count; i++)
                {
                    RenderableObject ro = (RenderableObject)this.ChildObjects[i];
                    if (ro != null && ro.IsOn &&
                        ro is Icon)
                    {
                        Icon icon = (Icon)ro;

                        if (icon.RefreshInterval == TimeSpan.MaxValue ||
                            icon.LastRefresh > DateTime.Now - icon.RefreshInterval)
                        {
                            continue;
                        }

                        object      key         = null;
                        IconTexture iconTexture = null;

                        if (icon.TextureFileName != null &&
                            icon.TextureFileName.Length > 0)
                        {
                            if (icon.TextureFileName.ToLower().StartsWith("http://") &&
                                icon.SaveFilePath != null)
                            {
                                //download it
                                try {
                                    WebDownload webDownload = new WebDownload(icon.TextureFileName);
                                    webDownload.DownloadType = DownloadType.Unspecified;

                                    FileInfo saveFile = new FileInfo(icon.SaveFilePath);
                                    if (!saveFile.Directory.Exists)
                                    {
                                        saveFile.Directory.Create();
                                    }

                                    webDownload.DownloadFile(saveFile.FullName);
                                }
                                catch {}

                                iconTexture = (IconTexture)m_textures[icon.SaveFilePath];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.StaticDevice, icon.SaveFilePath);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.StaticDevice, icon.SaveFilePath);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                            else
                            {
                                // Icon image from file
                                iconTexture = (IconTexture)m_textures[icon.TextureFileName];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.StaticDevice, icon.TextureFileName);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.StaticDevice, icon.TextureFileName);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                        }
                        else
                        {
                            // Icon image from bitmap
                            if (icon.Image != null)
                            {
                                iconTexture = (IconTexture)m_textures[icon.Image];
                                if (iconTexture != null)
                                {
                                    IconTexture tempTexture = iconTexture;
                                    m_textures[icon.SaveFilePath] = new IconTexture(DrawArgs.StaticDevice, icon.Image);
                                    tempTexture.Dispose();
                                }
                                else
                                {
                                    key         = icon.SaveFilePath;
                                    iconTexture = new IconTexture(DrawArgs.StaticDevice, icon.Image);

                                    // New texture, cache it
                                    m_textures.Add(key, iconTexture);

                                    // Use default dimensions if not set
                                    if (icon.Width == 0)
                                    {
                                        icon.Width = iconTexture.Width;
                                    }
                                    if (icon.Height == 0)
                                    {
                                        icon.Height = iconTexture.Height;
                                    }
                                }
                            }
                        }

                        icon.LastRefresh = DateTime.Now;
                    }
                }
            }
            catch {}
            finally {
                isUpdating = false;
            }
        }
コード例 #10
0
        public override void Render(DrawArgs drawArgs)
        {
            if (!isOn)
            {
                return;
            }

            if (!Inited)
            {
                return;
            }

            // First render everything except icons
            foreach (RenderableObject ro in m_children)
            {
                //	if(ro is Icon)
                //		continue;

                if (!ro.IsOn)
                {
                    continue;
                }

                // Child is not an icon
                ro.Render(drawArgs);
            }

            int  closestIconDistanceSquared = int.MaxValue;
            Icon closestIcon = null;

            // Now render just the icons
            m_sprite.Begin(SpriteFlags.AlphaBlend);
            foreach (RenderableObject ro in m_children)
            {
                if (!ro.IsOn)
                {
                    continue;
                }

                Icon icon = ro as Icon;
                if (icon == null)
                {
                    continue;
                }

                Vector3 translationVector = new Vector3((float)(icon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X), (float)(icon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y), (float)(icon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z));

                // Find closest mouse-over icon
                Vector3 projectedPoint = drawArgs.WorldCamera.Project(translationVector);

                int dx = DrawArgs.LastMousePosition.X - (int)projectedPoint.X;
                int dy = DrawArgs.LastMousePosition.Y - (int)projectedPoint.Y;
                if (icon.SelectionRectangle.Contains(dx, dy))
                {
                    // Mouse is over, check whether this icon is closest
                    int distanceSquared = dx * dx + dy * dy;
                    if (distanceSquared < closestIconDistanceSquared)
                    {
                        closestIconDistanceSquared = distanceSquared;
                        closestIcon = icon;
                    }
                }

                if (icon != mouseOverIcon)
                {
                    Render(drawArgs, icon, projectedPoint);
                }
            }

            // Render the mouse over icon last (on top)
            if (mouseOverIcon != null)
            {
                Vector3 translationVector = new Vector3((float)(mouseOverIcon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X), (float)(mouseOverIcon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y), (float)(mouseOverIcon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z));

                Render(drawArgs, mouseOverIcon, drawArgs.WorldCamera.Project(translationVector));
            }

            mouseOverIcon = closestIcon;

            m_sprite.End();
        }
コード例 #11
0
        public override bool PerformSelectionAction(DrawArgs drawArgs)
        {
            foreach (RenderableObject ro in m_children)
            {
                if (!ro.IsOn)
                {
                    continue;
                }
                if (!ro.IsSelectable)
                {
                    continue;
                }

                Icon icon = ro as Icon;
                if (icon == null)
                {
                    // Child is not an icon
                    if (ro.PerformSelectionAction(drawArgs))
                    {
                        return(true);
                    }
                    continue;
                }

                if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position))
                {
                    continue;
                }

                Vector3 projectedPoint = drawArgs.WorldCamera.Project(icon.Position);
                if (!icon.SelectionRectangle.Contains(DrawArgs.LastMousePosition.X - (int)projectedPoint.X, DrawArgs.LastMousePosition.Y - (int)projectedPoint.Y))
                {
                    continue;
                }

                try {
                    if (DrawArgs.IsLeftMouseButtonDown &&
                        !DrawArgs.IsRightMouseButtonDown)
                    {
                        if (icon.OnClickZoomAltitude != double.NaN || icon.OnClickZoomHeading != double.NaN ||
                            icon.OnClickZoomTilt != double.NaN)
                        {
                            drawArgs.WorldCamera.SetPosition(icon.Latitude, icon.Longitude, icon.OnClickZoomHeading, icon.OnClickZoomAltitude, icon.OnClickZoomTilt);
                        }

                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName        = icon.ClickableActionURL;
                        psi.Verb            = "open";
                        psi.UseShellExecute = true;

                        psi.CreateNoWindow = true;
                        Process.Start(psi);
                    }
                    else if (!DrawArgs.IsLeftMouseButtonDown &&
                             DrawArgs.IsRightMouseButtonDown)
                    {
                        ScreenOverlay[] overlays = icon.Overlays;
                        if (overlays != null &&
                            overlays.Length > 0)
                        {
                            ContextMenu contextMenu = new ContextMenu();
                            foreach (ScreenOverlay curOverlay in overlays)
                            {
                                contextMenu.MenuItems.Add(curOverlay.Name, new EventHandler(icon.OverlayOnOpen));
                            }
                            contextMenu.Show(DrawArgs.StaticParentControl, DrawArgs.LastMousePosition);
                        }
                    }
                    return(true);
                }
                catch {}
            }
            return(false);
        }
コード例 #12
0
        public override void Initialize(DrawArgs drawArgs)
        {
            if (!isOn)
            {
                return;
            }

            if (m_sprite != null)
            {
                m_sprite.Dispose();
                m_sprite = null;
            }

            m_sprite = new Sprite(drawArgs.Device);

            TimeSpan smallestRefreshInterval = TimeSpan.MaxValue;

            // Load all textures
            foreach (RenderableObject ro in m_children)
            {
                Icon icon = ro as Icon;
                if (icon == null)
                {
                    // Child is not an icon
                    if (ro.IsOn)
                    {
                        ro.Initialize(drawArgs);
                    }
                    continue;
                }

                if (icon.RefreshInterval.TotalMilliseconds != 0 && icon.RefreshInterval != TimeSpan.MaxValue &&
                    icon.RefreshInterval < smallestRefreshInterval)
                {
                    smallestRefreshInterval = icon.RefreshInterval;
                }

                // Child is an icon
                icon.Initialize(drawArgs);

                object      key         = null;
                IconTexture iconTexture = null;

                if (icon.TextureFileName != null &&
                    icon.TextureFileName.Length > 0)
                {
                    if (icon.TextureFileName.ToLower().StartsWith("http://") &&
                        icon.SaveFilePath != null)
                    {
                        //download it
                        try {
                            WebDownload webDownload = new WebDownload(icon.TextureFileName);
                            webDownload.DownloadType = DownloadType.Unspecified;

                            FileInfo saveFile = new FileInfo(icon.SaveFilePath);
                            if (!saveFile.Directory.Exists)
                            {
                                saveFile.Directory.Create();
                            }

                            webDownload.DownloadFile(saveFile.FullName);
                        }
                        catch {}

                        iconTexture = (IconTexture)m_textures[icon.SaveFilePath];
                        if (iconTexture == null)
                        {
                            key         = icon.SaveFilePath;
                            iconTexture = new IconTexture(drawArgs.Device, icon.SaveFilePath);
                        }
                    }
                    else
                    {
                        // Icon image from file
                        iconTexture = (IconTexture)m_textures[icon.TextureFileName];
                        if (iconTexture == null)
                        {
                            key         = icon.TextureFileName;
                            iconTexture = new IconTexture(drawArgs.Device, icon.TextureFileName);
                        }
                    }
                }
                else
                {
                    // Icon image from bitmap
                    if (icon.Image != null)
                    {
                        iconTexture = (IconTexture)m_textures[icon.Image];
                        if (iconTexture == null)
                        {
                            // Create new texture from image
                            key         = icon.Image;
                            iconTexture = new IconTexture(drawArgs.Device, icon.Image);
                        }
                    }
                }

                if (iconTexture == null)
                {
                    // No texture set
                    continue;
                }

                if (key != null)
                {
                    // New texture, cache it
                    m_textures.Add(key, iconTexture);

                    // Use default dimensions if not set
                    if (icon.Width == 0)
                    {
                        icon.Width = iconTexture.Width;
                    }
                    if (icon.Height == 0)
                    {
                        icon.Height = iconTexture.Height;
                    }
                }
            }

            // Compute mouse over bounding boxes
            foreach (RenderableObject ro in m_children)
            {
                Icon icon = ro as Icon;
                if (icon == null)
                {
                    // Child is not an icon
                    continue;
                }

                if (GetTexture(icon) == null)
                {
                    // Label only
                    icon.SelectionRectangle = drawArgs.DefaultDrawingFont.MeasureString(null, icon.Name, DrawTextFormat.None, 0);
                }
                else
                {
                    // Icon only
                    icon.SelectionRectangle = new Rectangle(0, 0, icon.Width, icon.Height);
                }

                // Center the box at (0,0)
                icon.SelectionRectangle.Offset(-icon.SelectionRectangle.Width / 2, -icon.SelectionRectangle.Height / 2);
            }

            if (refreshTimer == null &&
                smallestRefreshInterval != TimeSpan.MaxValue)
            {
                refreshTimer          = new Timer(smallestRefreshInterval.TotalMilliseconds);
                refreshTimer.Elapsed += new ElapsedEventHandler(refreshTimer_Elapsed);
                refreshTimer.Start();
            }

            Inited = true;
        }
コード例 #13
0
 /// <summary>
 /// Adds an icon to this layer. Deprecated.
 /// </summary>
 public void AddIcon(Icon icon)
 {
     Add(icon);
 }
コード例 #14
0
		/// <summary>
		/// Creates an icon on the globe
		/// </summary>
		/// <param name="Name">The name of the item</param>
		/// <param name="Desc">The description</param>
		/// <param name="Lat">The latitude for the icon</param>
		/// <param name="Lon">The longitude for the icon</param>
		/// <param name="URL">The URL to open when the icon is clicked</param>
		/// <param name="bitmapPath">The path to the bitmap to show</param>
		private void CreateIcon(string Name, string Desc, float Lat, float Lon, int Alt, string URL, string bitmapPath)
		{
			int bitmapSize = 64;
 
			// Create the icon and set initial settings
			Icon ic = new Icon(
				Name,										// name
				Lat,										// latitude
				Lon,										// longitude
				(float)Alt);								// altitude
 
			// Set optional icon settings
			ic.Description = Desc;
			ic.ClickableActionURL = URL;
			ic.TextureFileName = bitmapPath;
			ic.Height = ic.Width = bitmapSize;
			ic.RenderPriority = RenderPriority.Icons;
 
			// Add the icon to the layer
			EQIcons.AddIcon(ic);
		}