private void SetupProjectTemplates() { var programClassTemplate = new NetAstFileTemplate("Program", "Program", null, CodeEditorExtension.Instance, CodeDomUnitFactory.CreateEntryPointModuleUnit("%folder%", "Program")); var method = programClassTemplate.CompileUnit.Namespaces[1].Types[0].Members[0] as CodeMemberMethod; method.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(STAThreadAttribute)))); method.Statements.AddRange(new CodeStatement[] { new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeTypeReferenceExpression(typeof(Application)), "EnableVisualStyles"))), new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeTypeReferenceExpression(typeof(Application)), "SetCompatibleTextRenderingDefault"), new CodePrimitiveExpression(false))), new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeTypeReferenceExpression(typeof(Application)), "Run"), new CodeObjectCreateExpression("Form1"))), }); var formClassTemplate = new NetAstFileTemplate( "Form1", "Form1", null, CodeEditorExtension.Instance, CodeDomUnitFactory.CreateFormClass("%folder%", "Form1")); var formDesignerClassTemplate = new NetAstFileTemplate( "Form1.Designer", "Form1", null, this, CodeDomUnitFactory.CreateFormDesignerClass("%folder%", "Form1")); var formTemplate = new NetFormTemplate( "Form1", Properties.Resources.window_new, this, formDesignerClassTemplate, formClassTemplate); var csProject = new NetProjectTemplate( "Windows Forms Application", Properties.Resources.window_list, LanguageDescriptor.GetLanguage<CSharpLanguage>(), SubSystem.Windows, programClassTemplate, formTemplate); csProject.References.AddRange(new string[] { "System.Drawing.dll", "System.Windows.Forms.dll" }); LanguageDescriptor.GetLanguage<CSharpLanguage>().Templates.Add(csProject); var vbProject = new NetProjectTemplate( "Windows Forms Application", Properties.Resources.window_list, LanguageDescriptor.GetLanguage<VisualBasicLanguage>(), SubSystem.Windows, programClassTemplate, formTemplate); vbProject.References.AddRange(new string[] { "System.Drawing.dll", "System.Windows.Forms.dll" }); LanguageDescriptor.GetLanguage<VisualBasicLanguage>().Templates.Add(vbProject); }
private void SetupFileTemplates() { var formDesignerClassTemplate = new NetAstFileTemplate( "%file%.Designer", "%file%", null, this, CodeDomUnitFactory.CreateFormDesignerClass("%folder%", "%file%")); var formClassTemplate = new NetAstFileTemplate( "%file%", null, null, CodeEditorExtension.Instance, CodeDomUnitFactory.CreateFormClass("%folder%", "%file%")); var formTemplate = new NetFormTemplate( "Form", Properties.Resources.window_new, this, formDesignerClassTemplate, formClassTemplate); LanguageDescriptor.GetLanguage<CSharpLanguage>().Templates.Add(formTemplate); LanguageDescriptor.GetLanguage<VisualBasicLanguage>().Templates.Add(formTemplate); }