public void buildGui()
        {
            var topPanel = this.add_Panel();
            Path = topPanel.insert_Above<TextBox>(20);
            sourceCode = topPanel.add_SourceCodeEditor();
            dataGridView = sourceCode.insert_Above<Panel>(100).add_DataGridView();
            leftPanel = topPanel.insert_Left<Panel>(300);

            Path.onEnter(loadFiles);
            Path.onDrop(
                (fileOrFolder)=>{
                                    Path.set_Text(fileOrFolder);
                                    loadFiles(fileOrFolder);
                                });
            dataGridView.SelectionChanged+=
                (sender,e) => {
                        if (dataGridView.SelectedRows.size() == 1)
                        {
                            var selectedRow = dataGridView.SelectedRows[0];
                            var filePath = selectedRow.Cells[0].Value.str();
                            var filename = selectedRow.Cells[1].Value.str();
                            var lineNumber = selectedRow.Cells[2].Value.str();
                            "opening up source code: {0}".info(filePath);
                            sourceCode.open(filePath.pathCombine(filename));
                            sourceCode.gotoLine(lineNumber.toInt() + 1);
                            dataGridView.focus();
                        }
                  };
        }
Beispiel #2
0
        public void buildGui()
        {
            var topPanel = this.add_Panel();

            Path         = topPanel.insert_Above <TextBox>(20);
            sourceCode   = topPanel.add_SourceCodeEditor();
            dataGridView = sourceCode.insert_Above <Panel>(100).add_DataGridView();
            leftPanel    = topPanel.insert_Left <Panel>(300);

            Path.onEnter(loadFiles);
            Path.onDrop(
                (fileOrFolder) => {
                Path.set_Text(fileOrFolder);
                loadFiles(fileOrFolder);
            });
            dataGridView.SelectionChanged +=
                (sender, e) => {
                if (dataGridView.SelectedRows.size() == 1)
                {
                    var selectedRow = dataGridView.SelectedRows[0];
                    var filePath    = selectedRow.Cells[0].Value.str();
                    var filename    = selectedRow.Cells[1].Value.str();
                    var lineNumber  = selectedRow.Cells[2].Value.str();
                    "opening up source code: {0}".info(filePath);
                    sourceCode.open(filePath.pathCombine(filename));
                    sourceCode.gotoLine(lineNumber.toInt() + 1);
                    dataGridView.focus();
                }
            };
        }
     public void InitializeComponent()
     {
     	var splitControl = this.add_SplitContainer(
     						false, 		//setOrientationToHorizontal
     						true,		// setDockStyleoFill
     						true);		// setBorderStyleTo3D)
     	var leftGroupBox = splitControl.Panel1.add_GroupBox("Methods");
         //var rightGroupBox = splitControl.Panel2.add_GroupBox("SourceCode");
         tvDirectoriesAndFiles = leftGroupBox.add_TreeView();
         tvDirectoriesAndFiles.AfterSelect += tvDirectoriesAndFiles_AfterSelect;
         tvDirectoriesAndFiles.AllowDrop = true;
         tvDirectoriesAndFiles.DragEnter += tvDirectoriesAndFiles_DragEnter;
         tvDirectoriesAndFiles.DragDrop += tvDirectoriesAndFiles_DragDrop;                        
         
         var rightSplitControl = splitControl.Panel2.add_SplitContainer(
     						true, 		//setOrientationToHorizontal
     						true,		// setDockStyleoFill
     						true);		// setBorderStyleTo3D)
         
         var topGroupBox = rightSplitControl.Panel1.add_GroupBox("SourceCode");
         var bottomGroupBox = rightSplitControl.Panel2.add_GroupBox("ControlFlowGraph");
         sourceCodeEditor = topGroupBox.add_SourceCodeEditor();
         tvControlFlowGraph = bottomGroupBox.add_TreeView();
         tvControlFlowGraph.BeforeExpand += tvDirectoriesAndFiles_BeforeExpand;
         // set-up size
         this.Width = 500;
         this.Height = 700;     
         leftGroupBox.Width = 400;
         //splitControl.Panel1.Width=300;
 	}
 public static O2CodeStream show(this O2CodeStream o2CodeStream, SourceCodeEditor codeEditor)
 {
     if (o2CodeStream != null)
     {
         codeEditor.open(o2CodeStream.SourceFile);
         codeEditor.colorINodes(o2CodeStream.iNodes());
     }
     return o2CodeStream;
 }
