Пример #1
0
 private static void RecursiveAddAndVisualizePipeData(TreeList parentTree, List <LogicGroup> list, Dictionary <string, IFeatureClass> fcs, string geoColumnName)
 {
     if (parentTree == null || list == null)
     {
         return;
     }
     foreach (LogicGroup lg in list)
     {
         TreeNodeLogicGroup tnlg = new TreeNodeLogicGroup()
         {
             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, fcs, geoColumnName);
         foreach (MajorClass mc in lg.MajorClasses)
         {
             TreeNodeMajorClass tnmc = new TreeNodeMajorClass()
             {
                 Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                 CustomValue = mc
             };
             tnlg.Add(tnmc);
             AddSubClass(mc, tnlg, fcs, geoColumnName);
         }
         tnlg.CollapseAll();
     }
 }
Пример #2
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (currentLayer != null)
     {
         string name          = this.teName.Text.Trim();
         string alias         = this.teAlias.Text.Trim();
         string classifyfield = this.teClassifyField.Text.Trim();
         if (string.IsNullOrEmpty(name))
         {
             XtraMessageBox.Show("名称不能为空!", "提示");
             return;
         }
         if (currentLayer is TreeNodeLogicGroup && currentLayer.CustomValue is LogicGroup)
         {
             LogicGroup lg = currentLayer.CustomValue as LogicGroup;
             if (lg.Name != name)
             {
                 if (dictGroups.ContainsKey(name))
                 {
                     XtraMessageBox.Show("已存在该组!", "提示");
                     return;
                 }
                 dictGroups.Remove(lg.Name);
             }
             lg.Name  = name;
             lg.Alias = alias;
             TreeNodeLogicGroup treenode = currentLayer as TreeNodeLogicGroup;
             treenode.Name        = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias;
             treenode.CustomValue = lg;
             dictGroups[name]     = lg;
         }
         else if (currentLayer is TreeNodeMajorClass && currentLayer.CustomValue is MajorClass)
         {
             if (string.IsNullOrEmpty(classifyfield))
             {
                 XtraMessageBox.Show("分组字段不能为空!", "提示");
                 return;
             }
             MajorClass mc = currentLayer.CustomValue as MajorClass;
             if (mc.Name != name)
             {
                 if (dictMCs.ContainsKey(name))
                 {
                     XtraMessageBox.Show("已存在该大类!", "提示");
                     return;
                 }
                 dictMCs.Remove(mc.Name);
             }
             mc.Name          = name;
             mc.Alias         = alias;
             mc.ClassifyField = classifyfield;
             TreeNodeMajorClass treenode = currentLayer as TreeNodeMajorClass;
             treenode.Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias;
             treenode.CustomValue = mc;
             dictMCs[name]        = mc;
         }
     }
 }
