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); } } }
ESRI.ArcGIS.Carto.ILegendGroup ILegendInfo.get_LegendGroup(int intLegendIdx) { if (m_pLegendGroup.get_Class(0).Symbol != null) { return(m_pLegendGroup); } else { return(null); } }
//加载拓扑图层 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; } }
ISymbol IFeatureRenderer.get_SymbolByFeature(ESRI.ArcGIS.Geodatabase.IFeature Feature) { ISymbol pSymbol = m_pLegendGroup.get_Class(0).Symbol; return(pSymbol); }