private void LoopHideLegend(ILayer layer) { ILegendGroup lgroup = null; if (layer is ICompositeLayer && (layer as ICompositeLayer).Count > 0) { ICompositeLayer cplayer = layer as ICompositeLayer; ILayer sublayer = null; for (int j = 0; j < cplayer.Count; j++) { sublayer = cplayer.get_Layer(j); LoopHideLegend(sublayer); } } else { ILegendInfo lInfo = layer as ILegendInfo; if (lInfo != null && lInfo.LegendGroupCount >= 0) { for (int g = 0; g < lInfo.LegendGroupCount; g++) { lgroup = lInfo.get_LegendGroup(g); lgroup.Visible = false; } } } }
ESRI.ArcGIS.Carto.ILegendGroup ILegendInfo.get_LegendGroup(int Index) { string strHeading = null; ILegendInfo pLegendInfo = null; switch (Index) { case 0: pLegendInfo = m_pMainRend as ILegendInfo; if (m_pMainRend == m_pShapePatternRend) strHeading = "Shape/Pattern: "; else if (m_pMainRend == m_pSizeRend) strHeading = "Size: "; else strHeading = "Color 1: "; break; case 1: if (m_pShapePatternRend != null) { if (m_pSizeRend != null) { pLegendInfo = m_pSizeRend as ILegendInfo; strHeading = "Size: "; } else { pLegendInfo = m_pColorRend1 as ILegendInfo; strHeading = "Color 1: "; } } else { if (m_pSizeRend != null) { pLegendInfo = m_pColorRend1 as ILegendInfo; strHeading = "Color 1: "; } else { pLegendInfo = m_pColorRend2 as ILegendInfo; strHeading = "Color 2: "; } } break; case 2: pLegendInfo = m_pColorRend1 as ILegendInfo; strHeading = "Color 1: "; break; case 3: pLegendInfo = m_pColorRend2 as ILegendInfo; strHeading = "Color 2: "; break; } ILegendGroup pLegendGroup = null; pLegendGroup = pLegendInfo.get_LegendGroup(0); //pLegendGroup.Heading = strHeading & pLegendGroup.Heading return pLegendGroup; }
private void InsertLegendInfoToTree(ILegendInfo pLegendInfo, TOCTreeNode pParantNode) { int legendGroupCount = pLegendInfo.LegendGroupCount; TOCTreeNode pNode = pParantNode; TOCTreeNode node2 = null; for (int i = 0; i < legendGroupCount; i++) { ILegendGroup group = pLegendInfo.get_LegendGroup(i); if (legendGroupCount > 1) { pNode = new TOCTreeNodeEx(group.Heading) { Tag = group }; pParantNode.Nodes.Add(pNode); } int classCount = group.ClassCount; for (int j = 0; j < classCount; j++) { ILegendClass class2 = group.get_Class(j); node2 = new TOCTreeNodeEx(class2.Label, false, true) { Tag = class2 }; pNode.Nodes.Add(node2); } } }
/// <summary> /// This recursive method will Populate the treeview. /// </summary> /// <param name="layer">The current layer</param> /// <param name="parentNode">The parent TreeNode</param> private void PopulateTree(ILayer layer, TreeNode parentNode) { TreeNode node = new TreeNode(layer.Name); ILegendInfo legendInfo = layer as ILegendInfo; if (legendInfo != null) { ILegendGroup legendGroup; for (int i = 0; i < legendInfo.LegendGroupCount; ++i) { ILegendClass legendClass; legendGroup = legendInfo.get_LegendGroup(i); for (int j = 0; j < legendGroup.ClassCount; ++j) { IAgEsri3dSymbolHelper symbolHelper = this.m_Renderer.Context.CreateObject("STKesriDisplay10.AgEsri3dSymbolHelper") as IAgEsri3dSymbolHelper;//new AgEsri3dSymbolHelperClass(); symbolHelper.SetUseSymbolSize(true); legendClass = legendGroup.get_Class(j); TreeNode legendClassNode = new TreeNode(legendClass.Label); ISymbol symbol; symbol = legendClass.Symbol; if (symbolHelper != null) { int bmp; bmp = symbolHelper.ToBitmap(symbol); IntPtr bmpPtr = new IntPtr(bmp); legendClassNode.ImageIndex = this.ImageList.Images.Count; legendClassNode.SelectedImageIndex = legendClassNode.ImageIndex; Bitmap bitmap = Bitmap.FromHbitmap(bmpPtr); bitmap.MakeTransparent(Color.FromArgb(85, 85, 85)); bitmap.SetResolution(30, 30); this.ImageList.Images.Add(StandardizeBitmap((bitmap))); } node.Nodes.Add(legendClassNode); } } } node.ImageIndex = NOIMAGE; parentNode.Nodes.Add(node); node.Checked = (layer.Visible && layer.Valid); node.Tag = layer; ICompositeLayer subLayer = layer as ICompositeLayer; if (subLayer != null) { for (int i = 0; i < subLayer.Count; ++i) { PopulateTree(subLayer.get_Layer(i), node); } } }
private void CollapseGroup(ILayer layer) { try { ILegendInfo info = (ILegendInfo)layer; ILegendGroup group = (ILegendGroup)info.get_LegendGroup(0); group.Visible = false; } catch (Exception) { } }
/// <summary> /// 展开/收缩图层的图例(最后需要执行toc的Update方法) /// </summary> /// <param name="layer"></param> /// <param name="isExpand"></param> public void ExpandLegend(ILayer layer, bool isExpand) { ILegendInfo legendInfo = (ILegendInfo)layer; int iLegendGroupCount = legendInfo.LegendGroupCount; for (int i = 0; i < iLegendGroupCount; i++) { var legendGroup = legendInfo.get_LegendGroup(i); legendGroup.Visible = isExpand; } axMapControlMainMap.Update(); }
private void ExpandLayer(IFeatureLayer pFeatureLayer) { ILegendInfo pLegendInfo = null; ILegendGroup pLegendGroup = new LegendGroupClass(); pLegendInfo = pFeatureLayer as ILegendInfo; if (pLegendInfo == null) { return; } pLegendGroup = pLegendInfo.get_LegendGroup(0); pLegendGroup.Visible = true; }
private void FoldLyrsItem_Click(object sender, EventArgs e) { //折叠所有图层 for (int i = 0; i < this.axMapcontrol.LayerCount; i++) { ILegendInfo m_LengendInfo = this.axMapcontrol.get_Layer(i) as ILegendInfo; for (int j = 0; j < m_LengendInfo.LegendGroupCount; j++) { ILegendGroup pLenGroup = m_LengendInfo.get_LegendGroup(j) as ILegendGroup; pLenGroup.Visible = false; } } this.axTOOControl.Update(); }
private void CollapseLayer(IFeatureLayer pFeatureLayer) { ILegendInfo pLegendInfo = null; ILegendGroup pLegendGroup = new LegendGroupClass(); if (pFeatureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { #region 如果图层是注记层 //IAnnotationLayer pAnnoLayer = pFeatureLayer as IAnnotationLayer; //IGeoFeatureLayer pGeoFeaLayer = pFeatureLayer as IGeoFeatureLayer; //IFeatureRenderer pRender = pGeoFeaLayer.Renderer; //ISymbol pSym = (pRender as IUniqueValueRenderer).DefaultSymbol; //ISimpleTextSymbol pTextSym = pSym as ISimpleTextSymbol; //ICompositeLayer pComLayer = pAnnoLayer as ICompositeLayer; //IGroupLayer pgLayer = new GroupLayerClass(); //pgLayer.Name = pFeatureLayer.Name; //for (int j = 0; j < pComLayer.Count; j++) //{ // ILayer ppLayer = pComLayer.get_Layer(j); // pgLayer.Add(ppLayer); //} //myHook.MapControl.Map.DeleteLayer(pFeatureLayer as ILayer); //myHook.MapControl.Map.AddLayer(pgLayer); //myHook.MapControl.ActiveView.Refresh(); //pgLayer.Expanded = false; //myHook.TOCControl.Update(); #endregion } else { //如果图层时普通的图层 pLegendInfo = pFeatureLayer as ILegendInfo; if (pLegendInfo == null) { return; } for (int i = 0; i < pLegendInfo.LegendGroupCount; i++) //changed by xisheng 2011.06.16 { //采用唯一值符号多个的一起折叠 pLegendGroup = pLegendInfo.get_LegendGroup(i); pLegendGroup.Visible = false; } } }
private void CollapseLayer(IFeatureLayer pFeatureLayer) { ILegendInfo pLegendInfo = null; ILegendGroup pLegendGroup = new LegendGroupClass(); if (pFeatureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { #region Èç¹ûͼ²ãÊÇ×¢¼Ç²ã //IAnnotationLayer pAnnoLayer = pFeatureLayer as IAnnotationLayer; //IGeoFeatureLayer pGeoFeaLayer = pFeatureLayer as IGeoFeatureLayer; //IFeatureRenderer pRender = pGeoFeaLayer.Renderer; //ISymbol pSym = (pRender as IUniqueValueRenderer).DefaultSymbol; //ISimpleTextSymbol pTextSym = pSym as ISimpleTextSymbol; //ICompositeLayer pComLayer = pAnnoLayer as ICompositeLayer; //IGroupLayer pgLayer = new GroupLayerClass(); //pgLayer.Name = pFeatureLayer.Name; //for (int j = 0; j < pComLayer.Count; j++) //{ // ILayer ppLayer = pComLayer.get_Layer(j); // pgLayer.Add(ppLayer); //} //myHook.MapControl.Map.DeleteLayer(pFeatureLayer as ILayer); //myHook.MapControl.Map.AddLayer(pgLayer); //myHook.MapControl.ActiveView.Refresh(); //pgLayer.Expanded = false; //myHook.TOCControl.Update(); #endregion } else { //Èç¹ûͼ²ãʱÆÕͨµÄͼ²ã pLegendInfo = pFeatureLayer as ILegendInfo; if (pLegendInfo == null) { return; } pLegendGroup = pLegendInfo.get_LegendGroup(0); pLegendGroup.Visible = false; } }
private void simpleButtonExpand_Click(object sender, EventArgs e)//TOCC图层文件展开 { UID uid = new UIDClass(); uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer layers = axMapControlMainMap.Map.get_Layers(uid, true); layers.Reset(); ILayer layer = null; while ((layer = layers.Next()) != null) { ILegendInfo pLegendInfo = layer as ILegendInfo; int iLegendGroupCount = pLegendInfo.LegendGroupCount; for (int i = 0; i < iLegendGroupCount; i++) { var lGroup = pLegendInfo.get_LegendGroup(i); lGroup.Visible = true; } } axTOCControlLayerTree.Update(); }
public static void UpdateMapUnitPolysRenderer(IWorkspace theWorkspace) { // Get the MapUnitPolys Layer from the ToC IFeatureLayer theLayer = commonFunctions.FindFeatureLayer(theWorkspace, "MapUnitPolys"); // If the layer was not found, don't try and update the renderer! if (theLayer == null) { return; } // Setup the renderer IUniqueValueRenderer theRenderer = new UniqueValueRendererClass(); theRenderer.FieldCount = 1; theRenderer.Field[0] = "MapUnit"; // Setup a couple variables IColor nullColor = new RgbColorClass(); nullColor.NullColor = true; // Setup a blank line ILineSymbol nullLine = new SimpleLineSymbolClass(); nullLine.Color = nullColor; // Setup the "All Other Values" symbol ISimpleFillSymbol defaultSymbol = new SimpleFillSymbolClass(); IColor defaultColor = new RgbColorClass(); defaultColor.RGB = 255; defaultSymbol.Color = defaultColor; defaultSymbol.Outline = nullLine; // Apply the "All other values" symbol to the renderer theRenderer.DefaultSymbol = defaultSymbol as ISymbol; theRenderer.UseDefaultSymbol = true; string theHeading = "Geologic Map Units"; // Get the Legend Items var sortedDmu = GetDmuSortedByHierarchy(theWorkspace); // Loop through the legend items foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> legendEntry in sortedDmu) { DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDmuEntry = legendEntry.Value; // If this is a heading, make it so if (thisDmuEntry.ParagraphStyle.Contains("Heading") == true) { theHeading = thisDmuEntry.Name; continue; } // Make a Simple Fill RuleID ISimpleFillSymbol theSymbol = new SimpleFillSymbolClass(); //theRuleID.Style = esriSimpleFillStyle.esriSFSSolid; // Get the right color IColor symbolColor = new RgbColorClass(); string rgbString = thisDmuEntry.AreaFillRGB; string[] rgbValues = rgbString.Split(';'); // Long integer representations of RGB values are dumb: G*65536 + B*256 + R if (rgbValues.Length < 3) { symbolColor.RGB = 16777215; } else { symbolColor.RGB = int.Parse(rgbValues[0]) + int.Parse(rgbValues[1]) * 256 + int.Parse(rgbValues[2]) * 65536; } theSymbol.Color = symbolColor; theSymbol.Outline = nullLine; // Add it to the renderer theRenderer.AddValue(thisDmuEntry.MapUnit, theHeading, theSymbol as ISymbol); // Give it the right label theRenderer.Label[thisDmuEntry.MapUnit] = thisDmuEntry.MapUnit + " - " + thisDmuEntry.Name; } // Apply the renderer IGeoFeatureLayer geoFLayer = (IGeoFeatureLayer)theLayer; geoFLayer.Renderer = (IFeatureRenderer)theRenderer; // Minimizing the legend info in the Table of Contents is not trivial ILegendInfo layerLegendInfo = (ILegendInfo)theLayer; for (int i = 0; i < layerLegendInfo.LegendGroupCount; i++) { ILegendGroup layerLegendGroup = layerLegendInfo.get_LegendGroup(i); layerLegendGroup.Visible = false; } // Update the views ArcMap.Document.UpdateContents(); ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, theLayer, null); }
private void AddLayersToMap(IWorkspace ValidNcgmpDatabase, bool useRepresentation) // bool hasTopologyStuff, bool hasStationFunction, { // Get references to the map for adding layers and tables IMxDocument MxDoc = (IMxDocument)ArcMap.Document; IMap thisMap = MxDoc.FocusMap; IStandaloneTableCollection thisMapTables = (IStandaloneTableCollection)thisMap; // Create a group layer IGroupLayer GeoMapGroupLayer = new GroupLayerClass(); GeoMapGroupLayer.Name = "Geologic Map"; // Create a group layer IGroupLayer StationGroupLayer = new GroupLayerClass(); StationGroupLayer.Name = "Observation Data"; //if (hasTopologyStuff == true) { #region "GeologicMapTopology" ITopology geoMapTopo = commonFunctions.OpenTopology(ValidNcgmpDatabase, "GeologicMapTopology"); ITopologyLayer geoMapTopoTL = new TopologyLayerClass(); geoMapTopoTL.Topology = geoMapTopo; ILayer geoMapTopoL = (ILayer)geoMapTopoTL; geoMapTopoL.Name = "Geologic Map Topology"; geoMapTopoL.Visible = false; // Minimizing the legend info in the Table of Contents is not trivial ILegendInfo geoMapTopoLegendInfo = (ILegendInfo)geoMapTopoL; ILegendGroup geoMapTopoLegendGroup = geoMapTopoLegendInfo.get_LegendGroup(0); geoMapTopoLegendGroup.Visible = false; geoMapTopoLegendGroup = geoMapTopoLegendInfo.get_LegendGroup(1); geoMapTopoLegendGroup.Visible = false; geoMapTopoLegendGroup = geoMapTopoLegendInfo.get_LegendGroup(2); geoMapTopoLegendGroup.Visible = false; GeoMapGroupLayer.Add(geoMapTopoL); #endregion } { #region "OrientationPoints" IFeatureClass orientationPointsFC = commonFunctions.OpenFeatureClass(ValidNcgmpDatabase, "OrientationPoints"); IFeatureLayer orientationPointsFL = new FeatureLayerClass(); orientationPointsFL.FeatureClass = orientationPointsFC; orientationPointsFL.Name = "Orientation Points"; orientationPointsFL.DisplayField = "Type"; if (useRepresentation == true) { // Set the layer renderer to use representations IGeoFeatureLayer orientationPointsGeoFL = (IGeoFeatureLayer)orientationPointsFL; IRepresentationRenderer orientationPointsRepRend = new RepresentationRendererClass(); orientationPointsRepRend.RepresentationClass = commonFunctions.GetRepClass(ValidNcgmpDatabase, "OrientationPoints_Rep"); orientationPointsGeoFL.Renderer = (IFeatureRenderer)orientationPointsRepRend; commonFunctions.BuildGenericTemplates(ValidNcgmpDatabase, orientationPointsFL as ILayer, "OrientationPoints"); } ILegendInfo orientationPointsLegendInfo = (ILegendInfo)orientationPointsFL; ILegendGroup orientationPointsLegendGroup = orientationPointsLegendInfo.get_LegendGroup(0); orientationPointsLegendGroup.Visible = false; StationGroupLayer.Add(orientationPointsFL); #endregion #region "ObservationData" string[] arr = new string[4]; // Initialize arr[0] = "Stations"; // Element 1 arr[1] = "GenericPoints"; // Element 2 arr[2] = "GenericSamples"; // Element 3 arr[3] = "GeochronPoints"; // Element 4 foreach (string s in arr) { try { IFeatureClass FC = commonFunctions.OpenFeatureClass(ValidNcgmpDatabase, s); IFeatureLayer FL = new FeatureLayerClass(); FL.FeatureClass = FC; FL.Name = s; FL.Visible = false; ILegendInfo LegendInfo = (ILegendInfo)FL; ILegendGroup LegendGroup = LegendInfo.get_LegendGroup(0); LegendGroup.Visible = false; StationGroupLayer.Add(FL); } catch (Exception ex) { // Write exception to C:\Users\<user name>\AppData\Local\Temp\NCGMPToolbarLog.txt string path = Path.Combine(Environment.GetEnvironmentVariables()["LOCALAPPDATA"] as string, "Temp/NCGMPToolbarLog.txt"); string message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + s + ": " + ex.Message + "\r\n"; System.IO.File.AppendAllText(path, message); } } #endregion } //add station group layer to map document GeoMapGroupLayer.Add(StationGroupLayer); { #region "LinesWithoutRepresentations" string[] arr = new string[2]; // Initialize arr[0] = "CartographicLines"; // Element 1 arr[1] = "IsoValueLines"; // Element 2 foreach (string s in arr) { try { IFeatureClass FC = commonFunctions.OpenFeatureClass(ValidNcgmpDatabase, s); IFeatureLayer FL = new FeatureLayerClass(); FL.FeatureClass = FC; FL.Name = s; FL.Visible = false; ILegendInfo LegendInfo = (ILegendInfo)FL; ILegendGroup LegendGroup = LegendInfo.get_LegendGroup(0); LegendGroup.Visible = false; GeoMapGroupLayer.Add(FL); } catch (Exception ex) { // Write exception to C:\Users\<user name>\AppData\Local\Temp\NCGMPToolbarLog.txt string path = Path.Combine(Environment.GetEnvironmentVariables()["LOCALAPPDATA"] as string, "Temp/NCGMPToolbarLog.txt"); string message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + s + ": " + ex.Message + "\r\n"; System.IO.File.AppendAllText(path, message); } } #endregion } { #region "LinesWithRepresentations" string[] arr = new string[2]; // Initialize arr[0] = "GeologicLines"; // Element 1 arr[1] = "ContactsAndFaults"; // Element 2 foreach (string s in arr) { try { IFeatureClass FC = commonFunctions.OpenFeatureClass(ValidNcgmpDatabase, s); IFeatureLayer FL = new FeatureLayerClass(); FL.FeatureClass = FC; FL.Name = s; if (useRepresentation == true) { // Set the layer renderer to use representations IGeoFeatureLayer GeoFL = (IGeoFeatureLayer)FL; IRepresentationRenderer RepRend = new RepresentationRendererClass(); RepRend.RepresentationClass = commonFunctions.GetRepClass(ValidNcgmpDatabase, s + "_Rep"); GeoFL.Renderer = (IFeatureRenderer)RepRend; commonFunctions.BuildGenericTemplates(ValidNcgmpDatabase, FL as ILayer, s); } ILegendInfo LegendInfo = (ILegendInfo)FL; ILegendGroup LegendGroup = LegendInfo.get_LegendGroup(0); LegendGroup.Visible = false; GeoMapGroupLayer.Add(FL); } catch (Exception ex) { // Write exception to C:\Users\<user name>\AppData\Local\Temp\NCGMPToolbarLog.txt string path = Path.Combine(Environment.GetEnvironmentVariables()["LOCALAPPDATA"] as string, "Temp/NCGMPToolbarLog.txt"); string message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + s + ": " + ex.Message + "\r\n"; System.IO.File.AppendAllText(path, message); } } #endregion } { #region "Polygons" string[] arr = new string[3]; // Initialize arr[0] = "DataSourcePolys"; // Element 1 arr[1] = "MapUnitPolys"; // Element 2 arr[2] = "OtherPolys"; // Element 3 foreach (string s in arr) { try { IFeatureClass FC = commonFunctions.OpenFeatureClass(ValidNcgmpDatabase, s); IFeatureLayer FL = new FeatureLayerClass(); FL.FeatureClass = FC; FL.Name = s; ILegendInfo LegendInfo = (ILegendInfo)FL; ILegendGroup LegendGroup = LegendInfo.get_LegendGroup(0); LegendGroup.Visible = false; GeoMapGroupLayer.Add(FL); } catch (Exception ex) { // Write exception to C:\Users\<user name>\AppData\Local\Temp\NCGMPToolbarLog.txt string path = Path.Combine(Environment.GetEnvironmentVariables()["LOCALAPPDATA"] as string, "Temp/NCGMPToolbarLog.txt"); string message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + s + ": " + ex.Message + "\r\n"; System.IO.File.AppendAllText(path, message); } } #endregion } { #region "Tables" string[] arr = new string[7]; // Initialize arr[0] = "DataSources"; // Element 1 arr[1] = "DescriptionOfMapUnits"; // Element 2 arr[2] = "ExtendedAttributes"; // Element 3 arr[3] = "GeologicEvents"; // Element 4 arr[4] = "Glossary"; // Element 5 arr[5] = "Notes"; // Element 6 arr[6] = "StandardLithology"; // Element 7 foreach (string s in arr) { try { ITable Table = commonFunctions.OpenTable(ValidNcgmpDatabase, s); IStandaloneTable Standalone = new StandaloneTableClass(); Standalone.Table = Table; Standalone.Name = s; thisMapTables.AddStandaloneTable(Standalone); } catch (Exception ex) { // Write exception to C:\Users\<user name>\AppData\Local\Temp\NCGMPToolbarLog.txt string path = Path.Combine(Environment.GetEnvironmentVariables()["LOCALAPPDATA"] as string, "Temp/NCGMPToolbarLog.txt"); string message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + s + ": " + ex.Message + "\r\n"; System.IO.File.AppendAllText(path, message); } } #endregion } // Add the Geologic Map Group Layer to the map GeoMapGroupLayer.Expanded = true; thisMap.AddLayer(GeoMapGroupLayer); // Adjust the MapUnitPolys Renderer commonFunctions.UpdateMapUnitPolysRenderer(ValidNcgmpDatabase); // Adjust the MapUnitPolys Feature Templates commonFunctions.UpdateMapUnitPolysFeatureTemplates(ValidNcgmpDatabase); }
//加载拓扑图层 public static void AddTopoLayer(ref AxMapControl pMapCtrl, string strTopoLayerName, ITopologyWorkspace ipTopologyWS, IFeatureClassContainer ipFeatClassContainer, IFeatureDataset ipFeatDataset) { int nOriginClassID, nDestClassID; ITopology ipTopology; //打开数据集 //ITopologyContainer ipTopoContainer = (ITopologyContainer)ipFeatDataset; IWorkspace2 pWorkspace = (IWorkspace2)ipFeatDataset.Workspace; if (pWorkspace.get_NameExists(esriDatasetType.esriDTTopology, strTopoLayerName)) { ipTopology = ipTopologyWS.OpenTopology(strTopoLayerName); if (ipTopology == null) { return; } ITopologyLayer ipTopologyLayer = new TopologyLayerClass(); ipTopologyLayer.Topology = ipTopology; ILegendInfo legendInfo = (ILegendInfo)ipTopologyLayer; for (int i = 0; i < legendInfo.LegendGroupCount; i++) { ILegendGroup legendgroup = legendInfo.get_LegendGroup(i); ILegendClass legendclass = legendgroup.get_Class(0); switch (legendgroup.Heading) { case "Area Errors": { legendgroup.Heading = ""; legendclass.Label = "面状错误"; legendclass.Description = "面状错误"; break; } case "Line Errors": { legendgroup.Heading = ""; legendclass.Label = "线状错误"; legendclass.Description = "线状错误"; break; } case "Point Errors": { legendgroup.Heading = ""; legendclass.Label = "点状错误"; legendclass.Description = "点状错误"; break; } } } ILayer ipLayer = (ILayer)ipTopologyLayer; ipLayer.Name = strTopoLayerName; //将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,采用此方法命名 hehy20080724 /* 将拓扑检查合并后,将拓扑图层名指定为“拓扑错误”后,注销以下代码 hehy20080724 * /////////////////////////////////////////////////// * //得到拓扑层相对应的规则名称 * CModelSchema pModelSchema = new CModelSchema(); * string strRuleName = pModelSchema.GetRuleNameByTopoLayerName(m_pTask.pSchema, strTopoLayerName); * ////////////////////////////////////////////////// * if (strRuleName.Length == 0) * { * ipLayer.Name = strTopoLayerName; * } * else * { * ipLayer.Name = strRuleName; * } */ //把拓扑图层加载到map控件中 //pMapCtrl.AddLayer(ipLayer, pMapCtrl.LayerCount); pMapCtrl.Map.AddLayer(ipLayer); //pMapCtrl.ActiveView.Extent = ipLayer.AreaOfInterest; } }