public ascx_FolderView buildGui()
        {
            var topPanel = this.clear().add_Panel();

            CodeViewer = topPanel.title(Title_CodeEditor).add_SourceCodeViewer();
            FolderView = topPanel.insert_Left(SplitterDistance, Title_FolderView).add_TreeView();

            FolderView.afterSelect <string>(
                (fileOrFolder) => {
                if (fileOrFolder.fileExists())
                {
                    CodeViewer.open(fileOrFolder);
                }
            });

            FolderView.beforeExpand <string>((treeNode, path) => loadFolder(treeNode, path));

            FolderView.onDrop((fileOrfolder) => {
                FolderView.clear();
                if (fileOrfolder.dirExists())
                {
                    loadFolder(FolderView.rootNode(), fileOrfolder);
                }
            });
            FolderView.add_ContextMenu()
            .add_MenuItem("Refresh", true, () => refresh())
            .add_MenuItem("Open in Windows Explorer",
                          () => FolderView.selected().get_Tag().str().startProcess());

            CodeViewer.set_Text("....select file on the left to view its contents here...");
            return(this);
        }
Exemple #2
0
            public void createMethodStream(IMethod iMethod)
            {
                MethodStream     = AstEngine.AstData.createO2MethodStream(iMethod);
                MethodStreamFile = MethodStream.csharpCode().saveWithExtension(".cs");

                CodeViewer.open(MethodStreamFile);
                CodeStreamCodeViewer.open(MethodStreamFile);
                if (AstData_MethodStream.notNull())
                {
                    AstData_MethodStream.Dispose();
                }
                AstData_MethodStream = new O2MappedAstData();
                AstData_MethodStream.loadFile(MethodStreamFile);
            }
Exemple #3
0
        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());
                }
            });
        }