Add() public méthode

public Add ( string text ) : TreeNode
text string
Résultat TreeNode
 /// <summary>
 /// 获取注册表项的子节点,并将其添加到树形控件节点中
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="rootKey"></param>
 public void GetSubKey(TreeNodeCollection nodes, RegistryKey rootKey)
 {
     if (nodes.Count != 0) return;
     //获取项的子项名称列表
     string[] keyNames = rootKey.GetSubKeyNames();
     //遍历子项名称
     foreach (string keyName in keyNames)
     {
     try
     {
     //根据子项名称功能注册表项
     RegistryKey key = rootKey.OpenSubKey(keyName);
     //如果表项不存在,则继续遍历下一表项
     if (key == null) continue;
     //根据子项名称创建对应树形控件节点
     TreeNode TNRoot = new TreeNode(keyName);
     //将注册表项与树形控件节点绑定在一起
     TNRoot.Tag = key;
     //向树形控件中添加节点
     nodes.Add(TNRoot);
     }
     catch
     {
     //如果由于权限问题无法访问子项,则继续搜索下一子项
     continue;
     }
     }
 }
Exemple #2
1
        public void initTrvTree(TreeNodeCollection treeNodes, string strParentIndex, DataView dvList)
        {
            try
            {
                TreeNode tempNode;
                DataView dvList1;
                string currentNum;
                dvList1 = dvList;
                // select the datarow that it's parentcode is strParentIndex
                DataRow[] dataRows = dvList.Table.Select("parentCode ='" + strParentIndex + "'");
                foreach (DataRow dr in dataRows)
                {
                    tempNode = new TreeNode();
                    tempNode.Text = dr["bookTypeCode"].ToString() + "-"
                        + dr["bookTypeName"].ToString();
                    // tag property is save data about this treenode
                    tempNode.Tag = new treeNodeData(dr["bookTypeCode"].ToString(),
                        dr["bookTypeName"].ToString(), dr["bookTypeExplain"].ToString(),
                        dr["currentCode"].ToString(), dr["parentCode"].ToString());

                    currentNum = dr["currentCode"].ToString();
                    treeNodes.Add(tempNode);
                    // call rucursive
                    TreeNodeCollection temp_nodes = treeNodes[treeNodes.Count - 1].Nodes;
                    initTrvTree(temp_nodes, currentNum, dvList1);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("初始化TreeView失败");
            }
        }
Exemple #3
0
 void Apply( TypeAnalied type, TreeNodeCollection tnc )
 {
     if ( type.Parent == null ) {
         foreach ( TreeNode v in tnc ) {
             if ( v.Text == type.Source.Namespace ) {
                 tnc = v.Nodes;
                 break;
             }
             if ( tnc.IndexOf( v ) == tnc.Count - 1 ) {
                 tnc = tnc.Add( type.Source.Namespace ).Nodes;
                 break;
             }
         }
         if ( tnc.Count == 0 )
             tnc = tnc.Add( type.Source.Namespace ).Nodes;
     }
     TreeNode node = new TreeNode( type.Source.Name );
     tnc.Add( node );
     foreach ( VariableAnalied var_ana in type.Variables )
         Apply( var_ana, node.Nodes );
     foreach ( MethodAnalied var_ana in type.Methods )
         Apply( var_ana, node.Nodes );
     foreach ( TypeAnalied typ_ana in type.Types )
         Apply( typ_ana, node.Nodes );
 }
        private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
        {
            TreeNode tn = new TreeNode();

            if (dt == null)
                return;

            if (nodes == null)
            {
                tn.Text = "אין קטגוריות";
                tn.ToolTipText = "-1";
                nodes.Add(tn);
            }

            foreach (DataRow dr in dt.Rows)
            {
                string name = dr["CatHebrewName"].ToString();
                string id = dr["CatId"].ToString();
                tn.Text = name;
                tn.ToolTipText = id;
                try
                {
                    nodes.Add(tn);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                DataTable childDT = GetTableFromQuery(String.Format("select * FROM Table_LookupCategories WHERE ParentCatId='{0}'", id));
                PopulateNodes(childDT, tn.Nodes);
            }
        }
Exemple #5
0
 void AddDiretory(string dir, TreeNodeCollection nodes)
 {
     try
     {
         foreach (string subdir in System.IO.Directory.GetDirectories(dir, "*", System.IO.SearchOption.TopDirectoryOnly))
         {
             TreeNode node = new TreeNode(System.IO.Path.GetFileName(subdir));
             AddDiretory(subdir, node.Nodes);
             nodes.Add(node);
         }
     }
     catch (Exception)
     {
     }
     try
     {
         foreach (string file in System.IO.Directory.GetFiles(dir, "*", System.IO.SearchOption.TopDirectoryOnly))
         {
             TreeNode node = new TreeNode(System.IO.Path.GetFileName(file));
             node.Name = file.Remove(0, 4);  // 最初の"bmp\"を取り除く
             nodes.Add(node);
         }
     }
     catch (Exception)
     {
     }
 }
        public static void PopulateExternalMembers( IMemberRefResolutionScope decl, TreeNodeCollection nodes, bool red )
        {
            foreach ( MethodRefDeclaration externalMethod in decl.MethodRefs )
            {
                nodes.Add( new ExternalMethodTreeNode( externalMethod, red ) );
            }

            foreach ( FieldRefDeclaration externalField in decl.FieldRefs )
            {
                nodes.Add( new ExternalFieldTreeNode( externalField, red ) );
            }
        }
Exemple #7
0
 private void AddRoutes(TreeNodeCollection collection, string path, string[] keywords, string[] metadata)
 {
     if (Directory.Exists(path)) {
         string[] directories = Directory.GetDirectories(path);
         foreach (string directory in directories) {
             TreeNode node = collection.Add(Path.GetFileName(directory));
             node.ImageKey = "folder";
             node.SelectedImageKey = "folder";
             string title = Path.GetFileNameWithoutExtension(directory);
             if (keywords.Length != 0) {
                 List<string> remaining = new List<string>();
                 foreach (string keyword in keywords) {
                     if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) < 0) {
                         remaining.Add(keyword);
                     }
                 }
                 AddRoutes(node.Nodes, directory, remaining.ToArray(), metadata);
             } else {
                 AddRoutes(node.Nodes, directory, keywords, metadata);
             }
         }
         string[] files = Directory.GetFiles(path);
         foreach (string file in files) {
             if (file.EndsWith(".csv", StringComparison.OrdinalIgnoreCase) | file.EndsWith(".rw", StringComparison.OrdinalIgnoreCase)) {
                 string title = Path.GetFileNameWithoutExtension(file);
                 bool add = true;
                 foreach (string keyword in keywords) {
                     add = false;
                     foreach (string tag in metadata) {
                         if (tag.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
                             add = true;
                             break;
                         }
                     }
                     if (!add) {
                         if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
                             add = true;
                         } else {
                             break;
                         }
                     }
                 }
                 if (add) {
                     TreeNode node = collection.Add(title);
                     node.Tag = file;
                     node.ImageKey = "route";
                     node.SelectedImageKey = "route";
                 }
             }
         }
     }
 }
 private void PopulateMethod(TreeNodeCollection c, Method m) {
   c.Add(new TreeNode(m.RestPath));
   c.Add(new TreeNode(m.RpcName));
   c.Add(new TreeNode(m.HttpMethod));
   TreeNode n = new TreeNode("Parameters");
   c.Add(n);
   c = n.Nodes;
   if (m.Parameters != null) {
     foreach (KeyValuePair<string, Parameter> p in m.Parameters) {
       PopulateParameter(c, p.Value);
     }
   }
 }
 /// <summary>
 /// 加载文件夹和文件的递归方法
 /// </summary>
 /// <param name="path"></param>
 /// <param name="tree"></param>
 private void InputFileAndDirectory(string path, TreeNodeCollection tree)
 {
     string[] directories = Directory.GetDirectories(path);
     foreach (var item in directories)//不用判断是否有文件,如果没有,foreach不会执行
     {
         TreeNode sonTrees = tree.Add(Path.GetFileName(item));
         InputFileAndDirectory(item, sonTrees.Nodes);
     }
     string[] files = Directory.GetFiles(path);
     foreach (var item in files)
     {
         tree.Add(Path.GetFileName(item));
     }
 }
Exemple #10
0
 private void showParseNode(PatternNode pattNode, TreeNodeCollection coll)
 {
     if (pattNode.Nodes.Count == 0) {
         coll.Add(pattNode.Text);
         return;
     }
     for (int i = 0; i < pattNode.Nodes.Count; i++) {
         PatternNode node = pattNode.Nodes[i];
         TreeNode treeNode = new TreeNode(node.Text + ":"+node.Releation.ToString()
             +":"+node.OneOrMore);
         coll.Add(treeNode);
         if (node.Nodes.Count != 0)
             showParseNode(node,treeNode.Nodes);
     }
 }
Exemple #11
0
        public bool Parser( ref TreeNodeCollection mNode, 
            byte [] PacketData ,
            ref int Index ,
            ref ListViewItem LItem)
        {
            TreeNode mNodex;
            string Tmp = "";
            //int k = 0;

            mNodex = new TreeNode();
            mNodex.Text = "TB ( Trans Bridging Protocol )";
            //mNodex.Tag = Index.ToString() + "," + Const.LENGTH_OF_ARP.ToString();
            //Function.SetPosition( ref mNodex , Index - 2 , 2 , false );

            /*if( ( Index + Const.LENGTH_OF_ARP ) >= PacketData.Length )
            {
                mNode.Add( mNodex );
                Tmp = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";
                mNode.Add( Tmp );
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = Tmp;

                return false;
            }*/

            try
            {
                //k = Index - 2; mNodex.Nodes[ mNodex.Nodes.Count - 1 ].Tag = k.ToString() + ",2";

                LItem.SubItems[ Const.LIST_VIEW_PROTOCOL_INDEX ].Text = "TB";
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = "TB protocol";

                mNode.Add( mNodex );

            }
            catch( Exception Ex )
            {
                mNode.Add( mNodex );
                Tmp = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";
                mNode.Add( Tmp );
                Tmp = "[ Exception raised is <" + Ex.GetType().ToString() + "> at packet index <" + Index.ToString() + "> ]";
                mNode.Add( Tmp );
                LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = "[ Malformed TB packet. Remaining bytes don't fit an TB packet. Possibly due to bad decoding ]";

                return false;
            }

            return true;
        }
