当前位置: 首页>>代码示例>>C#>>正文


C# TreeView.add_Node方法代码示例

本文整理汇总了C#中System.Windows.Forms.TreeView.add_Node方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.add_Node方法的具体用法?C# TreeView.add_Node怎么用?C# TreeView.add_Node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TreeView的用法示例。


在下文中一共展示了TreeView.add_Node方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: showInTreeView

        public static void showInTreeView(this MethodMappings methodMappings, TreeView treeView, string filter, bool showSourceCodeSnippets, bool onlyShowSourceCodeLine)
        {
            treeView.parent().backColor("LightPink");
            treeView.visible(false);
            treeView.clear();
            var indexedMappings = methodMappings.indexedByKey(filter);
            if (onlyShowSourceCodeLine)
            {
                //do this so that we don't add more than one item per line
                var indexedByFileAndLine = new Dictionary<string, MethodMapping>();

                foreach(var item in indexedMappings)
                    foreach(var methodMapping in item.Value)
                        if (methodMapping.File.valid())
                        {
                            var key = "{0}_{1}".format(methodMapping.File, methodMapping.Start_Line);
                            indexedByFileAndLine.add(key, methodMapping);
                        }
                // now group then by the same text in the SourceCodeLine
                var indexedBySourceCodeLine =  new Dictionary<string, List<MethodMapping>>();
                foreach(var methodMapping in indexedByFileAndLine.Values)
                    indexedBySourceCodeLine.add(methodMapping.sourceCodeLine(), methodMapping);

                //Finally show then
                foreach(var item  in indexedBySourceCodeLine)
                {
                    var uniqueTextNode = treeView.add_Node(item.Key, item.Value,true);
                }
            }
            else
            {
                foreach(var item in indexedMappings)
                {
                    var keyNodeText = "{0}                       ({1})".format(item.Key, item.Value.size());
                    var keyNode= treeView.add_Node(keyNodeText, item.Value,true);
                }
                treeView.afterSelect<List<MethodMapping>>(
                    (mappings)=>{
                                    var keyNode = treeView.selected();
                                    keyNode.clear();
                                    foreach(var methodMapping in mappings)
                                    {
                                        var nodeText = (showSourceCodeSnippets)
                                            ? methodMapping.sourceCodeLine()
                                            : "{0} - {1}".format(methodMapping.INodeType,methodMapping.SourceCode);
                                        keyNode.add_Node(nodeText, methodMapping);
                                    }
                    });
            }
            treeView.parent().backColor("Control");
            treeView.visible(true);
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:52,代码来源:MethodMappings_ExtensionMethods_GUI.cs

示例2: mapFoldersAndFiles

 public void mapFoldersAndFiles(TreeView targetTreeView, TreeNode treeNode)
 {
     targetTreeView.clear(treeNode);
     var folder = treeNode.Tag.ToString();
     foreach (var dir in folder.dirs())
         if (dir.contains(".git").isFalse())
             targetTreeView.add_Node(treeNode, dir.fileName(), dir, true)
                 .ForeColor = Color.SaddleBrown;
     foreach (var file in folder.files())
         targetTreeView.add_Node(treeNode, file.fileName(), file, false)
             .ForeColor = Color.DarkBlue;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:12,代码来源:ascx_Execute_Scripts.cs

示例3: buildGui

		public ascx_CodeStreams buildGui() 
		{
			//codeViewer = this.add_SourceCodeViewer();
			_codeEditor = this.add_SourceCodeEditor();
			codeStreams = _codeEditor.insert_Right().add_GroupBox("All Code Streams").add_TreeView();
			codeStreamViewer = codeStreams.parent().insert_Below().add_GroupBox("Selected Code Stream").add_TreeView(); 
			//var codeStreamViewer = topPanel.insert_Right().add_TreeView();
			
			Action<TreeNode, CodeStreamPath> add_CodeStreamPath = null;
			
			add_CodeStreamPath = 
				(treeNode, codeStreamPath)=>{
												var newNode = treeNode.add_Node(codeStreamPath);
												foreach(var childPath in codeStreamPath.CodeStreamPaths)
													add_CodeStreamPath(newNode, childPath);
											};
											
			Action<TreeView, CodeStreamPath> showCodeStreamPath= 
				(treeView, codeStreamPath)=>{																		
												treeView.clear(); 
												add_CodeStreamPath(treeView.rootNode(), codeStreamPath);
												treeView.expandAll();
												treeView.selectFirst();
											};
			
			Action<SourceCodeEditor, CodeStreamPath, bool> colorCodePath = 
				(codeEditor, codeStreamPath, clearMarkers)=>
					{												
						if (codeEditor.getSourceCode().inValid() || codeStreamPath.Line == 0 && codeStreamPath.Column ==0)
							return;						
						try
						{
							if (clearMarkers)
							{
								codeEditor.clearMarkers(); 								
								codeEditor.caret(codeStreamPath.Line,codeStreamPath.Column);
							}
							codeEditor.selectTextWithColor( codeStreamPath.Line,
															codeStreamPath.Column,
															codeStreamPath.Line_End,
															codeStreamPath.Column_End);
							codeEditor.refresh(); 										
						}
						catch(Exception ex)
						{
							ex.log();
						}					
				  	};
			
			Action<SourceCodeEditor, List<CodeStreamPath>> colorCodePaths = 
				(codeEditor, codeStreamPaths)=> {
													foreach(var codeStreamPath in codeStreamPaths)
														colorCodePath(codeEditor, codeStreamPath,false); 
											    };
				
			Action<TreeView,SourceCodeEditor> set_AfterSelect_SyncWithCodeEditor = 
				(treeView, codeEditor)=>{
								treeView.afterSelect<CodeStreamPath>(
										(codeStreamPath)=> colorCodePath(codeEditor, codeStreamPath,true ) );
			
							};
			
			
			set_AfterSelect_SyncWithCodeEditor(codeStreams, _codeEditor.editor()); 
			set_AfterSelect_SyncWithCodeEditor(codeStreamViewer, _codeEditor.editor());
			
			codeStreams.afterSelect<CodeStreamPath>(
				(codeStreamPath)=> showCodeStreamPath(codeStreamViewer, codeStreamPath));											
					
			
			codeStreams.beforeExpand<CodeStreamPath>(
				(treeNode, codeStreamPath)=>{
												treeNode.add_Nodes(codeStreamPath.CodeStreamPaths, (codeStream) => codeStream.CodeStreamPaths.size() > 0 );
											});
			
			
			_codeEditor.onClick(
				()=>{ 
						if (savedMethodStream.notNull())
						{	
							_codeEditor.editor().clearMarkers();  
							codeStreamViewer.clear();
							codeStreams.clear();
							var line = _codeEditor.caret().Line + 1; 				
							var column = _codeEditor.caret().Column + 1;  							
							CodeStreamPath lastMatch = null;
							foreach(var codeStreamPath in savedMethodStream.CodeStreams)
							{
								if (codeStreamPath.Line <= line && codeStreamPath.Line_End >= line &&
								    codeStreamPath.Column <= column && codeStreamPath.Column_End >= column)
								    {
								    	codeStreams.add_Node(codeStreamPath);
										lastMatch = codeStreamPath;																									
									}
							}
							if (lastMatch.notNull())
							{								
								showCodeStreamPath(codeStreamViewer, lastMatch);
								var codeStreamPaths = (from node in codeStreamViewer.allNodes() 
													   select (CodeStreamPath)node.get_Tag()).toList();
//.........这里部分代码省略.........
开发者ID:jobyjames85,项目名称:O2.Platform.Scripts,代码行数:101,代码来源:ascx_CodeStreams.cs

示例4: populateTreeViewUsingViewMode_byFunctionSignature

        private static Thread populateTreeViewUsingViewMode_byFunctionSignature(IEnumerable<string> lsList,
                                                                       TreeView targetTreeView,
                                                                       int namespaceDepthValue, string textFilter, int iMaxItemsToShow)
        {
            return O2Thread.mtaThread(
                () =>
                {
                    targetTreeView.invokeOnThread(() => targetTreeView.Visible = false);
                    try
                    {
                        var dItemsParsed = new Dictionary<String, FilteredSignature>();
                        foreach (String sItem in lsList)
                        {
                            //if (false == dItemsParsed.ContainsKey(sItem))
                            {
                                if (textFilter == "" || RegEx.findStringInString(sItem, textFilter))
                                    dItemsParsed.Add(sItem, new FilteredSignature(sItem));
                            }
                            //else
                            //    PublicDI.log.error("Something's wrong in showListOnTreeView, lsList had repeated key:{0}", sItem);
                        }
                        var dItemsBrokenByClassDepth = new Dictionary<String, List<FilteredSignature>>();

                        foreach (String sItem in lsList)
                        {

                            if (namespaceDepthValue == -1)
                            {
                                if (textFilter == "" || RegEx.findStringInString(sItem, textFilter))
                                    if (dItemsParsed.ContainsKey(sItem))
                                        // add node ASync and on the correct thread
                                        O2Forms.addNodeToTreeNodeCollection(targetTreeView, targetTreeView.Nodes,
                                                                  O2Forms.newTreeNode(
                                                                      dItemsParsed[sItem].sSignature, sItem,
                                                                      3, dItemsParsed[sItem]), iMaxItemsToShow);
                            }
                            else
                            {
                                if (dItemsParsed.ContainsKey(sItem))
                                {
                                    String sClassNameToShow =
                                        dItemsParsed[sItem].getClassName_Rev(namespaceDepthValue);
                                    if (sClassNameToShow == "")
                                        sClassNameToShow = dItemsParsed[sItem].sFunctionClass;
                                    /*  var sClassNameToConsolidate = (sClassNameToShow == "")
                                                                 ? dItemsParsed[sItem].sFunctionClass
                                                                 : dItemsParsed[sItem].sFunctionClass.Replace(
                                                                       sClassNameToShow, "");*/
                                    if (false == dItemsBrokenByClassDepth.ContainsKey(sClassNameToShow))
                                        dItemsBrokenByClassDepth.Add(sClassNameToShow, new List<FilteredSignature>());
                                    //String sSignatureToShow = sClassNameToConsolidate + "__" + dItemsParsed[sItem].sFunctionNameAndParams;
                                    dItemsBrokenByClassDepth[sClassNameToShow].Add(dItemsParsed[sItem]);
                                }
                            }

                            // add calculated results 
                            //     TreeNodeCollection tncToAddFunction_ = targetTreeView.Nodes;
                        }
                            foreach (String sClass in dItemsBrokenByClassDepth.Keys)
                            {
                                var filteredSignatures = dItemsBrokenByClassDepth[sClass];
                                TreeNode tnNewTreeNode = O2Forms.newTreeNode(sClass, sClass, 0,
                                                                             filteredSignatures);
                                if (filteredSignatures.Count > 0)
                                    tnNewTreeNode.Nodes.Add("DummyNode");
                                // add node ASync and on the correct thread
                                O2Forms.addNodeToTreeNodeCollection(targetTreeView, targetTreeView.Nodes, tnNewTreeNode, iMaxItemsToShow);
                                //tncToAddFunction.Add(tnNewTreeNode);


                            }


                            // remove empty nodes

                            /*       if (false && bRemoveEmptyRootNodes && NamespaceDepthValue > -1)
                    {
                        var tnTreeNodesToRemove = new List<TreeNode>();
                        foreach (TreeNode tnTreeNode in tvTempTreeView.Nodes)
                            if (tnTreeNode.Nodes.Count == 0)
                                tnTreeNodesToRemove.Add(tnTreeNode);
                        foreach (TreeNode tnTreeNode in tnTreeNodesToRemove)
                            tvTempTreeView.Nodes.Remove(tnTreeNode);
                    }*/
                        

                        var numberOfUniqueStrings = lsList.Count();
                        if (numberOfUniqueStrings > iMaxItemsToShow)
                        {
                            var message = string.Format("This view has more items that the current MaxToView. only showing the first {0} out of {1}", iMaxItemsToShow, numberOfUniqueStrings);
                            PublicDI.log.error(message);
                            targetTreeView.add_Node(message);                            
                        }
                    }
                    catch (Exception ex)
                    {
                        PublicDI.log.error("in populateTreeViewUsingViewMode_byFunctionSignature: {0}", ex.Message);
                    }

                    targetTreeView.invokeOnThread(
//.........这里部分代码省略.........
开发者ID:SiGhTfOrbACQ,项目名称:O2.FluentSharp,代码行数:101,代码来源:ascx_FunctionsViewer.Controllers.cs

示例5: showFilteredHtmlContentInTreeView

    	public static string showFilteredHtmlContentInTreeView(this string htmlCode, string filter, TreeView htmlTags_TreeView, TextBox htmlNodeFilter)
    	{
    		htmlTags_TreeView.clear();
			try
			{
				">showing htmlcode with size: {0}".info(htmlCode.size());
				htmlNodeFilter.backColor(Color.White);
				var htmlDocument = htmlCode.htmlDocument();  	
				if (filter.valid())
					htmlTags_TreeView.add_Nodes(htmlDocument.select(filter));
				else 
				{
					htmlTags_TreeView.add_Node(htmlDocument);
					htmlTags_TreeView.expand();
				}
				"HtmlTags_TreeView nodes: {0}".info(htmlTags_TreeView.nodes().size());
				
			}
			catch(System.Exception ex)
			{
				ex.log("in htmlNodeFilter.onEnter");
				htmlNodeFilter.backColor(Color.Red);
			} 			
			htmlTags_TreeView.applyPathFor_1NodeMissingNodeBug(); 
			return htmlCode;
    	}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Scripts,代码行数:26,代码来源:HtmlAgilityPack_ExtensionMethods.cs

示例6: buildGui

		//bool putJavaScriptCodeViewerOnTheLeft,
		public ascx_Javascript_AST buildGui( bool addUrlLoadTextBox)
		{
			var mainGui = this.add_1x1("Files or ScriptBlocks","Javascript Source (you can edit this code and see the results in realtime)");
			var splitContainer = this.controls<SplitContainer>();
			if (addUrlLoadTextBox)			
			{
				showJavascriptsFromUrl = 
				splitContainer.insert_Above<Panel>(25)
							  .add_LabelAndComboBoxAndButton("Enter Url to load Javascripts","","Open",  loadJavascriptsFromUrl)
							  .controls<ComboBox>();								  
			}
			/*if (putJavaScriptCodeViewerOnTheLeft)
			{				
				splitContainer.splitterDistance(this.width()/3);
				javascriptCode = mainGui[1].add_TreeView().showSelection().sort();
				sourceCode = mainGui[0].add_SourceCodeViewer(); 				
			}
			else			
			{*/
				javascriptCode = mainGui[0].add_TreeView().showSelection().sort();
				sourceCode = mainGui[1].add_SourceCodeViewer(); 
			//}
			pagesVisited = javascriptCode.insert_Above<ComboBox>(25).dropDownList();
			
			codeSnippet = sourceCode.insert_Below<TextBox>(100).multiLine().scrollBars(); 
			tabControl  = javascriptCode.insert_Below<TabControl>();
			
			jsAST = tabControl.add_Tab("Javascript - View Ast Tree")
								  .add_TreeView()
								  .showSelection();
								  
			jsFunctions = tabControl.add_Tab("JScript: Functions")
								  		.add_TreeView()
								  		.showSelection()
								  		.sort();
			
			jsIdentifiers = tabControl.add_Tab("JScript: Identifiers")
								  		  .add_TreeView()
								  		  .showSelection()
								  		  .sort();

			jsValues = tabControl.add_Tab("JScript: Values")
								  	 .add_TreeView()
								  	 .showSelection()
								  	 .sort();
								  		
			
			allAST = tabControl.add_Tab("Javascript - View Ast Elements")					    
								   .add_TreeView()
								   .showSelection()
								   .sort();
			
			var searchTab = tabControl.add_Tab("Search in Code")
									  .add_LabelAndComboBoxAndButton("search for (case sensitive)","","show",
									  	(text)=> {
									  				sourceCode.editor().invoke("searchForTextInTextEditor_findNext", text);
									  			 });
									  					  
			//tabControl.select_Tab(searchTab);
			javaScriptLoadMessage = javascriptCode.insert_Below<Panel>(20);
													  
			allAST.insert_Below<Panel>(25)
				  .add_CheckBox("Render this view (some performace impact on large scripts)", 0,0, 
				  		(value)=>{
				  					RenderViewAstElementsTreeView = value;
				  					processJavascript();
				  				 })
				  .autoSize(); 
				  
				  
			allAST.jint_configure_showSelectionDetails(sourceCode, codeSnippet); 
			jsFunctions.jint_configure_showSelectionDetails(sourceCode, codeSnippet); 
			jsIdentifiers.jint_configure_showSelectionDetails(sourceCode, codeSnippet); 
			jsValues.jint_configure_showSelectionDetails(sourceCode, codeSnippet); 

			javascriptCode.afterSelect<string>(
				(jsCode) => {
								sourceCode.editor().clearBookmarksAndMarkers();
								sourceCode.set_Text(jsCode,"*.js");
								sourceCode.editor().refresh(); 
							});
			
			sourceCode.onTextChanged(processJavascript);
			
			pagesVisited.onSelection<IE_HtmlPage>(
				(htmlPage)=>{
								var allScriptsCompiledOk = javascriptCode.populateWithHtmlPageScripts(htmlPage);
								javascriptCode.add_Node("zzz [Original Html Code for: {0}]".format(htmlPage.PageUri.str()),htmlPage.PageSource);
								handleCompilationResult(allScriptsCompiledOk);								
							});
							
			pagesVisited.onSelection<Jint_Wrapper>(
				(jintWrapper)=>{									
									var allScriptsCompiledOk = javascriptCode.populateWithHtmlPageScripts(jintWrapper.JavaScripts);
									javascriptCode.add_Node("zzz_[Original Code for: {0}]".format(jintWrapper.Uri.str()),jintWrapper.Html);
									handleCompilationResult(allScriptsCompiledOk);
							   });
			
			javascriptCode.onDrop(
//.........这里部分代码省略.........
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:101,代码来源:ascx_Javascript_AST.cs


注:本文中的System.Windows.Forms.TreeView.add_Node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。