Пример #3
0
        public static void AddAndVisualizePipeData(IConnectionInfo ci, string geoColumnName, TreeList parentTree, bool bNeedFly = false, bool bTempData = true)
        {
            try
            {
                if (ci == null || parentTree == null)
                {
                    return;
                }

                Dictionary <string, IFeatureClass> fcs = DataUtils.GetFeatureClass(ci);
                if (fcs == null || fcs.Count == 0)
                {
                    return;
                }

                foreach (MajorClass mc in LogicDataStructureManage3D.Instance.RootMajorClasses)
                {
                    TreeNodeMajorClass tnmc = new TreeNodeMajorClass()
                    {
                        Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                        CustomValue = mc
                    };
                    tnmc.OwnNode = parentTree.AppendNode(new object[] { tnmc.Name }, (TreeListNode)null);
                    AddSubClass(mc, tnmc, fcs, geoColumnName);
                }

                foreach (LogicGroup lg in LogicDataStructureManage3D.Instance.RootLogicGroups)
                {
                    TreeNodeLogicGroup tnlg = new TreeNodeLogicGroup()
                    {
                        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, fcs, geoColumnName);
                    foreach (MajorClass mc in lg.MajorClasses)
                    {
                        TreeNodeMajorClass tnmc = new TreeNodeMajorClass()
                        {
                            Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                            CustomValue = mc
                        };
                        tnlg.Add(tnmc);
                        AddSubClass(mc, tnmc, fcs, geoColumnName);
                    }
                    tnlg.CollapseAll();
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #4
0
 private void RecurSaveData(TreeNodeLogicGroup parentLayer, XmlDocument document, XmlNode parentNode)
 {
     if (parentLayer == null || parentNode == null)
     {
         return;
     }
     for (int i = 0; i < parentLayer.GetLayerCount(); i++)
     {
         IBaseLayer layer = parentLayer.GetLayerByIndex(i);
         if (!(layer is TreeNodeLogicGroup) && !(layer is TreeNodeMajorClass))
         {
             continue;
         }
         if (layer is TreeNodeLogicGroup)
         {
             TreeNodeLogicGroup treenode = layer as TreeNodeLogicGroup;
             if (!(treenode.CustomValue is LogicGroup))
             {
                 continue;
             }
             LogicGroup lg      = treenode.CustomValue as LogicGroup;
             XmlElement element = document.CreateElement("LogicGroup");
             element.SetAttribute("name", lg.Name);
             element.SetAttribute("alias", lg.Alias);
             XmlNode lgNode = parentNode.AppendChild(element);
             RecurSaveData(treenode, document, lgNode);
         }
         if (layer is TreeNodeMajorClass)
         {
             TreeNodeMajorClass treenode = layer as TreeNodeMajorClass;
             if (treenode.CustomValue is MajorClass)
             {
                 MajorClass mc      = treenode.CustomValue as MajorClass;
                 XmlElement element = document.CreateElement("MajorClass");
                 element.SetAttribute("name", mc.Name);
                 element.SetAttribute("alias", mc.Alias);
                 element.SetAttribute("classifyfield", mc.ClassifyField);
                 element.SetAttribute("fc2D", mc.Fc2D);
                 element.SetAttribute("fc3D", mc.Fc3D);
                 XmlNode mcNode = parentNode.AppendChild(element);
                 foreach (SubClass sc in mc.SubClasses)
                 {
                     XmlElement ele1 = document.CreateElement("SubClass");
                     ele1.SetAttribute("name", sc.Name);
                     ele1.SetAttribute("groupid", sc.GroupId.ToString());
                     mcNode.AppendChild(ele1);
                 }
             }
         }
     }
 }
Пример #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string name          = this.teName.Text.Trim();
            string alias         = this.teAlias.Text.Trim();
            string classifyfield = this.teClassifyField.Text.Trim();

            if (string.IsNullOrEmpty(name))
            {
                XtraMessageBox.Show("名称不能为空!", "提示");
                return;
            }
            if (type == 1)
            {
                if (dictGroups.ContainsKey(name))
                {
                    XtraMessageBox.Show("已存在该组!", "提示");
                    return;
                }
                LogicGroup lg = null;
                if (currentLayer != null && currentLayer is TreeNodeLogicGroup)
                {
                    lg = new LogicGroup(name, alias, currentLayer.CustomValue as LogicGroup);
                }
                else
                {
                    lg = new LogicGroup(name, alias, null);
                }
                TreeNodeLogicGroup treenode = new TreeNodeLogicGroup()
                {
                    Name        = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias,
                    CustomValue = lg
                };
                if (currentLayer != null && currentLayer is TreeNodeLogicGroup)
                {
                    (currentLayer as GroupLayerClass).Add2(treenode);
                }
                else
                {
                    treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null);
                }
                dictGroups[name] = lg;
            }
            if (type == 2)
            {
                if (dictMCs.ContainsKey(name))
                {
                    XtraMessageBox.Show("已存在该大类!", "提示");
                    return;
                }
                if (string.IsNullOrEmpty(classifyfield))
                {
                    XtraMessageBox.Show("分组字段不能为空!", "提示");
                    return;
                }

                MajorClass mc = null;
                if (currentLayer != null && currentLayer is TreeNodeLogicGroup)
                {
                    mc = new MajorClass(name, alias, classifyfield, "", "", currentLayer.CustomValue as LogicGroup);
                }
                else
                {
                    mc = new MajorClass(name, alias, classifyfield, "", "", null);
                }
                TreeNodeMajorClass treenode = new TreeNodeMajorClass()
                {
                    Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                    CustomValue = mc
                };
                if (currentLayer != null && currentLayer is TreeNodeLogicGroup)
                {
                    (currentLayer as GroupLayerClass).Add2(treenode);
                }
                else
                {
                    treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null);
                }
                dictMCs[name] = mc;
            }
        }