Exemple #12
0
        public static void calculateAllTracesFromFunction(String sSignature, TreeNodeCollection tncTraces,
                                                          List<String> lFunctionsCalled,
                                                          String sFilter_Signature, String sFilter_Parameter,
                                                          bool bUseIsCalledBy, ICirDataAnalysis fcdAnalysis)
        {
            TreeNode tnNewTreeNode = O2Forms.newTreeNode(sSignature, sSignature, 0, sSignature);
            tncTraces.Add(tnNewTreeNode);

            if (fcdAnalysis.dCirFunction_bySignature.ContainsKey(sSignature))
            {
                ICirFunction cfCirFunction = fcdAnalysis.dCirFunction_bySignature[sSignature];
                List<ICirFunction> lsFunctions = new List<ICirFunction>();
                if (bUseIsCalledBy)
                    foreach(var cirFunctionCall in cfCirFunction.FunctionIsCalledBy)
                        lsFunctions.Add(cirFunctionCall.cirFunction);
                else
                    lsFunctions.AddRange(cfCirFunction.FunctionsCalledUniqueList);                                               

                foreach (ICirFunction cirFunction in lsFunctions)
                    if (false == lFunctionsCalled.Contains(cirFunction.FunctionSignature))
                    {
                        lFunctionsCalled.Add(cirFunction.FunctionSignature);
                        calculateAllTracesFromFunction(cirFunction.FunctionSignature, tnNewTreeNode.Nodes, lFunctionsCalled,
                                                       sFilter_Signature, sFilter_Parameter, bUseIsCalledBy,
                                                       fcdAnalysis);
                    }
                    else
                        tnNewTreeNode.Nodes.Add("(Circular ref) : " + cirFunction.FunctionSignature);
            }
        }
 private void PopulateMethods(TreeNodeCollection c, Resource r) {
   foreach (KeyValuePair<string, Method> kvp in r.Methods) {
     TreeNode m = new TreeNode(kvp.Key);
     PopulateMethod(m.Nodes, kvp.Value);
     c.Add(m);
   }
 }
		/// <summary>
		/// 选中装载流程列表
		/// </summary>
		/// <param name="iSqlstr"></param>
		/// <param name="StartNotes"></param>
        public static void LoadWorkFlowSelectNode(string key, TreeNodeCollection startNodes)
		{
			if (startNodes==null)
                throw new Exception("LoadWorkFlowSelectNode的参数startNotes不能为空!");

            DataTable table = WorkFlowClass.GetWorkflowsByClassId(key);
			//startNodes.Clear();
            //deleteNode(startNodes);
			foreach(DataRow row in table.Rows)
			{

                WorkFlowTreeNode tmpNode = new WorkFlowTreeNode();
                tmpNode.NodeId = row["WorkFlowId"].ToString();
                tmpNode.WorkFlowClassId = row["WFClassId"].ToString();
				tmpNode.ImageIndex=2;
				tmpNode.SelectedImageIndex=2;
                tmpNode.ToolTipText = "流程";
                tmpNode.Status = row["Status"].ToString();
                tmpNode.Text = row["FlowCaption"].ToString();
                tmpNode.MgrUrl=row["mgrurl"].ToString();
                tmpNode.Description = row["Description"].ToString();
                tmpNode.NodeType = WorkConst.WORKFLOW_FLOW;
				startNodes.Add(tmpNode);

			}

		}
        public void GetDirectories(TreeNode TreNode, TreeNodeCollection TreNodeCollection,string PathOfDir)
        {
            DirectoryInfo[] DirNames;

            //TreNode.SelectedImageIndex the index of image and this if to sure that
            // the image is not to rootnode and not to files so it will be to directory
            //and then open dir and get subdir and files
            if (TreNode.SelectedImageIndex!=0 && TreNode.SelectedImageIndex!=2)
            {
                try
                {
                    //to get directories
                    DirectoryInfo Directories = new DirectoryInfo(PathOfDir);
                    DirNames = Directories.GetDirectories();

                    foreach (DirectoryInfo DName in DirNames)
                    {
                        TreNode = new TreeNode(DName.Name,1,1);
                        TreNodeCollection.Add(TreNode);
                    }

                    //To get files from directory
                    GetFiles(TreNode, TreNodeCollection,PathOfDir);

                }
                catch (Exception w)
                {

                    MessageBox.Show(w.ToString());
                }
            }
        }
 static void BuildTree(TreeNodeCollection nodes, Tree tree)
 {
     var node = new TreeNode { Text = tree.Token };
     nodes.Add(node);
     foreach (var subTree in tree)
         BuildTree(node.Nodes, subTree);
 }
        private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader)
        {
            bool bContinue = reader.ReadToDescendant("function");
            while (bContinue)
            {
                NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name"));
                outNodes.Add(node);

                bool bInstance = reader.GetAttribute("instance") == "true";
                node.bIsInstanceMethod = bInstance;
                string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax;
                node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example

                if (this.emphasizeStaticness())
                {
                    if (!bInstance)
                    {
                        //change visible node text to emphasize static-ness
                        node.Text = node.strNamespacename + "." + node.strFunctionname;
                    }
                }
                bContinue = ReadToNextSibling(reader, "function");
            }

            reader.Close();
        }
Exemple #18
0
 private void InitTreeView(IEnumerable<string> roots, TreeNodeCollection childNodes)
 {
     foreach (var root in roots)
     {
         childNodes.Add(root).Nodes.Add("tmpNode");
     }
 }
        private void expandNamespace_function(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader)
        {
            bool bContinue = reader.ReadToDescendant("function");
            while (bContinue)
            {

               // if (reader.GetAttribute("args") != null) MessageBox.Show("instance?");

                NodeDocLnzFunction node = new NodeDocLnzFunction(strSection, strNamespace, reader.GetAttribute("name"));

                bool bInstance = reader.GetAttribute("instance") == "true";
                node.bIsInstanceMethod = bInstance;
                string strArgs = reader.GetAttribute("args"); if (strArgs != null && strArgs != "") node.strArguments = strArgs;
                string strReturns = reader.GetAttribute("returns"); if (strReturns != null && strReturns != "") node.strReturns = strReturns;
                node.strDocumentationAndExample = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example

                if (bInstance)
                {
                    //MessageBox.Show("instance found");
                    outInstanceMethods.Nodes.Add(node);
                }
                else
                    outNodes.Add(node);

                bContinue = ReadToNextSibling(reader, "function");
            }
            reader.Close();
        }
