Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created November 7, 2012 15:03
Show Gist options
  • Select an option

  • Save DinisCruz/4032116 to your computer and use it in GitHub Desktop.

Select an option

Save DinisCruz/4032116 to your computer and use it in GitHub Desktop.
O2 Script - VisualStudio API - Create WinForms Control on Document save
var targetFile = @"E:\O2_V4\O2.FluentSharp\O2.FluentSharp.REPL\Ascx\ascx_Simple_Script_Editor.cs";
var targetType = "ascx_Simple_Script_Editor";
var visualStudio = new VisualStudio_2010();
var panel = visualStudio.open_Panel("Live instance of: " + targetType)
.insert_LogViewer();;
Action<string> compileAndShowFile =
(file)=>{
var compileEngine = new CompileEngine(false);
var assembly = compileEngine.compileSourceFile(file);
if (assembly.notNull())
{
var type = assembly.type(targetType);
panel.clear().add_Control(type);
}
};
visualStudio.open_Document(targetFile);
VisualStudio_2010.on_DocumentSaved.clear()
.add((document)=>{
var fileToCompile = document.FullName;
if (fileToCompile == targetFile)
compileAndShowFile(targetFile);
});
compileAndShowFile(targetFile);
return "done";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment