예제 #1
0
        /// <summary>
        /// Метод добавления сети
        /// </summary>
        /// <param name="nameSubnet">Имя сети.</param>
        /// <param name="ipSubnet">IP адрес сети.</param>
        /// <param name="maskSubnet">Маска сети.</param>
        /// <returns>Возвращает созданную сеть</returns>
        public LCTreeNodeSubnet AddSubnet(string nameSubnet, string ipSubnet, string maskSubnet, string description)
        {
            // созадем новую сеть
            LCTreeNodeSubnet lcTreeNodeSubnet = new LCTreeNodeSubnet
            {
                Text             = nameSubnet,
                Description      = description,
                ContextMenuStrip = LCTreeNode.subnetContextMenuStrip,
                IPSubnet         = ipSubnet,
                MaskSubnet       = maskSubnet,
                ToolTipText      = nameSubnet
            };

            this.Nodes.Add(lcTreeNodeSubnet);
            lcTreeNodeSubnet.UpdateLC();
            this.WriteListBoxOperation("Добавлена группа : " + nameSubnet);
            return(lcTreeNodeSubnet);
        }
예제 #2
0
        /// <summary>
        /// Метод добавления дочерних узлов в дерево
        /// </summary>
        /// <param name="xnod">XML элемент</param>
        /// <param name="newNode">Компонент TreeNode в котором создаются узлы</param>
        private void AddChildrenDOMXML(XElement xnod, TreeNode newNode)
        {
            if (xnod.NodeType == System.Xml.XmlNodeType.Element)
            {
                switch (xnod.Name.ToString())
                {
                case "Group":
                {
                    LCTreeNodeGroup lcTreeNodeGroup = new LCTreeNodeGroup
                    {
                        Text             = xnod.Attribute("NameGroup").Value,
                        Description      = xnod.Attribute("Description").Value,
                        ContextMenuStrip = LCTreeNode.groupContextMemuStrip,
                        ImageIndex       = 2
                    };
                    newNode.Nodes.Add(lcTreeNodeGroup);
                    lcTreeNodeGroup.UpdateLC();
                    newNode = lcTreeNodeGroup;
                }
                break;

                case "NoList":
                {
                    LCTreeNodeNoList lcTreeNodeNoList = new LCTreeNodeNoList
                    {
                        Text             = xnod.Attribute("NameGroup").Value,
                        Description      = xnod.Attribute("Description").Value,
                        ContextMenuStrip = LCTreeNode.noListContextMenuStrip,
                        ImageIndex       = 2
                    };
                    lcTreeNodeNoList.ToolTipText += lcTreeNodeNoList.Text;
                    lcTreeNodeNoList.ToolTipText += "\n" + lcTreeNodeNoList.Description;
                    newNode.Nodes.Add(lcTreeNodeNoList);
                    newNode = lcTreeNodeNoList;
                }
                break;

                case "Host":
                {
                    LCTreeNodeHost lcTreeNodeHost = new LCTreeNodeHost
                    {
                        Text             = xnod.Attribute("NameHost").Value,
                        IP               = xnod.Attribute("IP").Value,
                        Barcode          = xnod.Attribute("Barcode").Value,
                        Login            = xnod.Attribute("Login").Value,
                        Password         = xnod.Attribute("Password").Value,
                        Description      = xnod.Attribute("Description").Value,
                        TypeHost         = (LCTypeHost)Enum.Parse(typeof(LCTypeHost), xnod.Attribute("TypeHost").Value),
                        ContextMenuStrip = LCTreeNode.computerContextMenuStrip
                    };
                    newNode.Nodes.Add(lcTreeNodeHost);
                    lcTreeNodeHost.UpdateLC();
                    return;
                }

                case "Subnet":
                {
                    LCTreeNodeSubnet lcTreeNodeSubnet = new LCTreeNodeSubnet
                    {
                        Text             = xnod.Attribute("NameSubnet").Value,
                        IPSubnet         = xnod.Attribute("IPSubnet").Value,
                        MaskSubnet       = xnod.Attribute("MaskSubnet").Value,
                        Description      = xnod.Attribute("Description").Value,
                        ContextMenuStrip = LCTreeNode.subnetContextMenuStrip,
                        ImageIndex       = 5
                    };
                    newNode.Nodes.Add(lcTreeNodeSubnet);
                    lcTreeNodeSubnet.UpdateLC();
                    newNode = lcTreeNodeSubnet;
                }
                break;

                case "Root":
                {
                    //MessageBox.Show("yes");
                    //newNode.ImageIndex = 1;
                    //newNode.Text = mapAttributes.Item(1).Value;
                }
                break;
                }
                foreach (XElement element in xnod.Elements())
                {
                    AddChildrenDOMXML(element, newNode);
                }
            }
        }