Exemple #20
0
        private void AddNode(TreeNodeCollection parentTreeNodes, XElement element)
        {
            StringBuilder sb = new StringBuilder();

            string attrstring = string.Join(" ", element.Attributes().Select(a => a.Name + "=\"" + a.Value + "\""));
            if (attrstring != string.Empty)
            {
                sb.Append(" " + attrstring);
            }

            string innertext = element.Value;
            if (innertext != string.Empty)
            {
                sb.Append(" Value=\"" + innertext + "\"");
            }

            TreeNode treenode = new TreeNode();
            treenode.Text = element.Name.LocalName + sb.ToString();
            parentTreeNodes.Add(treenode);

            foreach (XElement child in element.Descendants())
            {
                AddNode(treenode.Nodes, child);
            }

            treenode.Expand();
        }
        /// <summary>
        /// 递归装载全部流程类型
        /// </summary>
        /// <param name="key"></param>
        /// <param name="startNodes"></param>
        public static void LoadWorkFlowClass(string key, TreeNodeCollection startNodes)
        {
            try
            {
                DataTable table = WorkFlowClass.GetChildWorkflowClass(key);

                startNodes.Clear();
                foreach (DataRow row in table.Rows)
                {
                    WorkFlowClassTreeNode tmpNode = new WorkFlowClassTreeNode();
                    tmpNode.NodeId = row["WFClassId"].ToString();
                    tmpNode.ImageIndex = 0;
                    tmpNode.ToolTipText = "分类";
                    tmpNode.clLevel = Convert.ToInt16(row["clLevel"]);
                    tmpNode.SelectedImageIndex = 0;
                    tmpNode.Text = row["Caption"].ToString();
                    tmpNode.WorkflowFatherClassId = row["FatherId"].ToString();
                    tmpNode.Description = row["Description"].ToString();
                    tmpNode.MgrUrl = row["clmgrurl"].ToString();
                    tmpNode.NodeType = WorkConst.WORKFLOW_CLASS;
                    startNodes.Add(tmpNode);

                    LoadWorkFlowClass(tmpNode.NodeId, tmpNode.Nodes);

                }
                WorkFlowTreeNode.LoadWorkFlowSelectNode(key, startNodes);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
 private void PopulateTree(Node currentNode, TreeNodeCollection parentsNodes)
 {
     TreeNode newNode = new TreeNode("[ " + currentNode.Type + "] " + currentNode.Value);
     parentsNodes.Add(newNode);
     foreach (Node child in currentNode.Children)
         PopulateTree(child, newNode.Nodes);
 }
Exemple #23
0
        void PopulateNodes(System.Windows.Forms.TreeNodeCollection nodes, ITreeStore item)
        {
            nodes.Clear();
            var count = item.Count;

            for (int i = 0; i < count; i++)
            {
                var child = item[i];
                var node  = nodes.Add(child.Key, child.Text, GetImageKey(child.Image));
                node.Tag = child;

                if (child.Expandable)
                {
                    if (child.Expanded)
                    {
                        PopulateNodes(node.Nodes, child);
                        node.Expand();
                    }
                    else
                    {
                        node.Nodes.Add(EmptyName, string.Empty);
                    }
                }
            }
        }
 /// <summary>
 /// Adds an options node to the options tree.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 private int AddNode(WinForms.TreeNodeCollection collection, IOptions options)
 {
     WinForms.TreeNode node = new WinForms.TreeNode(options.NodeName);
     node.Tag = options;
     collection.Add(node);
     return(this.nodesList.Add(options));
 }
Exemple #25
0
        void PerformPopulateNodes(System.Windows.Forms.TreeNodeCollection nodes, ITreeStore item)
        {
            nodes.Clear();
            var count = item.Count;

            for (int i = 0; i < count; i++)
            {
                var child = item[i];
                var node  = new swf.TreeNode
                {
                    Text = child.Text,
                    Name = child.Key,
                    Tag  = child,
                };
                SetImage(child, node);

                if (child.Expandable)
                {
                    if (child.Expanded)
                    {
                        PerformPopulateNodes(node.Nodes, child);
                        node.Expand();
                    }
                    else
                    {
                        node.Nodes.Add(EmptyName, string.Empty);
                    }
                }

                nodes.Add(node);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GrhTreeViewFolderNode"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="subCategory">The sub category.</param>
 GrhTreeViewFolderNode(TreeNodeCollection parent, string subCategory)
 {
     _subCategory = subCategory;
     Name = FullCategory;
     parent.Add(this);
     Text = SubCategory;
 }
        private void AddSourceNodeToRoot(Guid source, TreeNodeCollection coll)
        {
            var node = new TreeNode
                           {
                               Name = source.ToString(),
                               Text = source.ToString()
                           };

            node.ContextMenu = new ContextMenu(
                new[]
                    {
                        new MenuItem("Delete",
                                     (sender, args) =>
                                         {
                                             var senderNode = ((sender as MenuItem).Parent.Tag as TreeNode);
                                             if (senderNode.Nodes.Count > 0)
                                             {
                                                 MessageBox.Show("Nodes containing events cannot be deleted.");
                                                 return;
                                             }
                                             store.RemoveEmptyEventSource(Guid.Parse(node.Name));
                                             senderNode.Remove();
                                         }
                            )
                    }
                ) { Tag = node };

            coll.Add(node);

            var events = store.GetAllEvents(source);
            foreach (var evt in events)
            {
                AddEvtNodeToSourceNode(evt, node);
            }
        }
 private void PopulateSchemaRecursive(System.Windows.Forms.TreeNodeCollection nodes, IDataSourceViewSchema viewSchema, int depth, IDictionary duplicates)
 {
     if (viewSchema != null)
     {
         SchemaTreeNode node = new SchemaTreeNode(viewSchema);
         nodes.Add(node);
         SchemaTreeNode node2 = (SchemaTreeNode)duplicates[viewSchema.Name];
         if (node2 != null)
         {
             node2.Duplicate = true;
             node.Duplicate  = true;
         }
         foreach (TreeNodeBinding binding in this._bindingsListView.Items)
         {
             if (string.Compare(binding.DataMember, viewSchema.Name, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 IDataSourceViewSchemaAccessor accessor = binding;
                 if ((depth == binding.Depth) || (accessor.DataSourceViewSchema == null))
                 {
                     accessor.DataSourceViewSchema = viewSchema;
                 }
             }
         }
         IDataSourceViewSchema[] children = viewSchema.GetChildren();
         if (children != null)
         {
             for (int i = 0; i < children.Length; i++)
             {
                 this.PopulateSchemaRecursive(node.Nodes, children[i], depth + 1, duplicates);
             }
         }
     }
 }
Exemple #29
0
 public TreeNode AddTreeNodes(ref TreeNodeCollection nodes, string name, object tag)
 {
     TreeNode newNode = nodes.Add(name);
     newNode.Tag = tag;
     newNode.ImageIndex = Convert.ToInt32(tag);
     return newNode;
 }
 private void LoadTagBlockValuesAsNodes(TreeNodeCollection treeNodeCollection, TagBlock block)
 {
     //Add this TagBlock (chunk) to the Nodes
     treeNodeCollection.Add(block.ToString());
     int index = treeNodeCollection.Count - 1;
     treeNodeCollection[index].ContextMenuStrip = chunkMenu;
     //Add the TagBlock (chunk) object to the Tag to let use edit it directly from the node
     treeNodeCollection[index].Tag = block;
     //Values might be null, dealio
     if (block.Values == null) return;
     foreach (Value val in block.Values)
     {
         //the Values can be a bunch of things, we only want the ones that are TagBlockArrays (reflexives)
         if (val is TagBlockArray)
         {
             treeNodeCollection[index].Nodes.Add(val.ToString());
             treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].ContextMenuStrip = reflexiveMenu;
             //Add the TagBlockArray object (reflexive) to the Tag to let us edit it directly from the node
             treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].Tag = val;
             //TagBlocks also might be null, dealio
             if ((val as TagBlockArray).TagBlocks == null) continue;
             foreach (TagBlock tagBlock in (val as TagBlockArray).TagBlocks)
             {
                 //Recurse
                 LoadTagBlockValuesAsNodes(treeNodeCollection[index].Nodes[treeNodeCollection[index].Nodes.Count - 1].Nodes, tagBlock);
             }
         }
     }
 }
Exemple #31
0
        /// <summary>
        /// Adds a virtual file system item to the tree view.
        /// </summary>
        /// <param name="p_tndRoot">The node to which to add the new item.</param>
        /// <param name="p_strName">The name of the new virtual item to add.</param>
        /// <returns>The new tree node representing the new virtual file system item.</returns>
        public FileSystemTreeNode AddVirtualNode(FileSystemTreeNode p_tndRoot, string p_strName)
        {
            if ((p_tndRoot != null) && !p_tndRoot.IsDirectory)
            {
                return(AddVirtualNode(p_tndRoot.Parent, p_strName));
            }
            FileSystemTreeNode tndFile = null;

            System.Windows.Forms.TreeNodeCollection tncSiblings = (p_tndRoot == null) ? this.Nodes : p_tndRoot.Nodes;
            if (!tncSiblings.ContainsKey(p_strName))
            {
                tndFile = (FileSystemTreeNode)tncSiblings[p_strName];
            }
            else
            {
                string strName = Path.GetFileName(p_strName);
                if (String.IsNullOrEmpty(strName))
                {
                    strName = p_strName;
                }
                tndFile      = new FileSystemTreeNode(strName, null);
                tndFile.Name = p_strName;
                tncSiblings.Add(tndFile);
                OnNodeAdded(new NodesChangedEventArgs(tndFile));
            }
            return(tndFile);
        }
Exemple #32
0
        private static void AddNodes(TreeNodeCollection treeNodes, RegexNode regexNode)
        {
            var treeNode = treeNodes.Add(
                regexNode.Id.ToString(CultureInfo.InvariantCulture),
                string.Format("{0} - {1}", regexNode.Pattern, regexNode.NodeType));

            if (regexNode is LeafNode)
            {
                return;
            }

            var wrapperNode = regexNode as WrapperNode;
            if (wrapperNode != null)
            {
                AddNodes(treeNode.Nodes, (wrapperNode).Child);
            }

            var containerNode = regexNode as ContainerNode;
            if (containerNode != null)
            {
                foreach (var child in (containerNode).Children)
                {
                    AddNodes(treeNode.Nodes, child);
                }
            }

            var alternation = regexNode as Alternation;
            if (alternation != null)
            {
                foreach (var choice in (alternation).Choices)
                {
                    AddNodes(treeNode.Nodes, choice);
                }
            }
        }
Exemple #33
0
 private void TreeViewAppendObject(object Data, TreeNodeCollection Target)
 {
     Target.Add(new TreeNode()
     {
         Text = Data.ToString(),
         Tag = Data
     });
 }
 public static System.Windows.Forms.TreeNode AddNode(System.Windows.Forms.TreeNodeCollection parentNodes, string text, int imageIndex, object tag)
 {
     System.Windows.Forms.TreeNode n = parentNodes.Add(text);
     n.ImageIndex         = imageIndex;
     n.SelectedImageIndex = imageIndex;
     n.Tag = tag;
     return(n);
 }
Exemple #35
0
 public static void AddTreeNode(string str, int cls, System.Windows.Forms.TreeNodeCollection nodes)
 {
     System.Windows.Forms.TreeNode nodeTemp = new System.Windows.Forms.TreeNode();
     nodeTemp.Text               = str;
     nodeTemp.ImageIndex         = cls;
     nodeTemp.SelectedImageIndex = cls;
     nodes.Add(nodeTemp);
 }
Exemple #36
0
 public void ParseTree( TreeNodeCollection n , Expression ex )
 {
     foreach (Expression e in ex.Members)
     {
         TreeNode t = n.Add(FormName(e));
         ParseTree ( t.Nodes, e );
     }
 }
Exemple #37
0
        public static void AddNAEToTree(TreeNodeCollection nodes, NAE nae)
        {
            TreeNode naeNode = new TreeNode(nae.Name);
            naeNode.Tag = nae;
            naeNode.ContextMenuStrip = frmMain.StaticContextNAE;

            nodes.Add(naeNode);
        }
Exemple #38
0
        /// <summary>
        /// Raises the <see cref="Control.DragDrop"/>.
        /// </summary>
        /// <remarks>
        /// This handles adding the dropped file/folder to the source tree.
        /// </remarks>
        /// <param name="e">A <see cref="DragEventArgs"/> that describes the event arguments.</param>
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);

            Cursor crsOldCursor = Cursor;

            Cursor = Cursors.WaitCursor;
            BeginUpdate();
            FileSystemTreeNode tndFolder = (FileSystemTreeNode)GetNodeAt(PointToClient(new Point(e.X, e.Y)));

            if ((tndFolder != null) && !tndFolder.IsDirectory)
            {
                tndFolder = tndFolder.Parent;
            }
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] strFileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (strFileNames != null)
                {
                    if (tndFolder != null)
                    {
                        AddPaths(tndFolder, strFileNames);
                        tndFolder.Expand();
                    }
                    else
                    {
                        AddPaths(null, strFileNames);
                    }
                }
            }
            else if (e.Data.GetDataPresent(typeof(List <FileSystemTreeNode>)))
            {
                List <FileSystemTreeNode> lstNodes = ((List <FileSystemTreeNode>)e.Data.GetData(typeof(List <FileSystemTreeNode>)));
                System.Windows.Forms.TreeNodeCollection tncSiblings = null;
                if (tndFolder == null)
                {
                    tncSiblings = Nodes;
                }
                else
                {
                    tncSiblings = tndFolder.Nodes;
                    tndFolder.Expand();
                }
                for (Int32 i = 0; i < lstNodes.Count; i++)
                {
                    lstNodes[i].Remove();
                    tncSiblings.Add(lstNodes[i]);
                }
            }
            EndUpdate();
            Cursor = crsOldCursor;
        }
