Beispiel #1
0
 private static void RecursiveAddAndVisualizePipeData(TreeList parentTree, List <LogicGroup> list, Dictionary <string, IFeatureClass> dicfc, IMapControl2 mapControl, IMap pMap)
 {
     if (parentTree == null || list == null)
     {
         return;
     }
     foreach (LogicGroup lg in list)
     {
         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>(); //subclass所对应的<要素类ID,类>字典
             Dictionary <string, IFeatureLayer>    dicFLs = new Dictionary <string, IFeatureLayer>();    //subclass所对应的<要素类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);
             VisualMapLayer(pMap, mapControl, dict, dicFLs);
             SetSubClass(mc, tnmc, dict, dicFLs);
             //AddSubClass(mc, tnlg, fcs, dict, dicFLs);
         }
         tnlg.CollapseAll();
     }
 }
Beispiel #2
0
        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;
            }
        }