Beispiel #5
0
        private void loadSourceCodeFileIntoTab(string fileToOpen, TabPage tabPage, bool compileLoadedFile)
        {
            var sourceCodeEditor = new SourceCodeEditor();

            sourceCodeEditor.Dock = DockStyle.Fill;
            tabPage.Controls.Add(sourceCodeEditor);
            sourceCodeEditor.loadSourceCodeFile(fileToOpen.Trim());
            if (compileLoadedFile)
            {
                sourceCodeEditor.compileSourceCode();
            }
        }
 public static SourceCodeEditor add_SourceCodeEditor(this Control control)
 {
     return control.invokeOnThread(
         () =>
             {
                 var sourceCodeEditor = new SourceCodeEditor();
                 sourceCodeEditor.getObject_TextEditorControl().Document.
                                  FormattingStrategy = new DefaultFormattingStrategy();
                 sourceCodeEditor.Dock = DockStyle.Fill;
                 control.Controls.Add(sourceCodeEditor);
                 return sourceCodeEditor;
             });
 }
 public static TreeView afterSelect_ShowAstInSourceCodeEditor(this TreeView treeView, SourceCodeEditor codeEditor)
 {
     return (TreeView)codeEditor.invokeOnThread(() =>
     {
         treeView.afterSelect<AstTreeView.ElementNode>((node) =>
         {
             var element = (INode)node.field("element");
             codeEditor.setSelectionText(element.StartLocation, element.EndLocation);
         });
         treeView.afterSelect<INode>((node) =>
         {
             codeEditor.setSelectionText(node.StartLocation, node.EndLocation);
         });
         return treeView;
     });
 }
 public void SetUp()
 {
     CodeEditor = Default_Helpers.CSharpFile_HelloWord
                                 .open_InCodeEditor();
 }
		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;
		}
 private static void loadFileAndSelectText(SourceCodeEditor sourceCodeEditor, IM_FileOrFolderSelected fileOrFolderSelectedMessage)
 {
     sourceCodeEditor.loadSourceCodeFile(fileOrFolderSelectedMessage.pathToFileOrFolder);
     sourceCodeEditor.setSelectedText(fileOrFolderSelectedMessage.lineNumber,
                                      fileOrFolderSelectedMessage.columnNumber,
                                      fileOrFolderSelectedMessage.showAsError);
 }
 private static void loadFileAndSelectLine(SourceCodeEditor sourceCodeEditor, IM_FileOrFolderSelected fileOrFolderSelectedMessage)
 {
     sourceCodeEditor.loadSourceCodeFile(fileOrFolderSelectedMessage.pathToFileOrFolder);
     sourceCodeEditor.setSelectedLineNumber(fileOrFolderSelectedMessage.lineNumber);
 }
		public static ascx_TraceTreeView afterSelect_ShowTraceInCodeEditor(this ascx_TraceTreeView traceViewer , SourceCodeEditor codeEditor)
		{
			traceViewer._onTraceSelected += 
				(o2Trace)=>{
								codeEditor.show(o2Trace);
								Application.DoEvents();
								traceViewer.focus();
						   };
			return traceViewer;
		}
        public static ascx_FindingsViewer set_CodeEditor(this ascx_FindingsViewer findingsViewer, SourceCodeEditor codeEditor)
        {
        	findingsViewer._onTraceSelected += 
					(trace)=>{
									codeEditor.show(trace);
									findingsViewer.controls<ascx_TraceTreeView>().focus();
							 };
				findingsViewer._onFindingSelected +=
					(finding)=> { 				
									findingsViewer.invokeOnThread(
										()=>{
												codeEditor.textEditor().LineViewerStyle = ICSharpCode.TextEditor.Document.LineViewerStyle.None;												
												codeEditor.open(finding.file);											
												//"Going to line: {0}".info(finding.lineNumber);																					
												codeEditor.editor().gotoLine((int)finding.lineNumber);														
											});									
									O2Thread.mtaThread(
										()=>{
												findingsViewer.sleep(100,false);												
												findingsViewer.getResultsTreeView().focus();												
											});
								};
			return 	findingsViewer;							
        }
Beispiel #14
0
 public void reloadFile(SourceCodeEditor sourceCodeEditor)
 {
     sourceCodeEditor.reloadCurrentFile();
 }