Exemple #39
0
 private void LoadNodes(System.Windows.Forms.TreeNodeCollection destNodes, System.Web.UI.WebControls.MenuItemCollection sourceNodes)
 {
     foreach (System.Web.UI.WebControls.MenuItem item in sourceNodes)
     {
         MenuItemContainer node = new MenuItemContainer();
         destNodes.Add(node);
         node.Text = item.Text;
         System.Web.UI.WebControls.MenuItem clone = (System.Web.UI.WebControls.MenuItem)((ICloneable)item).Clone();
         this._menuDesigner.RegisterClone(item, clone);
         node.WebMenuItem = clone;
         if (item.ChildItems.Count > 0)
         {
             this.LoadNodes(node.Nodes, item.ChildItems);
         }
     }
 }
Exemple #40
0
 private void LoadNodes(System.Windows.Forms.TreeNodeCollection destNodes, System.Web.UI.WebControls.TreeNodeCollection sourceNodes)
 {
     foreach (System.Web.UI.WebControls.TreeNode node in sourceNodes)
     {
         TreeNodeContainer container = new TreeNodeContainer();
         destNodes.Add(container);
         container.Text = node.Text;
         System.Web.UI.WebControls.TreeNode clone = (System.Web.UI.WebControls.TreeNode)((ICloneable)node).Clone();
         this._treeViewDesigner.RegisterClone(node, clone);
         container.WebTreeNode = clone;
         if (node.ChildNodes.Count > 0)
         {
             this.LoadNodes(container.Nodes, node.ChildNodes);
         }
     }
 }
