public void loadH2Script(string scriptToLoad) { O2Thread.mtaThread(() => { if (scriptToLoad.fileName().starts(this.typeName())) { PublicDI.log.error("We can execute the current type of we will get a recursive load :)"); return; } currentScript = scriptToLoad; statusLabel.set_Text("loading script: {0}".format(scriptToLoad.fileName())); csharpCompiler = new CSharp_FastCompiler(); csharpCompiler.set_OnAstFail(() => { showError("Ast creation failed", csharpCompiler.astErrors()); csharpCompiler_OnAstFail.invoke(); }); csharpCompiler.set_OnAstOK(() => { showInfo("Ast creation Ok"); csharpCompiler_OnAstOk.invoke(); }); csharpCompiler.set_OnCompileFail(() => { showError("Compilation failed", csharpCompiler.compilationErrors()); csharpCompiler_OnCompileFail.invoke(); }); csharpCompiler.set_OnCompileOK(() => { showInfo("Compilation Ok: Executing 1st method"); csharpCompiler_OnCompileOk.invoke(); executeCompiledCode(); }); var sourceCode = ""; PublicDI.CurrentScript = scriptToLoad; csharpCompiler.CompilerOptions.SourceCodeFile = scriptToLoad; if (scriptToLoad.extension(".h2")) { sourceCode = H2.load(scriptToLoad).SourceCode; } if (scriptToLoad.extension(".o2") || scriptToLoad.extension(".cs")) { sourceCode = scriptToLoad.contents(); } if (sourceCode.valid()) { csharpCompiler.compileSnippet(sourceCode); } else { statusLabel.set_Text("Non supported file").textColor(this, Color.Red); } }); }
public Control showEditGui(Control hostControl, string title1, string title2, Func <List <string> > getContent) { hostControl.clear(); var usersGui = hostControl.add_1x1(title1, title2, true, hostControl.width() / 3); var pageEditor = usersGui[1].add_Control <ascx_MediaWiki_PageEditor_Simple>().buildGui(WikiApi); Action <Control> loadData = (control) => { control.clear(); control.enabled(false); O2Thread.mtaThread( () => { var content = getContent(); var treeView = control.add_TreeViewWithFilter(content) .afterSelect <string>((userPage) => pageEditor.openPage(userPage)); addEditMenuItemsToTreeView(treeView); control.enabled(true); }); }; usersGui[0].insert_Below <Panel>(20) .add_Link("Reload data", 0, 0, () => loadData(usersGui[0])) .click(); return(hostControl); }
public static void executeInAppDomain(string appDomainName, string scriptToExecute) { O2Thread.mtaThread( () => { var o2AppDomain = new O2.Kernel.Objects.O2AppDomainFactory(appDomainName); try { o2AppDomain.load("O2_XRules_Database"); o2AppDomain.load("O2_Kernel"); o2AppDomain.load("O2_DotNetWrappers"); var o2Proxy = (O2Proxy)o2AppDomain.getProxyObject("O2Proxy"); o2Proxy.InvokeInStaThread = true; o2Proxy.staticInvocation("O2_External_SharpDevelop", "FastCompiler_ExtensionMethods", "executeSourceCode", new object[] { scriptToExecute }); } catch (Exception ex) { ex.log("inside new AppDomain"); } DebugMsg.showMessageBox("Click OK to close the '{0}' AppDomain (and close all open windows)".format(appDomainName)); o2AppDomain.unLoadAppDomain(); }); }
public GoogleAnalytics LogEntry(string page, string title, string accountId, string userCookie) { if (Enabled.isFalse()) { return(this); } var gaRequest = ("{0}?utmdt={1}&utmp={2}&utmac={3}&utmcc={4}").format( Analytics_Url, title, page, accountId, userCookie); //this should register a new entry in the GoogleAnalytics account, but I'm not sure how we cancheck that it actually worked (the returning gif is the same for success or failure) O2Thread.mtaThread( () => { if (TM_Xml_Database.Current.ServerOnline) { //gaRequest.info(); // to see the actual request "[GA] {0} -> {1}".info(title, page); gaRequest.GET(); } else { "[Offline][No GA] {0} -> {1}".info(title, page); } }); LogCount++; return(this); }
private void createJarStubFiles() { O2Thread.mtaThread( () => { // reset progress bar values this.invokeOnThread(() => { progressBarForJarStubCreation.Maximum = dotNetAssembliesToConvert.loadedFiles.Count; progressBarForJarStubCreation.Value = 0; btCreateJarStubFiles.Enabled = false; }); // process all files in dotNetAssembliesToConvert foreach (var fileToProcess in dotNetAssembliesToConvert.loadedFiles) { var jarStubFile = new JavaCompile(ikvm).createJarStubForDotNetDll(fileToProcess, ikvm.jarStubsCacheDir); if (!File.Exists(jarStubFile)) { "Jar stub file not created for :{0}".error(jarStubFile); } this.invokeOnThread(() => progressBarForJarStubCreation.Value++); } deleteEmptyJarStubs(); this.invokeOnThread(() => btCreateJarStubFiles.Enabled = true); }); }
public static void viewClassMethods(ascx_FunctionsViewer targetFunctionsViewer, ICirClass targetClass, bool showInheritedMethods, bool ignoreCoreObjectClass) { if (targetClass != null) { O2Thread.mtaThread( () => { targetFunctionsViewer.clearLoadedSignatures(); targetFunctionsViewer.setNamespaceDepth(0); var signaturesToShow = new List <string>(); if (showInheritedMethods) { List <ICirFunction> inheritedSignatures = CirDataAnalysisUtils.getListOfInheritedMethods(targetClass, ignoreCoreObjectClass); foreach (var inheritedSignature in inheritedSignatures) { signaturesToShow.Add(inheritedSignature.FunctionSignature); } } else { signaturesToShow.AddRange(targetClass.dFunctions.Keys.ToList()); } targetFunctionsViewer.showSignatures(signaturesToShow); /*var thread = targetFunctionsViewer.showSignatures(signaturesToShow); * if (thread != null) * { * thread.Join(); * targetFunctionsViewer.expandNodes(); * } */ }); } }
// was part of Tool Tip Provider void OnToolTipRequest(object sender, ToolTipRequestEventArgs e) { O2Thread.mtaThread( () => { try { if (e.InDocument && !e.ToolTipShown) { var logicalPosition = e.LogicalPosition; // parseSourceCode(CodeCompleteTargetText); ResolveResult rr = resolveLocation(logicalPosition); string toolTipText = GetText(rr); if (toolTipText != null) { e.ShowToolTip(toolTipText); //} //if (toolTipText.valid()) "ToolTipText: {0}".format(toolTipText).info(); } } } catch (Exception ex) { ex.log("in OnToolTipRequest"); } }); }
// this will regularly parse the current source code so that we have code completion for its methods public void startParseCodeThread() { O2Thread.mtaThread( () => { //"starting parseCodeThread".debug(); while (!textEditor.IsDisposed && UseParseCodeThread) { //this.parseSourceCode(this.textEditorToGrabCodeFrom.get_Text()); this.parseSourceCode(DummyFileName, this.textEditor.get_Text()); foreach (var codeOrFile in extraSourceCodeToProcess) { if (codeOrFile.isFile()) { this.parseSourceCode(codeOrFile, codeOrFile.contents()); } else { this.parseSourceCode(codeOrFile); } } this.sleep(2000, false); // "post sleep in parseCodeThread".debug(); } "LEAVING parseCodeThread".debug(); }); }
public void executeTask(IStep step) { O2Thread.mtaThread( () => { var sourceDirectory = step.getPathFromStep(0); var targetDirectory = step.getPathFromStep(1); var targetFile = calculateTargetFileName(sourceDirectory, targetDirectory); step.allowNext(false); step.allowBack(false); step.append_Line(" .... creating zip file ...."); new zipUtils().zipFolder(sourceDirectory, targetFile); if (File.Exists(targetFile)) { step.append_Line("File Created: {0}", targetFile); } else { step.append_Line("There was a problem creating the file: {0}", targetFile); } step.append_Line("all done"); step.allowNext(true); step.allowBack(true); }); }
public Thread loadO2Assessment(IO2AssessmentLoad o2AssessmentLoad, string pathToFileToLoad) { if (o2AssessmentLoad == null || false == File.Exists(pathToFileToLoad)) { this.invokeOnThread(() => laLoadingDroppedFile.Visible = false); return(null); } return(O2Thread.mtaThread(() => { this.invokeOnThread(() => laLoadingDroppedFile.Visible = true); var o2Assemment = new O2Assessment(o2AssessmentLoad, pathToFileToLoad); // load this on another thread var sync = new AutoResetEvent(false); this.invokeOnThread(() => // and then complete it on the controls thread { loadO2Assessment(o2Assemment); tbSavedFileName.Text = (cbClearOnOzasmtDrop.Checked) ? pathToFileToLoad : DI.config.TempFileNameInTempDirectory + "_" + Path.GetFileName(pathToFileToLoad); laLoadingDroppedFile.Visible = false; sync.Set(); }); sync.WaitOne(); })); }
public void startAddReferencesThread() { O2Thread.mtaThread( () => { O2Thread.setPriority_Lowest(); mapDotNetReferencesForCodeComplete(); }); }
public void setDocumentContents(string documentContents, string file) { // ToCheckOutLater: I don't really understand why I need to run this of a different thread // (but when developing ascx_O2_Command_Line there was a case where I had an // "In setDocumentContents: GapTextBufferStategy is not thread-safe!" // error O2Thread.mtaThread(() => sourceCodeEditor.setDocumentContents(documentContents, file)); }
public static Button onClick(this Button button, MethodInvoker onClick) { if (onClick != null) { button.Click += (sender, e) => O2Thread.mtaThread(() => onClick()); } return(button); }
public static string formatJsCode(this Control tempHostControl, string codeToFormat) { var ie = tempHostControl.add_IE().silent(true); var result = ie.formatJsCode(codeToFormat); O2Thread.mtaThread(() => ie.close()); return(result); }
public static WebBrowser open_ASync(this WebBrowser webBrowser, string url) { O2Thread.mtaThread( () => { webBrowser.open(url); }); return(webBrowser); }
public static void startShowThread() { if (targetRichTextBoxes.notEmpty() && activeShowThread.isNull()) { showMessages = true; activeShowThread = O2Thread.mtaThread(showLoop); } }
public void showInCurrentBrowser(string url) { O2Thread.mtaThread( () => { "opening page: {0}".info(url); BrowserCurrent.open(url); }); }
public static WebView open_ASync(this WebView webView, string url) { O2Thread.mtaThread( () => { webView.Load(url); }); return(webView); }
public void createAndShowCodeStream(INode iNode) { O2Thread.mtaThread( () => { CodeStream = AstData_MethodStream.createO2CodeStream(TaintRules, MethodStreamFile, iNode); showCodeStream(); }); }
public static ascx_WSDL_Creation_and_Execution createAndOpen(string wsdlToOpen) { var wsdlGui = "WSDL Execution for: {0}".format(wsdlToOpen) .showAsForm <ascx_WSDL_Creation_and_Execution>(1000, 400); O2Thread.mtaThread(() => wsdlGui.open(wsdlToOpen));; return(wsdlGui); }
private void llDeleteAllBreakpoints_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { O2Thread.mtaThread(() => { DI.o2MDbg.BreakPoints.deleteAddBreakpoints(); refreshBreakPointList(); }); }
public static void launchO2DockContentAsStandAloneForm(Type typeOfControlToLoad, string controlName) { if (typeOfControlToLoad == null) { PublicDI.log.error("in launchO2DockContentAsStandAloneForm typeOfControlToLoad was null"); } else { try { var sync = new AutoResetEvent(false); O2Thread.staThread(() => { try { O2AscxGUI.o2GuiStandAloneFormMode = true; //var controlToLoad = (Control) Activator.CreateInstance(typeOfControlToLoad); // if (typeOfControlToLoad != null) // { var o2DockContent = new O2DockContent(typeOfControlToLoad, DockState.Float, controlName); o2DockContent.dockContent.HandleCreated += (sender, e) => sync.Set(); // as soons as the control HandleCreated is created, we can let this function (launchO2DockContentAsStandAloneForm end) if (o2DockContent.createControlFromType()) { o2DockContent.dockContent.Width = o2DockContent.desiredWidth; o2DockContent.dockContent.Height = o2DockContent.desiredHeight; O2DockUtils.addO2DockContentToDIGlobalVar(o2DockContent); o2DockContent.dockContent.Closed += (sender, e) => { if (O2AscxGUI.dO2LoadedO2DockContent.Count == 0) // if there are no more controls trigger the end of the GUI session { O2AscxGUI.guiClosed.Set(); } }; o2DockContent.dockContent.ShowDialog(); } else { PublicDI.log.error( "in launchO2DockContentAsStandAloneForm, could not create instance of controlToLoad: {0}", typeOfControlToLoad.ToString()); } } catch (Exception ex) { PublicDI.log.ex(ex, "in launchO2DockContentAsStandAloneForm"); } sync.Set(); }); sync.WaitOne(); } catch (Exception ex) { PublicDI.log.ex(ex); } } }
public static void startControl(string scriptToExecute) { // load Execute_Scripts GUI var formTitle = "O2 XRules Database ({0})".format("O2_XRules_Database.exe".assembly().version()); "{0}".info(formTitle); var executeScripts = (ascx_Execute_Scripts)typeof(ascx_Execute_Scripts).showAsForm(formTitle, 240, 200); executeScripts.checkForMSI_andOnFirstRunAndUnzipDefaultScripts(); "LocalScriptsFolder: {0}".debug(PublicDI.config.LocalScriptsFolder); executeScripts.buildGui(); // see if there there is a script to execute //(first via normal process arguments if (scriptToExecute.valid() && scriptToExecute.fileExists()) { executeScripts.runScriptAndCloseGui(scriptToExecute); } else { //.. then via Clickonce invoke scriptToExecute = ClickOnceDeployment.getClickOnceScriptPath(); if (scriptToExecute.fileExists()) { executeScripts.runScriptAndCloseGui(scriptToExecute); } else // ... if there is no script to execute: check for SVN updates and Start the new GUI { if (ClickOnceDeployment.isClickOnceDeployment()) { executeScripts.checkForClickOnceUpdates(); executeScripts.syncO2ViaSvn(); } else { svnSyncComplete.Set(); } svnSyncComplete.WaitOne(); // load new gui var newGuiScript = NEW_GUI_SCRIPT.local(); if (newGuiScript.fileExists()) { executeScripts.welcomeMessage = "New O2 GUI detected, launching it now..."; executeScripts.status(executeScripts.welcomeMessage); { O2Thread.mtaThread(() => { loadNewGui(executeScripts); }); } } } } }
public static API_Veracode_DetailedXmlFindings show_In_TreeView(this API_Veracode_DetailedXmlFindings apiVeracode, Control control) { var treeView = control.clear().add_TreeView(); Action <TreeNode, string> removeSchemaReference = (treeNode, textToRemove) => { treeNode.set_Text(treeNode.get_Text().remove(textToRemove)); }; treeView.afterSelect( (treeNode) => { removeSchemaReference(treeNode, "{" + apiVeracode.schemaName + "}"); }); Action <string> loadFile = (file) => { apiVeracode.load(file); treeView.rootNode().showXml(apiVeracode.ReportXmlFile); }; treeView.onDrop( (fileOrFolder) => { treeView.azure(); O2Thread.mtaThread( () => { if (fileOrFolder.dirExists()) { foreach (var file in fileOrFolder.files(true, "*.xml", "*.zip")) { try { loadFile(file); } catch (Exception ex) { "error loading file: {0} : {1}".error(file.fileName(), ex.Message); } } } else { loadFile(fileOrFolder); } treeView.white(); }); }); if (apiVeracode.ReportXmlFile.valid()) { treeView.rootNode().showXml(apiVeracode.ReportXmlFile); } else { treeView.rootNode().add_Node("drop a Veracode DetailedFindings Xml (or zip) file to view it"); } treeView.selectFirst().expand(); return(apiVeracode); }
public static Panel Main(bool startHidden = false, string targetScript = null) { //O2ConfigSettings.O2Version = "Package_O2_Script_v1"; //O2Setup.extractEmbededConfigZips(); //var topPanel = panel.clear().add_Panel(); var topPanel = "Util - Compile H2, O2 or CS Script into separate Folder".popupWindow(800, 300, startHidden) .insert_LogViewer(); var browser = topPanel.add_WebBrowser_Control() .add_NavigationBar(); var dropZone = topPanel.insert_Left(200) .add_Button("Drop script file here \n\n to package it into seperate folder").fill() .font_bold(); var lastScriptFile = ""; var compiledScript = ""; Action <string> packageScript = (scriptFile) => { lastScriptFile = scriptFile; dropZone.green(); O2Thread.mtaThread( () => { var pathToAssemblies = ""; var projectFile = ""; if (scriptFile.package_Script(ref compiledScript, ref pathToAssemblies, ref projectFile).valid()) { browser.open(pathToAssemblies); dropZone.azure(); } else { var logFile = projectFile + ".log"; "LogFile: {0}".error(logFile); browser.set_Text(logFile.fileContents().replace("".line(), "<br>")); dropZone.pink(); } }); }; dropZone.parent().insert_Below(20).add_Link("Execute", () => compiledScript.startProcess()) .append_Link("Open Folder", () => compiledScript.directoryName().startProcess()) .append_Link("Edit Target", () => lastScriptFile.local().showInCodeEditor()); // .append_Link("Clear Cache", ()=> { CompileEngine.CachedCompiledAssemblies.Clear(); "Compilation Cache Cleared".info();}); dropZone.onDrop(packageScript); dropZone.onClick(() => packageScript(lastScriptFile)); dropZone.add_MenuItem_with_TestScripts(packageScript); if (targetScript.valid()) { packageScript(targetScript); } //return packageScript; return(topPanel); }
public void showRawWikiText() { var defaultTopPanelText = "You can refresh the Html view using F5 or Ctrl+R (or via the context menu (right-click on WikiText))"; var panel = MainDocumentPane.add_DocumentContent("Raw Wiki Text") .setAsActive() .add_WinForms_Panel(); //panel.clear(); //var wikiApi = new O2PlatformWikiAPI(); var topPanel = panel.add_1x1(false); var rawWiki = topPanel[0].add_TextArea(); var bottomPanel = topPanel[1].add_1x1x1("Pure Html", "Browser (pure html View)", "Browser (view using site's Styles)"); var htmlViewer = bottomPanel[0].add_RichTextBox(); var browserSimple = bottomPanel[1].add_WebBrowser(); var browserWithSyles = bottomPanel[2].add_WebBrowser(); Action <string> processWikiText = (wikiText) => { var htmlCode = WikiApi.parseText(wikiText); htmlViewer.set_Text(htmlCode); browserSimple.set_Text(htmlCode); browserWithSyles.set_Text(WikiApi.wrapOnHtmlPage(htmlCode)); }; MethodInvoker refresh = () => { topPanel[0].set_Text("Retrieving RawWiki Html code"); rawWiki.backColor(Color.LightPink); O2Thread.mtaThread( () => { processWikiText(rawWiki.get_Text()); rawWiki.backColor(Color.White); topPanel[0].set_Text(defaultTopPanelText); }); }; Action <KeyEventArgs> handlePressedKeys = (e) => { if (e.KeyValue == 116 || // F5 (key 116) or (e.Modifiers == Keys.Control && e.KeyValue == 'R')) // Ctrl+R it { refresh(); } }; rawWiki.KeyUp += (sender, e) => handlePressedKeys(e); //rawWiki.onEnter(processWikiText); rawWiki.add_ContextMenu().add_MenuItem("Show Html for Wiki Text", refresh); rawWiki.set_Text("===Raw WikiText===".line() + "this is simple text".line() + "* this is a bullet point"); refresh(); //panel_add_1x1( }
public static MDbgEngine process_StopInNSeconds(this MDbgEngine engine, int seconds) { O2Thread.mtaThread( () => { engine.sleep(seconds * 1000); engine.stop_Process(); }); return(engine); }
private void btExecuteOnFrame_Click(object sender, EventArgs e) { O2Thread.mtaThread(() => { DI.log.debug("Executing: {0}", tbExecuteOnFrame.Text); var result = O2MDbgUtils.execute(tbExecuteOnFrame.Text); DI.log.debug("Execution result: {0}", (result ?? "<null>")); }); }
public static void compileXRules(O2Thread.FuncVoidT1 <List <IXRule> > onCompilation, O2Thread.FuncVoidT1 <string> currentTask, O2Thread.FuncVoidT1 <int> numberOfStepsToPerform, O2Thread.FuncVoid onStepEvent) { O2Thread.mtaThread( () => { var xRules = compileXRules(currentTask, numberOfStepsToPerform, onStepEvent); onCompilation(xRules); }); }
public static void sleep(this object _object, int miliSeconds, bool verbose, MethodInvoker toInvokeAfterSleep) { O2Thread.mtaThread( () => { _object.sleep(miliSeconds, verbose); toInvokeAfterSleep(); }); }