Пример #6
0
 private bool SaveData(string fileName)
 {
     try
     {
         XmlDocument    document = new XmlDocument();
         XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null);
         document.AppendChild(newChild);
         XmlNode node = document.CreateElement("LogicDataStructure");
         document.AppendChild(node);
         List <IBaseLayer> logicBaseTree1GetRootLayers = this.logicBaseTree1.GetRootLayers();
         if (logicBaseTree1GetRootLayers != null)
         {
             foreach (IBaseLayer layer in logicBaseTree1GetRootLayers)
             {
                 if (!(layer is TreeNodeLogicGroup) && !(layer is TreeNodeMajorClass))
                 {
                     continue;
                 }
                 if (layer is TreeNodeLogicGroup)
                 {
                     TreeNodeLogicGroup treenode = layer as TreeNodeLogicGroup;
                     if (!(treenode.CustomValue is LogicGroup))
                     {
                         continue;
                     }
                     LogicGroup lg      = treenode.CustomValue as LogicGroup;
                     XmlElement element = document.CreateElement("LogicGroup");
                     element.SetAttribute("name", lg.Name);
                     element.SetAttribute("alias", lg.Alias);
                     XmlNode lgNode = node.AppendChild(element);
                     RecurSaveData(treenode, document, lgNode);
                 }
                 if (layer is TreeNodeMajorClass)
                 {
                     TreeNodeMajorClass treenode = layer as TreeNodeMajorClass;
                     if (treenode.CustomValue is MajorClass)
                     {
                         MajorClass mc      = treenode.CustomValue as MajorClass;
                         XmlElement element = document.CreateElement("MajorClass");
                         element.SetAttribute("name", mc.Name);
                         element.SetAttribute("alias", mc.Alias);
                         element.SetAttribute("classifyfield", mc.ClassifyField);
                         element.SetAttribute("fc2D", mc.Fc2D);
                         element.SetAttribute("fc3D", mc.Fc3D);
                         XmlNode mcNode = node.AppendChild(element);
                         foreach (SubClass sc in mc.SubClasses)
                         {
                             XmlElement ele1 = document.CreateElement("SubClass");
                             ele1.SetAttribute("name", sc.Name);
                             ele1.SetAttribute("groupid", sc.GroupId.ToString());
                             mcNode.AppendChild(ele1);
                         }
                     }
                 }
             }
         }
         document.Save(fileName);
         return(true);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("保存数据失败!", "提示");
         return(false);
     }
 }