Exemple #41
0
        void AddJoint(ListedMeshBlocks lmb, SimPe.Interfaces.Scenegraph.ICresChildren bl, Ambertation.Graphics.MeshList parent, System.Windows.Forms.TreeNodeCollection nodes)
        {
            SimPe.Plugin.TransformNode tn = bl.StoredTransformNode;


            if (tn != null)
            {
                Ambertation.Graphics.MeshBox mb = new Ambertation.Graphics.MeshBox(
                    Microsoft.DirectX.Direct3D.Mesh.Sphere(dx.Device, 0.02f, 12, 24),
                    1,
                    Ambertation.Graphics.DirectXPanel.GetMaterial(Color.Wheat)
                    );
                mb.Wire = false;

                Ambertation.Scenes.Transformation trans = new Ambertation.Scenes.Transformation();
                trans.Rotation.X = tn.Rotation.GetEulerAngles().X;
                trans.Rotation.Y = tn.Rotation.GetEulerAngles().Y;
                trans.Rotation.Z = tn.Rotation.GetEulerAngles().Z;

                trans.Translation.X = tn.TransformX;
                trans.Translation.Y = tn.TransformY;
                trans.Translation.Z = tn.TransformZ;

                mb.Transform = Ambertation.Scenes.Converter.ToDx(trans);

                TreeNode tnode = new TreeNode(tn.ToString());
                tnode.Tag = mb;
                nodes.Add(tnode);
                jointmap[bl.GetName()] = mb;

                parent.Add(mb);

                foreach (SimPe.Interfaces.Scenegraph.ICresChildren cld in bl)
                {
                    AddJoint(lmb, cld, mb, tnode.Nodes);
                }
            }
            else
            {
                foreach (SimPe.Interfaces.Scenegraph.ICresChildren cld in bl)
                {
                    AddJoint(lmb, cld, parent, nodes);
                }
            }
        }
        private void populateTreeControl(System.Xml.XmlNode doc, System.Windows.Forms.TreeNodeCollection nodes)
        {
            foreach (System.Xml.XmlNode node in doc.ChildNodes)
            {
                //if the element has a value
                //otherwise display the first attribute
                //(if there is one) or the element
                //(if there isn't)

                string text = (node.Value != null ? node.Value :
                               (node.Attributes != null &&
                                node.Attributes.Count > 0) ?
                               node.Attributes[0].Value : node.Name);
                TreeNode new_child = new TreeNode(text);
                nodes.Add(new_child);
                populateTreeControl(node, new_child.Nodes);
            }
        }
