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);
        }
		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();
								colorCodePaths(_codeEditor.editor(), codeStreamPaths);   
							}
							else
								refresh_AllCodeStreams_TreeView();
								
								
							
						}
					});
				return this;
		}