コード例 #1
0
        private void DuplicateAndPlaceLayer() // Page 39
        {
            Document docref = appRef.Documents.Add();

            appRef.ActiveDocument.ArtLayers.Add();
            LayerSet layerSetRef = docref.LayerSets.Add();
            ArtLayer layerRef    = docref.ArtLayers[1].Duplicate(layerSetRef, 2);
        }
コード例 #2
0
        private void CreateLayerSet() // page 38
        {
            appRef.Documents.Add();
            appRef.ActiveDocument.ArtLayers.Add();
            ArtLayer layerRef = appRef.ActiveDocument.Layers[1];
            // Create a new layer set
            LayerSet newLayerSetRef = appRef.ActiveDocument.LayerSets.Add();

            // Move the new layer to after the first layer
            newLayerSetRef.Move(newLayerSetRef, PsElementPlacement.psPlaceAfter);
        }
コード例 #3
0
ファイル: WorldWind.cs プロジェクト: jpespartero/WorldWind
		/// <summary>
		/// Builds a DirectX FontDescription object from a layer set font description.
		/// </summary>
		protected static Microsoft.DirectX.Direct3D.FontDescription GetLayerFontDescription( LayerSet.Type_DisplayFont2 displayFont )
		{
			Microsoft.DirectX.Direct3D.FontDescription fd = new Microsoft.DirectX.Direct3D.FontDescription();
			fd.FaceName = displayFont.Family.Value;
			fd.Height = (int) ((float)displayFont.Size.Value*1.5f);
			if(displayFont.HasStyle())
			{
				LayerSet.StyleType2 layerStyle = displayFont.Style;
				if(displayFont.Style.HasIsItalic() && layerStyle.IsItalic.Value)
					fd.IsItalic = true;
				else
					fd.IsItalic = false;

				if(displayFont.Style.HasIsBold() && layerStyle.IsBold.Value)
					fd.Weight = Microsoft.DirectX.Direct3D.FontWeight.Bold;
				else
					fd.Weight = Microsoft.DirectX.Direct3D.FontWeight.Regular;
			}
			else
			{
				fd.Weight = Microsoft.DirectX.Direct3D.FontWeight.Regular;
			}
			return fd;
		}
コード例 #4
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;
		}
コード例 #5
0
ファイル: GotoDialog.cs プロジェクト: jpespartero/WorldWind
      // utility function - given a layerset, add all its placenamesets to the above collection, recursing into child layers
      private void collectTiledPlacenamesSets(LayerSet.Type_LayerSet curLayerSet)
      {
         if(curLayerSet.HasTiledPlacenameSet()) // any placenames at all?
         {
            // yes, iterate over them
            for(int i = 0; i < curLayerSet.TiledPlacenameSetCount; i++)
            {
               // get tilesplacenameset
               LayerSet.Type_TiledPlacenameSet2 tpns = curLayerSet.GetTiledPlacenameSetAt(i);

               // compute full path to wpl file - WplIndex constructor needs this
               string wplFullPath = Path.Combine(MainApplication.DirectoryPath, tpns.PlacenameListFilePath.Value);

               // build an index descriptor (does not create or load the index yet)
               WplIndex idx = new WplIndex(tpns, wplFullPath);

               // an indexedTilePlacenameSet associates the index descriptor with the placenameset
               IndexedTiledPlaceNameSet ipns = new IndexedTiledPlaceNameSet(tpns, idx);

               // add them to our collection
               this.indexedTiledPlacenameSets.Add(ipns);
            }
         }
			
         // now recurse into child layers of this set and do the same
         if(curLayerSet.HasChildLayerSet())
         {
            for(int i = 0; i < curLayerSet.ChildLayerSetCount; i++)
            {
               this.collectTiledPlacenamesSets(curLayerSet.GetChildLayerSetAt(i));
            }
         }
      }
コード例 #6
0
ファイル: WplIndex.cs プロジェクト: jpespartero/WorldWind
      /// <summary>
      /// Initializes a new instance of the <see cref= "T:WorldWind.WplIndex"/> class. 
      /// Gets the full path to the list file as parameter
      /// Note that the constructor will neiter load the index data, nor create it if
      /// not present - all it does is "get ready" by loading the list of WWP files
      /// </summary>
      /// <param name="tps">Placename set (layer) the index is associated with</param>
      /// <param name="strWplFilePath">The full list file path</param>
			public WplIndex(LayerSet.Type_TiledPlacenameSet2 tps, string strWplFilePath) 
      {
         this.m_placeNameSet = tps; // remember placename set (layer) we're associated with
         this.m_strWplPath = strWplFilePath; // remember the full list file path
         m_strBasedir = Path.GetDirectoryName(strWplFilePath); // compute/store basedir

         ReadWwpNamesFromWpl(strWplFilePath); // load the place file names from the wpl.

         // computing total placenames is deferred until actually needed
         // PlaceCount accessor will take care of this.
      }
コード例 #7
0
ファイル: WplIndex.cs プロジェクト: jpespartero/WorldWind
		 /// <summary>
		 /// Initializes a new instance of the <see cref= "T:WorldWind.IndexedTiledPlaceNameSet"/> class. 
		 /// Initializes placenameset and index.
		 /// </summary>
		 /// <param name="pns"></param>
		 /// <param name="idx"></param>
      public IndexedTiledPlaceNameSet(LayerSet.Type_TiledPlacenameSet2 pns, WplIndex idx) 
      {
         placenameSet = pns;
         wplIndex = idx;
      }