Exemple #43
0
        /**/
        /// <summary>
        /// 递归查询
        /// </summary>
        /// <param name="nodes">TreeView节点集合</param>
        /// <param name="dataSource">数据源</param>
        /// <param name="parentid">上一级菜单节点标识码</param>
        public void CreateTreeViewRecursive(System.Windows.Forms.TreeNodeCollection nodes, DataTable dataSource, int parentid)
        {
            string filter;//定义一个过滤器

            filter = string.Format("PARENTID={0}", parentid);
            DataRow[] drarr = dataSource.Select(filter);//将过滤的ID放入数组中
            TreeNode  node;

            foreach (DataRow dr in drarr)//递归循环查询出数据
            {
                node      = new TreeNode();
                node.Text = dr["NODETEXT"].ToString();
                //node.Name = dr["name"].ToString();
                node.Tag = Convert.ToInt32(dr["ID"]);
                nodes.Add(node);//加入节点
                CreateTreeViewRecursive(node.Nodes, dataSource, Convert.ToInt32(node.Tag));
            }
        }
Exemple #44
0
        private void prepare_node_with_text(syntax_tree_node subnode, string text)
        {
            if (subnode == null)
            {
                return;
            }
            TreeNode tn = new TreeNode();

            tn.Text = text;
            tn.Tag  = subnode;
            string s = get_node_info.node(subnode);

            if (s != null)
            {
                tn.Text += "     " + s;
            }
            //tn.Nodes.Clear();
            visualizator vs = new visualizator(tn.Nodes);

            subnode.visit(vs);
            nodes.Add(tn);
        }
Exemple #45
0
        public void Load(string sPath, System.Windows.Forms.TreeNodeCollection tree)
        {
            string sSetFile = sPath + "\\" + System.IO.Path.GetFileName(sPath) + sSetExtension;

            if (System.IO.File.Exists(sSetFile))
            {
                XmlDocument doc  = XmlUtils.LoadXMLFile(sSetFile);
                XmlNode     root = doc.SelectSingleNode("//set");
                sSetName = root.Attributes["id"].Value;
                TreeNode setNode = null;
                if (tree != null)
                {
                    setNode     = tree.Add(sSetName);
                    setNode.Tag = this;
                }

                XmlNodeList cards = doc.SelectNodes("//card");
                if (cards.Count == 0)
                {
                    setNode.ForeColor = System.Drawing.Color.Red;
                }
                foreach (XmlNode card in cards)
                {
                    string sCardName = card.Attributes["name"].Value;
                    string sCardFile = card.Attributes["path"].Value;
                    Card   oNewCard  = new Card(sCardName, sSetName);
                    oNewCard.ImportFromCard(XmlUtils.LoadXMLFile(sCardFile));
                    if (setNode != null)
                    {
                        TreeNode cardNode = setNode.Nodes.Add(oNewCard.sCardName);
                        cardNode.Tag = oNewCard;
                    }
                    m_lstCards.Add(oNewCard);
                }
            }
            Console.WriteLine(sSetName);
        }
