private void DrawSymbolsInOrder(IFeatureCursor Cursor, esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
		{
			// this sub draws either markers or line symbols from large small so that the smallest symbols will be drawn on top

			// in graduated symbol case, a cursor is built and parsed n times for n size classes
			// in proportional symbol case, symbols are sorted and drawn from largest to smallest

			int iSizeIndex = 0;
			int iCurrentDrawableSymbolIndex = 0;
			IFeatureCursor pMyCursor = null;
			IFeature pFeat = null;
			IFeatureDraw pFeatDraw = null;
			bool bContinue = true;
			ISymbol pSizeSym = null;
			ISymbol pDrawSym = null;
			IFeatureCursor pSortedCursor = null;

			if (m_pSizeRend is IProportionalSymbolRenderer)
			{
				// sort 
				pSortedCursor = SortData(Cursor, trackCancel);

				// draw
				pFeat = pSortedCursor.NextFeature();
				while (pFeat != null)
				{
					pDrawSym = GetFeatureSymbol(pFeat);
					// draw the feature
					pFeatDraw = pFeat as IFeatureDraw;
					Display.SetSymbol(pDrawSym);

          //implementation of IExportSupport
          BeginFeature(pFeat, Display);
          					
					pFeatDraw.Draw(drawPhase, Display, pDrawSym, true, null, esriDrawStyle.esriDSNormal);

          //implementation of IExportSupport
          GenerateExportInfo(pFeat, Display);
          EndFeature(Display);
					
					// get next feature
					pFeat = pSortedCursor.NextFeature();
					if (trackCancel != null)
							bContinue = trackCancel.Continue();
				}

			}
			else
			{
				IClassBreaksRenderer pSizeCBRend = null;
                pSizeCBRend = m_pSizeRend as IClassBreaksRenderer;
				pMyCursor = Cursor;
				for (iCurrentDrawableSymbolIndex = (pSizeCBRend.BreakCount - 1); iCurrentDrawableSymbolIndex >= 0; iCurrentDrawableSymbolIndex--)
				{
					// do not build a cursor the 1st time because we already have one
					if (iCurrentDrawableSymbolIndex < (pSizeCBRend.BreakCount - 1))
					{
						// build pMyCursor
						pMyCursor = m_pFeatureClass.Search(m_pQueryFilter, true);
					}
					pFeat = pMyCursor.NextFeature();
					while (pFeat != null)
					{
						// check to see if we will draw in this pass
						pSizeSym = m_pSizeRend.get_SymbolByFeature(pFeat);
						iSizeIndex = GetSymbolIndex(pSizeSym, pSizeCBRend);
						if (iSizeIndex == iCurrentDrawableSymbolIndex)
						{
							// go ahead and draw the symbol
							// get symbol to draw
							pDrawSym = GetFeatureSymbol(pFeat);

							// draw the feature
							pFeatDraw = pFeat as IFeatureDraw;
							Display.SetSymbol(pDrawSym);

              //implementation of IExportSupport
              BeginFeature(pFeat, Display);
							
							pFeatDraw.Draw(drawPhase, Display, pDrawSym, true, null, esriDrawStyle.esriDSNormal);

              //implementation of IExportSupport
              GenerateExportInfo(pFeat, Display);
              EndFeature(Display);
              
							if (trackCancel != null)
									bContinue = trackCancel.Continue();
						}

						pFeat = pMyCursor.NextFeature();
					}

				} // increment DOWN to next symbol size

			}

		}
Exemplo n.º 2
0
        /// <summary>
        /// 根据线要素,及图层获取符号,及线类型
        /// </summary>
        /// <param name="pFeature">线要素</param>
        /// <param name="pLayer">图层</param>
        /// <param name="linetype">线类新</param>
        /// <returns>符号</returns>
        public static ILineSymbol GetLineSymbol(IFeature pFeature, IFeatureLayer pLayer, out epcLineSymbol linetype)
        {
            IGeoFeatureLayer pGeofLayer = pLayer as IGeoFeatureLayer;
            IFeatureRenderer pFRenderer = pGeofLayer.Renderer;
            ISymbol          pSymbol    = pFRenderer.get_SymbolByFeature(pFeature);

            linetype = epcLineSymbol.epcNull;
            if (pSymbol is ISimpleLineSymbol)
            {
                linetype = epcLineSymbol.epcSimple;
            }
            else if (pSymbol is ICartographicLineSymbol)
            {
                linetype = epcLineSymbol.epcCartoGraphic;
            }
            else if (pSymbol is IPictureLineSymbol)
            {
                linetype = epcLineSymbol.epcPicture;
            }
            else if (pSymbol is IMultiLayerLineSymbol)
            {
                linetype = epcLineSymbol.epcMultiLayer;
            }

            if (linetype == epcLineSymbol.epcNull)
            {
                return(null);
            }

            return(pSymbol as ILineSymbol);
        }
Exemplo n.º 3
0
        public static ISymbol GetSymbolFromLayer(ILayer layer)
        {
            if (layer == null)
            {
                return(null);
            }
            IFeatureLayer  featureLayer  = layer as IFeatureLayer;
            IFeatureCursor featureCursor = featureLayer.Search(null, false);
            IFeature       feature       = featureCursor.NextFeature();

            if (feature == null)
            {
                return(null);
            }
            IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
            IFeatureRenderer featureRenderer = geoFeatureLayer.Renderer;

            if (featureRenderer == null)
            {
                return(null);
            }
            ISymbol symbol = featureRenderer.get_SymbolByFeature(feature);

            return(symbol);
        }
Exemplo n.º 4
0
        public static ISymbol GetSymbolByLayer(ILayer layer)
        {
            //判断图层是否获取成功
            if (layer == null)
            {
                return(null);
            }

            //利用IFeatureLayer接口访问目标图层,获取图层的第一个要素
            //如果获取失败,返回空值
            IFeatureLayer  featurelayer  = layer as IFeatureLayer;
            IFeatureCursor featurecursor = featurelayer.Search(null, false);
            IFeature       feature       = featurecursor.NextFeature();

            if (feature == null)
            {
                return(null);
            }
            //通过IGeoFeatureLayer访问图层,获取图层渲染器
            //如果获取失败,返回空值
            IGeoFeatureLayer geofeaturelayer = featurelayer as IGeoFeatureLayer;
            IFeatureRenderer featurerender   = geofeaturelayer.Renderer;

            if (featurerender == null)
            {
                return(null);
            }

            ISymbol symbol = featurerender.get_SymbolByFeature(feature);

            /* ISimpleLineSymbol spl = (ISimpleLineSymbol)symbol;
             * spl.Style = esriSimpleLineStyle.esriSLSDash;
             * symbol = (ISymbol)spl;*/
            return(symbol);
        }
Exemplo n.º 5
0
        public static ISymbol GetSymbolFromLayer(ILayer layer)
        {
            if (layer == null)
            {
                return(null);
            }

            IFeatureLayer  pFl = layer as IFeatureLayer;
            IFeatureCursor pFc = pFl.Search(null, false);
            IFeature       pF  = pFc.NextFeature();

            if (pF == null)
            {
                return(null);
            }

            IGeoFeatureLayer pGfl = pFl as IGeoFeatureLayer;
            IFeatureRenderer pFr  = pGfl.Renderer;

            if (pFr == null)
            {
                return(null);
            }

            ISymbol pSb = pFr.get_SymbolByFeature(pF);

            return(pSb);
        }
Exemplo n.º 6
0
        public static IRgbColor GetFeatureColor(IGeoFeatureLayer igeoFeatureLayer_0, IFeature ifeature_0)
        {
            IRgbColor        rgbColor = new RgbColor();
            IFeatureRenderer renderer = igeoFeatureLayer_0.Renderer;
            ISymbol          symbol   = renderer.get_SymbolByFeature(ifeature_0);

            if (symbol is IMarkerSymbol)
            {
                IMarkerSymbol markerSymbol = symbol as IMarkerSymbol;
                rgbColor.RGB = Convert.ToInt32(markerSymbol.Color.RGB);
            }
            else if (symbol is ILineSymbol)
            {
                ILineSymbol lineSymbol = symbol as ILineSymbol;
                rgbColor.RGB = Convert.ToInt32(lineSymbol.Color.RGB);
            }
            else if (symbol is IFillSymbol)
            {
                IFillSymbol fillSymbol = symbol as IFillSymbol;
                rgbColor.RGB = Convert.ToInt32(fillSymbol.Color.RGB);
            }
            else
            {
                rgbColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue);
            }
            return(rgbColor);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取面的符号
        /// </summary>
        /// <param name="pFeature">面要素</param>
        /// <returns>符号</returns>
        public static IFillSymbol GetFillSymbol(IFeature pFeature)
        {
            IFeatureLayer    pfLayer    = GeoDbUtils.GetFeatureLayer(pFeature);
            IGeoFeatureLayer pGeofLayer = pfLayer as IGeoFeatureLayer;
            IFeatureRenderer pFRenderer = pGeofLayer.Renderer;
            ISymbol          pSymbol    = pFRenderer.get_SymbolByFeature(pFeature);

            return(pSymbol as IFillSymbol);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取指定要素的符号
        /// </summary>
        /// <param name="pFeature"></param>
        /// <returns></returns>
        public static IMarkerSymbol GetMarkSymbol(IFeature pFeature)
        {
            IFeatureClass    pfClass    = pFeature.Class as IFeatureClass;
            IGeoFeatureLayer pGeofLayer = GeoDbUtils.GetFeatureLayer(pfClass.AliasName, true) as IGeoFeatureLayer;
            //IGeoFeatureLayer pGeofLayer = pLayer as IGeoFeatureLayer;
            IFeatureRenderer pFRenderer    = pGeofLayer.Renderer;
            ISymbol          pSymbol       = pFRenderer.get_SymbolByFeature(pFeature);
            IMarkerSymbol    pMarkerSymbol = pSymbol as IMarkerSymbol;

            return(pMarkerSymbol);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 根据要素获取符号
        /// </summary>
        /// <param name="pFeature">要素</param>
        /// <returns>符号</returns>
        public static ISymbol GetSymbol(IFeature pFeature)
        {
            IFeatureLayer pfLayer = GeoDbUtils.GetFeatureLayer(pFeature);

            if (pfLayer != null && pfLayer is IGeoFeatureLayer)
            {
                IGeoFeatureLayer pGeoFLayer = (IGeoFeatureLayer)pfLayer;
                IFeatureRenderer pfRenderer = pGeoFLayer.Renderer;
                return(pfRenderer.get_SymbolByFeature(pFeature));
            }
            return(null);
        }
Exemplo n.º 10
0
        public static ISymbol GetSymbolFromLayer(ILayer player)
        {
            if (player == null)
            {
                return(null);
            }

            IFeatureLayer  pfeaturelayer  = player as IFeatureLayer;
            IFeatureCursor pfeaturecursor = pfeaturelayer.Search(null, false);
            IFeature       pfeature       = pfeaturecursor.NextFeature();

            IGeoFeatureLayer pgeofeaturelayer = pfeaturelayer as IGeoFeatureLayer;
            IFeatureRenderer pfeaturerenger   = pgeofeaturelayer.Renderer;

            ISymbol psymbol = pfeaturerenger.get_SymbolByFeature(pfeature);

            return(psymbol);
        }
		private ISymbol GetFeatureSymbol(IFeature pFeat)
		{

			ISymbol pSym = null;

			// get base symbol
			pSym = m_pMainRend.get_SymbolByFeature(pFeat);

			// modify base symbol as necessary

			if ((m_pSizeRend != null) && (! (m_pMainRend == m_pSizeRend)) && (pSym != null))
				pSym = ApplySize(pSym, pFeat);

			
			if (((m_pColorRend1 != null) | (m_pColorRend2 != null)) && (pSym != null))
				pSym = ApplyColor(pSym, pFeat);

			if (((m_ShapeType == esriGeometryType.esriGeometryPoint) | ((m_ShapeType == esriGeometryType.esriGeometryPolygon) & pSym is IMarkerSymbol)) && (pSym != null))
			{
                if (m_sRotationField != null)
                {
                    if ((m_sRotationField != "") && (m_sRotationField != null))
                    {
                        pSym = ApplyRotation(pSym as IMarkerSymbol, pFeat as IFeature) as ISymbol;
                    }
                }
			}

			// support for point, line, and poly features
			
            if (m_sTransparencyField != null)
            {
                if (m_sTransparencyField != "")
                {
                    pSym = ApplyTransparency(pSym);
                }
            }
			

			return pSym;

		}
Exemplo n.º 12
0
        public void BatchFeaturesToGraphics()
        {
            //****** Author:  James Carpenter
            //******** Date:  3/12/2017
            //* Description:  This procedure converts multiple features to graphics when selected in the Table of Contents.
            //******          This procedure only converts those features within the screen display visible bounds for better performance.
            //******          Subsitiute "null" for "pSpatailFilter" to convert all features to graphics. Line 123.
            //******          The procedure will set the active view as Layout View.
            //******          If you want to stay in Data View, manually switch back, or remove Line 184.
            //******
            //****** Locals:  pMxDoc, pMap, pActiveView, pPageLayout, pMap, pFeature, pElement, pGraphicsContainer, pEnvelope, pSet,
            //******          pSpatialFilter, pContentsView, pContentsViewSelection, pLayer, layername, numberOfLayers, pGeoFeatureLayer,
            //******          pFeatureClass, pFeatureCursor, pFeatureRenderer, pMarkerElement, pLineElement, pFillShapeElement
            //******
            //*****************************************************************************************************************************

            IMxDocument pMxDoc;

            pMxDoc = (IMxDocument)ArcMap.Application.Document;
            IActiveView pActiveView;

            pActiveView = pMxDoc.ActiveView;
            IPageLayout pPageLayout;

            pPageLayout = pMxDoc.PageLayout;
            IMap pMap;

            pMap = pActiveView.FocusMap;

            // Delcare features and elements
            IFeature           pFeature;
            IElement           pElement = null;
            IGraphicsContainer pGraphicsContainer;

            // Set Envelope to Screen Display Visible Bounds
            IEnvelope pEnvelope = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds;

            // Spatial filter
            ISpatialFilter pSpatialFilter;

            pSpatialFilter = new SpatialFilter();

            pSpatialFilter.Geometry      = pEnvelope;                                   // Setting equal to envelope
            pSpatialFilter.GeometryField = "SHAPE";
            pSpatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects; // Intersect the screen view

            // Get the TOC
            IContentsView pContentsView = pMxDoc.CurrentContentsView;

            IContentsViewSelection pContentsViewSelection = (IContentsViewSelection)pContentsView;


            // Get the selected items in the Table of Contents, and put in set
            ESRI.ArcGIS.esriSystem.ISet pSet;
            pSet = pContentsViewSelection.SelectedItems;

            // Check if multiple layers are selected in the Table of Contents
            if (pSet == null || pSet.Count == 1)
            {
                MessageBox.Show("Select multiple layers in the Table of Contents");
            }

            else
            {
                // Check if in user is in Data View or Layout View
                if (pActiveView == pPageLayout)            // If user is in Layout View
                {
                    pMxDoc.ActiveView = (IActiveView)pMap; // Switch to Data View

                    BatchFeaturesToGraphics();             // Run the entire tool again
                }
                else
                {
                    // Get the selected layers from the set
                    ILayer pLayer;
                    pLayer = (ILayer)pSet.Next();

                    while (pLayer != null)
                    {
                        // Set the layerName variable and get the name of the selected layer
                        string layerName;
                        layerName = pLayer.Name;

                        // Get the number of layers in the map document
                        int numberOfLayers = pMap.LayerCount;

                        // Loop through all the layers in the map document, and get each layer index
                        for (int j = 0; j < numberOfLayers; j++)
                        {
                            // Check if the name of the selected layer and the layer in the map document match
                            if (layerName == pMap.get_Layer(j).Name)
                            {
                                int[] array = { j }; // Create an array to store the layer indexes

                                pGraphicsContainer = (IGraphicsContainer)pMap;
                                foreach (var i in array) // Loop through each item in the array
                                {
                                    IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)pMap.get_Layer(i);

                                    IFeatureClass pFeatureClass = pGeoFeatureLayer.FeatureClass;

                                    // Pass in spatial filter, use "null" to convert all features
                                    IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, true);

                                    IFeatureRenderer pFeatureRenderer = pGeoFeatureLayer.Renderer;

                                    pFeature = pFeatureCursor.NextFeature();

                                    pGeoFeatureLayer.Visible = false; // Turn layers off in Table of Contents

                                    while (pFeature != null)
                                    {
                                        // Point Features
                                        if (pFeature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
                                        {
                                            IMarkerElement pMarkerElement = new MarkerElementClass();

                                            // Declare symbol
                                            ISymbol pSymbol = pFeatureRenderer.get_SymbolByFeature(pFeature);

                                            pMarkerElement.Symbol = (IMarkerSymbol)pSymbol;


                                            pElement = (IElement)pMarkerElement; // Declare element
                                        }

                                        // Line Features
                                        if (pFeature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                                        {
                                            ILineElement pLineElement = new LineElementClass();

                                            pLineElement.Symbol = (ILineSymbol)pFeatureRenderer.get_SymbolByFeature(pFeature); // Declare symbol

                                            pElement = (IElement)pLineElement;                                                 // Declare element
                                        }

                                        // Polygon Features
                                        if (pFeature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                                        {
                                            IFillShapeElement pFillShapeElement = new PolygonElementClass();

                                            pFillShapeElement.Symbol = (IFillSymbol)pFeatureRenderer.get_SymbolByFeature(pFeature); // Declare symbol

                                            pElement = (IElement)pFillShapeElement;                                                 // Declare element
                                        }

                                        // Create graphic
                                        if (pElement != null)
                                        {
                                            pElement.Geometry = pFeature.Shape;         // Get the geometry and shape
                                            pGraphicsContainer.AddElement(pElement, 0); // Add the new graphic element to the map
                                        }

                                        pFeature = pFeatureCursor.NextFeature();
                                    }
                                }
                            }
                        }
                        pLayer = (ILayer)pSet.Next(); // Loop back to the next selected layer in the set
                    }


                    pMxDoc.ActiveView = (IActiveView)pPageLayout; // Switch back to Layout View. Remove this line to stay in Data View
                    pMxDoc.UpdateContents();
                    pMxDoc.ActiveView.Refresh();
                }
            }
        }
		private ISymbol ApplyColor(ISymbol pSym, IFeature pFeat)
		{
	try
	{
			ISymbol pSym1 = null;
			ISymbol pSym2 = null;
			IColor pColor = null;
			IHsvColor pHSVColor = null;

			if ((m_pColorRend1 != null) & (m_pColorRend2 != null)) // for now both color renderers need to be set to apply color
			{
				pSym1 = m_pColorRend1.get_SymbolByFeature(pFeat);
				pSym2 = m_pColorRend2.get_SymbolByFeature(pFeat);
				// only use GetCombinedColor for HSV component-type combination method
				if (m_eColorCombinationMethod == EColorCombinationType.enuComponents)
				{
					pColor = GetCombinedColor(GetSymbolColor(pSym1), GetSymbolColor(pSym2), m_eColorCombinationMethod);

					
					// Hue is good when I do this...
					pHSVColor = pColor as IHsvColor;
					//'MsgBox(Str(pHSVColor.Hue) & " " & Str(pHSVColor.Saturation) & " " & " " & Str(pHSVColor.Value()))

				}
				else
				{
					
					pColor = new RgbColor();
                    pColor.RGB = (int)m_OLEColorMatrix[GetSymbolIndex(pSym1 as ISymbol, m_pColorRend1 as IClassBreaksRenderer), GetSymbolIndex(pSym2 as ISymbol, m_pColorRend2 as IClassBreaksRenderer)];
					
					
				}


				if (pSym is IMarkerSymbol)
				{
					IMarkerSymbol pMarkerSym = null;
                    pMarkerSym = pSym as IMarkerSymbol;
					pMarkerSym.Color = pColor;
				}
				else if (pSym is ILineSymbol)
				{
					ILineSymbol pLineSym = null;
                    pLineSym = pSym as ILineSymbol;
					pLineSym.Color = pColor;
				}
				else if (pSym != null)
				{
					IFillSymbol pFillSym = null;
					pFillSym = pSym as IFillSymbol;
					pFillSym.Color = pColor;
					

				}


			}

			return pSym;
			return null;
}

catch
{
    return null;
}
		}