public void Add(DF2DMajorClass mc) { if (this.Exists(mc.GetMajorClass().Name)) { return; } this.listMC.Add(mc); }
public static void AddAndVisualizeTreelistPipe(TreeList parentTree, IMapControl2 mapControl) { try { if (parentTree == null) { return; } IMapDocument pMapDoc = new MapDocument(); string pFileName = Config.GetConfigValue("2DMxdPipe"); if (string.IsNullOrEmpty(pFileName) || !File.Exists(pFileName)) { return; } SplashScreenManager.Default.SendCommand(null, "正在加载二维管线数据......"); pMapDoc.Open(pFileName, null); IMap pMap = pMapDoc.get_Map(0); Dictionary <string, IFeatureClass> dicfc = new Dictionary <string, IFeatureClass>(); //初始化要<素类ID,要素类>字典 for (int i = 0; i < pMap.LayerCount; i++) //对地图图层进行遍历 { ILayer layer = pMap.get_Layer(i); ReadMapLayer(layer, dicfc);//读取该图层,并更新字典 } if (dicfc == null || dicfc.Count == 0) { return; } foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) { TreeNodeLogicGroup2D tnlg = new TreeNodeLogicGroup2D()//创建逻辑分组根节点 { Name = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias }; tnlg.OwnNode = parentTree.AppendNode(new object[] { tnlg.Name }, (TreeListNode)null); tnlg.Visible = true; RecursiveAddAndVisualizePipeData(tnlg.OwnNode.TreeList, lg.LogicGroups, dicfc, mapControl, pMap); foreach (MajorClass mc in lg.MajorClasses) //遍历当前逻辑分组的二级大类 { Dictionary <string, DF2DFeatureClass> dict = new Dictionary <string, DF2DFeatureClass>(); //MajorClass所对应的<要素类ID,类>字典 Dictionary <string, IFeatureLayer> dicFLs = new Dictionary <string, IFeatureLayer>(); //MajorClass所对应的<要素类ID,图层>字典 TreeNodeMajorClass2D tnmc = new TreeNodeMajorClass2D() { Name = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias }; tnmc.Visible = true; tnmc.CustomValue = mc; tnlg.Add(tnmc); SetFeatureClassForGroup(mc, tnmc, dicfc, dict); //设置MajorClass所对应的要素类 VisualMapLayer(pMap, mapControl, dict, dicFLs); //为地图控件加载相关的图层 SetSubClass(mc, tnmc, dict, dicFLs); //设置subclass包含的相关参数的值 //AddSubClass(mc, tnmc, dicfc,dict,dicFLs); DF2DMajorClass dfmc = new DF2DMajorClass(mc, tnmc);//应用于管线显示控制 DF2DMajorClassManager.Instance.Add(dfmc); } tnlg.CollapseAll(); } } catch (System.Exception ex) { return; } }