Пример #7
0
 public void LoadData(string fileName)
 {
     if (string.IsNullOrEmpty(fileName))
     {
         return;
     }
     try
     {
         if (!File.Exists(fileName))
         {
             string path = System.IO.Path.GetDirectoryName(fileName) + "\\";
             if (!Directory.Exists(path))
             {
                 DirectoryInfo di = Directory.CreateDirectory(path);
                 if (di == null)
                 {
                     return;
                 }
             }
             XmlDocument    document = new XmlDocument();
             XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null);
             document.AppendChild(newChild);
             XmlNode node = document.CreateElement("LogicDataStructure");
             document.AppendChild(node);
             document.Save(fileName);
         }
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(fileName);
         if (xmlDoc == null)
         {
             return;
         }
         XmlNode root = xmlDoc.SelectSingleNode("LogicDataStructure");
         if (root == null)
         {
             return;
         }
         foreach (XmlNode node in root.ChildNodes)
         {
             if (node.Name == "LogicGroup")
             {
                 string fieldName = "", fieldAliasName = "";
                 if (node.Attributes["name"] != null)
                 {
                     fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName))
                     {
                         continue;
                     }
                 }
                 if (node.Attributes["alias"] != null)
                 {
                     fieldAliasName = node.Attributes["alias"].Value.Trim();
                 }
                 LogicGroup lg = new LogicGroup(fieldName, fieldAliasName, null);
                 if (dictGroups.ContainsKey(lg.Name))
                 {
                     continue;
                 }
                 dictGroups[lg.Name] = lg;
                 TreeNodeLogicGroup treenode = new TreeNodeLogicGroup()
                 {
                     Name        = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias,
                     CustomValue = lg
                 };
                 treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null);
                 RecursiveLoadData(node.ChildNodes, lg, treenode);
             }
             if (node.Name == "MajorClass")
             {
                 string fieldName = "", fieldAliasName = "", classifyFieldName = "", fc2D = "", fc3D = "";
                 if (node.Attributes["name"] != null)
                 {
                     fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName))
                     {
                         continue;
                     }
                 }
                 if (node.Attributes["alias"] != null)
                 {
                     fieldAliasName = node.Attributes["alias"].Value.Trim();
                 }
                 if (node.Attributes["classifyfield"] != null)
                 {
                     classifyFieldName = node.Attributes["classifyfield"].Value.Trim();
                 }
                 if (node.Attributes["fc2D"] != null)
                 {
                     fc2D = node.Attributes["fc2D"].Value.Trim();
                 }
                 if (node.Attributes["fc3D"] != null)
                 {
                     fc3D = node.Attributes["fc3D"].Value.Trim();
                 }
                 MajorClass mc = new MajorClass(fieldName, fieldAliasName, classifyFieldName, fc2D, fc3D, null);
                 if (dictMCs.ContainsKey(mc.Name))
                 {
                     continue;
                 }
                 dictMCs[mc.Name] = mc;
                 foreach (XmlNode cnode in node.ChildNodes)
                 {
                     if (cnode.Name != "SubClass")
                     {
                         continue;
                     }
                     string scname = "", scgroupid = "";
                     if (cnode.Attributes["name"] != null)
                     {
                         scname = cnode.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(scname))
                         {
                             continue;
                         }
                     }
                     if (cnode.Attributes["groupid"] != null)
                     {
                         scgroupid = cnode.Attributes["groupid"].Value.Trim();
                     }
                     int groupid = 0;
                     if (!int.TryParse(scgroupid, out groupid))
                     {
                         groupid = 0;
                     }
                     SubClass sc = new SubClass(scname, groupid, mc);
                     mc.SubClasses.Add(sc);
                 }
                 TreeNodeMajorClass treenode = new TreeNodeMajorClass()
                 {
                     Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                     CustomValue = mc
                 };
                 treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null);
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #8
0
 private void RecursiveLoadData(XmlNodeList list, LogicGroup parent, GroupLayerClass parentLayer)
 {
     if (list == null)
     {
         return;
     }
     foreach (XmlNode node in list)
     {
         if (node.Name == "LogicGroup")
         {
             string fieldName = "", fieldAliasName = "";
             if (node.Attributes["name"] != null)
             {
                 fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName))
                 {
                     continue;
                 }
             }
             if (node.Attributes["alias"] != null)
             {
                 fieldAliasName = node.Attributes["alias"].Value.Trim();
             }
             LogicGroup lg = new LogicGroup(fieldName, fieldAliasName, parent);
             if (dictGroups.ContainsKey(lg.Name))
             {
                 continue;
             }
             dictGroups[lg.Name] = lg;
             parent.LogicGroups.Add(lg);
             TreeNodeLogicGroup treenode = new TreeNodeLogicGroup()
             {
                 Name        = string.IsNullOrEmpty(lg.Alias) ? lg.Name : lg.Alias,
                 CustomValue = lg
             };
             parentLayer.Add2(treenode);
             RecursiveLoadData(node.ChildNodes, lg, parentLayer);
         }
         if (node.Name == "MajorClass")
         {
             string fieldName = "", fieldAliasName = "", classifyFieldName = "", fc2D = "", fc3D = "";
             if (node.Attributes["name"] != null)
             {
                 fieldName = node.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(fieldName))
                 {
                     continue;
                 }
             }
             if (node.Attributes["alias"] != null)
             {
                 fieldAliasName = node.Attributes["alias"].Value.Trim();
             }
             if (node.Attributes["classifyfield"] != null)
             {
                 classifyFieldName = node.Attributes["classifyfield"].Value.Trim();
             }
             if (node.Attributes["fc2D"] != null)
             {
                 fc2D = node.Attributes["fc2D"].Value.Trim();
             }
             if (node.Attributes["fc3D"] != null)
             {
                 fc3D = node.Attributes["fc3D"].Value.Trim();
             }
             MajorClass mc = new MajorClass(fieldName, fieldAliasName, classifyFieldName, fc2D, fc3D, parent);
             if (dictMCs.ContainsKey(mc.Name))
             {
                 continue;
             }
             dictMCs[mc.Name] = mc;
             parent.MajorClasses.Add(mc);
             foreach (XmlNode cnode in node.ChildNodes)
             {
                 if (cnode.Name != "SubClass")
                 {
                     continue;
                 }
                 string scname = "", scgroupid = "";
                 if (cnode.Attributes["name"] != null)
                 {
                     scname = cnode.Attributes["name"].Value.Trim(); if (string.IsNullOrEmpty(scname))
                     {
                         continue;
                     }
                 }
                 if (cnode.Attributes["groupid"] != null)
                 {
                     scgroupid = cnode.Attributes["groupid"].Value.Trim();
                 }
                 int groupid = 0;
                 if (!int.TryParse(scgroupid, out groupid))
                 {
                     groupid = 0;
                 }
                 SubClass sc = new SubClass(scname, groupid, mc);
                 mc.SubClasses.Add(sc);
             }
             TreeNodeMajorClass treenode = new TreeNodeMajorClass()
             {
                 Name        = string.IsNullOrEmpty(mc.Alias) ? mc.Name : mc.Alias,
                 CustomValue = mc
             };
             parentLayer.Add2(treenode);
         }
     }
 }