public void launchGui()
		{
			var astData = new O2MappedAstData();
			astData.loadFiles(@"C:\O2\DemoData\HacmeBank_v2.0 (Dinis version - 7 Dec 08)\HacmeBank_v2_WS\classes".files());
			
			var control = O2Gui.open<Panel>("test ascx_WriteRule",700,500);
			var writeRule = control.add_Control<ascx_WriteRule>();
			
			writeRule.buildGui(astData); 			
		}
		public void buildGui()
		{		
			var topPanel = this;
			CodeViewer = topPanel.add_SourceCodeViewer();   
			DataTreeView = CodeViewer.insert_Left<TreeView>(200).showSelection().sort();     
			Options = DataTreeView.insert_Below<Panel>(40); 
			Options.add_CheckBox("View AST",0,0,(value)=> { this.Show_Ast = value;}).check();
			Options.add_CheckBox("View CodeDom",0,95,(value)=> {this.Show_CodeDom = value; }).front();
			Options.add_CheckBox("View NRefactory",20,0,(value)=> {this.Show_NRefactory = value;}).front().autoSize();

			DataTreeView.showSelection();	
			DataTreeView.configureTreeViewForCodeDomViewAndNRefactoryDom();
			AstData.afterSelect_ShowInSourceCodeEditor(DataTreeView, CodeViewer.editor());  

			DataTreeView.onDrop(
				(fileOrFolder)=>{
									DataTreeView.backColor(Color.LightPink);
									O2Thread.mtaThread(
										()=>{
												AstData.dispose();
												AstData = new O2MappedAstData();
												if (fileOrFolder.fileExists())
													AstData.loadFile(fileOrFolder);
												else
													AstData.loadFiles(fileOrFolder.files("*.cs",true));
												loadDataInGui();
												DataTreeView.backColor(Color.White);
											 });									
								});
			DataTreeView.afterSelect<string>(
				(file)=>{
						if (file.fileExists())
							CodeViewer.open(file);
						});
			
			
			DataTreeView.beforeExpand<CompilationUnit>(
				(compilationUnit)=>{																	
										var treeNode = DataTreeView.selected();																									
										treeNode.clear();	           
																			
										if (Show_Ast)
										{										
											if (compilationUnit!=null) 
												treeNode.add_Node("AST",null)
		            									.show_Ast(compilationUnit)
		            									.show_Asts(compilationUnit.types(true))
		            									.show_Asts(compilationUnit.methods());
							                		//treeNode.show_Ast(compilationUnit);
							             }
							        
							            if (Show_CodeDom)
							            {
								            var codeNamespace = AstData.MapAstToDom.CompilationUnitToNameSpaces[compilationUnit];
							            	var domNode = treeNode.add_Node("CodeDom");
	            							domNode.add_Node("CodeNamespaces").show_CodeDom(codeNamespace);
											domNode.add_Node("CodeTypeDeclarations").show_CodeDom(AstData.codeTypeDeclarations());
	            							domNode.add_Node("CodeMemberMethods").show_CodeDom(AstData.codeMemberMethods());
	            							//domNode.add_Node("CodeMemberMethods").show_CodeDom(o2MappedAstData.codeMemberMethods());
							            }
							            if (Show_NRefactory)
							            {
							            	var iCompilationUnit = AstData.MapAstToNRefactory.CompilationUnitToICompilationUnit[compilationUnit];
							            	treeNode.add_Node("NRefactory")
							            		    .add_Nodes_WithPropertiesAsChildNodes<ICompilationUnit>(iCompilationUnit);
	                                           //.show_NRefactoryDom(o2MappedAstData.iClasses())
	                                           //.show_NRefactoryDom(o2MappedAstData.iMethods());
	
							            }
							
					    });				

		}
		public void build_CreateAllMethodStreamsTab(Control hostControl)
		{	
			var allMethodStreamsPanel = hostControl.add_1x1("Options","All Method Streams",false,50); 
			
			var sourceCode = allMethodStreamsPanel[1].add_SourceCodeViewer();//add_MethodStreamViewer();
			var treeView = sourceCode.insert_Left<TreeView>(300)
									 .showSelection()
									 .sort()
									 .afterSelect<string>(
									 	(filePath)=>sourceCode.open(filePath));
			
			var targerFolder = PublicDI.config.getTempFolderInTempDirectory("_AllMethodStreams");
			allMethodStreamsPanel[0].parent<SplitContainer>().borderNone();
			var optionsPanel = allMethodStreamsPanel[0].parent().clear();
			var progressBar = optionsPanel.add_ProgressBar(25,0).align_Right(optionsPanel);
			optionsPanel.add_LabelAndTextAndButton("Target Directory", targerFolder,"Create",
				(text)=>{
							AstData.createAllMethodsStreams(text, progressBar, null);
							foreach(var file in targerFolder.files())
								treeView.add_Node(file.fileName(), file);
							treeView.selectFirst();
						});
			
			progressBar.onDrop(
				(fileOrFolder)=>{
									if (fileOrFolder.fileExists())
										AstData.loadFile(fileOrFolder);
									else
									{
										AstData.dispose();
										AstData = new O2MappedAstData();									
										AstData.loadFiles(fileOrFolder.files("*.cs",true));
									}
								});
			//tabPages.Add(tabControl.add_Tab("Step 2: Create Code Streams"));
			//tabPages.Add(tabControl.add_Tab("Step 1: Create Final Findings"));
			
			
			//Create all Method Streams
			
			
			//var controls = tabPages;
			//var MethodStreamPanel  = controls[0].add_1x1("Current ","MethodStreams", false);
			
			/*
			var CodeStreamPanel = controls[1].add_1x1("Create CodeStreams", "CodeStreams", false); 
			var FindingsPanel = controls[2].add_1x1("Create Findings", "Final Findings",false);
			
			// MethodStreamPanel  
			MethodStreamScript = MethodStreamPanel[0].add_Script(false);   
			MethodStreamViewer = MethodStreamPanel[1].add_MethodStreamViewer();	
							
			//CodeStreamPanel    
			CodeStreamScript = CodeStreamPanel[0].add_Script(false);  
			var CodeStreamScriptResult = CodeStreamPanel[1].add_1x1("Code Streams", "Raw Findings", true, CodeStreamScript.width()/2);
			
			CodeStreamViewer =  CodeStreamScriptResult[0].add_CodeStreamViewer();   
			RawFindingsViewer = CodeStreamScriptResult[1].add_FindingsViewer();
			
			
			//RawFindingsViewer = FindingsPanel[1].add_FindingsViewer();				
			//CodeStreamViewer = MethodStreamPanel[1].add_CodeStreamViewer();   
			
			
			// FindingsPanel
			FindingsScript = FindingsPanel[0].add_Script(false);				
			FinalFindingsViewer = FindingsPanel[1].add_FindingsViewer();
			
			//var controls2 = host[1].add_1x1x1(true);  

			// extra vars
							
			// script parameters				
			var scriptParameters = new Dictionary<string,object>(); 				
			scriptParameters.Add("methodStreamViewer", MethodStreamViewer);  
			scriptParameters.Add("codeStreamViewer", CodeStreamViewer); 
			
			scriptParameters.Add("rawFindingsViewer", RawFindingsViewer); 
			scriptParameters.Add("finalFindingsViewer", FinalFindingsViewer); 
			
			scriptParameters.Add("astData", AstData); 				
			
			MethodStreamScript.InvocationParameters.AddRange(scriptParameters);				
			CodeStreamScript.InvocationParameters.AddRange(scriptParameters);
			FindingsScript.InvocationParameters.AddRange(scriptParameters);

			*/
		}