Exemple #46
0
        /// <summary>
        /// This adds a file/folder to the source file structure.
        /// </summary>
        /// <param name="p_tndRoot">The node to which to add the file/folder.</param>
        /// <param name="p_strFile">The path to add to the source file structure.</param>
        public FileSystemTreeNode AddPath(FileSystemTreeNode p_tndRoot, string p_strFile)
        {
            if ((p_tndRoot != null) && !p_tndRoot.IsDirectory && (!BrowseIntoArchives || !p_tndRoot.IsArchive))
            {
                return(AddPath(p_tndRoot.Parent, p_strFile));
            }
            Cursor crsOldCursor = Cursor;

            Cursor = Cursors.WaitCursor;
            try
            {
                if (!Archive.IsArchivePath(p_strFile))
                {
                    FileSystemInfo fsiInfo = null;
                    if (Directory.Exists(p_strFile))
                    {
                        fsiInfo = new DirectoryInfo(p_strFile);
                    }
                    else if (ShowFiles && File.Exists(p_strFile) && !".lnk".Equals(Path.GetExtension(p_strFile), StringComparison.OrdinalIgnoreCase))
                    {
                        fsiInfo = new FileInfo(p_strFile);
                    }
                    else
                    {
                        return(null);
                    }
                    if (!FileUtil.IsDrivePath(p_strFile) && ((fsiInfo.Attributes & FileAttributes.System) > 0))
                    {
                        return(null);
                    }
                }

                FileSystemTreeNode tndFile = null;
                System.Windows.Forms.TreeNodeCollection tncSiblings = (p_tndRoot == null) ? this.Nodes : p_tndRoot.Nodes;
                string strName = Path.GetFileName(p_strFile);
                if (String.IsNullOrEmpty(strName))
                {
                    strName = p_strFile;
                }
                if (tncSiblings.ContainsKey(strName))
                {
                    tndFile = (FileSystemTreeNode)tncSiblings[strName];
                    tndFile.AddSource(p_strFile, false);
                }
                else
                {
                    tndFile      = new FileSystemTreeNode(strName, p_strFile);
                    tndFile.Name = strName;
                    tncSiblings.Add(tndFile);
                    OnNodeAdded(new NodesChangedEventArgs(tndFile));
                }
                SetNodeImage(tndFile);

                if (tndFile.IsDirectory)
                {
                    if (ShouldLoadChildren(tndFile))
                    {
                        LoadChildren(tndFile);
                    }
                }
                else
                {
                    if (BrowseIntoArchives && tndFile.IsArchive)
                    {
                        if (ShouldLoadChildren(tndFile))
                        {
                            LoadChildren(tndFile);
                        }
                    }
                    else
                    {
                        tndFile.Sources[p_strFile].IsLoaded = true;
                    }
                }
                return(tndFile);
            }
            finally
            {
                Cursor = crsOldCursor;
            }
        }
Exemple #47
0
        void AddFunction(System.Windows.Forms.TreeNodeCollection nodes, SimPe.PackedFiles.Wrapper.ObjLuaFunction fkt)
        {
            TreeNode tn = new TreeNode(fkt.ToString());

            tn.Tag = fkt;
            nodes.Add(tn);

            TreeNode ctn = new TreeNode("Constants");

            tn.Nodes.Add(ctn);
            foreach (SimPe.PackedFiles.Wrapper.ObjLuaConstant olc in fkt.Constants)
            {
                TreeNode sctn = new TreeNode(olc.ToString());
                sctn.Tag = olc;

                ctn.Nodes.Add(sctn);
            }

            TreeNode cltn = new TreeNode("Locals");

            tn.Nodes.Add(cltn);
            int ct = 0;

            foreach (SimPe.PackedFiles.Wrapper.ObjLuaLocalVar c in fkt.Locals)
            {
                TreeNode scltn = new TreeNode(Helper.HexString(ct++) + ": " + c.ToString());
                scltn.Tag = c;

                cltn.Nodes.Add(scltn);
            }

            TreeNode cutn = new TreeNode("UpValues");

            tn.Nodes.Add(cutn);
            ct = 0;
            foreach (SimPe.PackedFiles.Wrapper.ObjLuaUpValue c in fkt.UpValues)
            {
                TreeNode scutn = new TreeNode(Helper.HexString(ct++) + ": " + c.ToString());
                scutn.Tag = c;

                cutn.Nodes.Add(scutn);
            }

            TreeNode cstn = new TreeNode("SourceLines");

            tn.Nodes.Add(cstn);
            ct = 0;
            foreach (SimPe.PackedFiles.Wrapper.ObjLuaSourceLine c in fkt.SourceLine)
            {
                TreeNode scstn = new TreeNode(Helper.HexString(ct++) + ": " + c.ToString());
                scstn.Tag = c;

                cstn.Nodes.Add(scstn);
            }

            TreeNode ftn = new TreeNode("Functions");

            tn.Nodes.Add(ftn);
            foreach (SimPe.PackedFiles.Wrapper.ObjLuaFunction olf in fkt.Functions)
            {
                AddFunction(ftn.Nodes, olf);
            }


            TreeNode cdtn = new TreeNode("Instructions");

            tn.Nodes.Add(cdtn);
            ct = 0;
            foreach (SimPe.PackedFiles.Wrapper.ObjLuaCode c in fkt.Codes)
            {
                TreeNode scdtn = new TreeNode(Helper.HexString(ct++) + ": " + c.ToString());
                scdtn.Tag = c;

                cdtn.Nodes.Add(scdtn);
            }
        }