コード例 #1
0
ファイル: YtTreeModel.cs プロジェクト: virl/yttrium
        /// <summary>
        /// Создание узла дерева из узла xml документа
        /// </summary>
        /// <param name="xmlNode">Узел xml документа</param>
        /// <returns>Созданный узел дерева</returns>
        protected static Aga.Controls.Tree.Node CreateNodeFromXml(XmlNode xmlNode)
        {
            if (xmlNode.Name.Equals("group"))
            {
                GroupNode groupNode = new GroupNode(xmlNode.Attributes["name"].Value);

                foreach (XmlNode subNode in xmlNode.ChildNodes)
                {
                    groupNode.Nodes.Add(CreateNodeFromXml(subNode));
                }

                return groupNode;
            }

            if (xmlNode.Name.Equals("computer"))
            {
                ComputerNode computerNode = new ComputerNode(xmlNode.Attributes["host"].Value);
                XmlAttribute password = (XmlAttribute)xmlNode.Attributes.GetNamedItem("password");
                if (password != null)
                {
                    computerNode.Password = password.Value;
                }

                return computerNode;
            }

            throw new FormatException("Invalid node type");
        }
コード例 #2
0
ファイル: SearchForm.cs プロジェクト: virl/yttrium
        void finder_ComputerFound(object sender, FinderEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler<FinderEventArgs>(finder_ComputerFound),
                    new object[] { sender, e });

                return;
            }

            ComputerNode comp = new ComputerNode(e.Hostname);
            Row row = new Row(new Cell[] { new Cell(comp),
                new Cell("Test") });

            resultTable.BeginUpdate();
            tableModel.Rows.Add(row);
            int[] oldIndx = tableModel.Selections.SelectedIndicies;
            tableModel.Selections.AddCells(
                tableModel.Rows.IndexOf(row),
                0,
                tableModel.Rows.IndexOf(row),
                columnModel.Columns.Count);
            resultTable_SelectionChanged(sender, new XPTable.Events.SelectionEventArgs(tableModel, oldIndx, tableModel.Selections.SelectedIndicies));
            UpdateComputersCount();
            resultTable.EndUpdate();

            comp.StateChanged += new EventHandler(comp_StateChanged);
        }