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);
        }
Ejemplo n.º 2
0
        private void SetupProjectTemplates()
        {
            var programTemplate = new NetAstFileTemplate("Program", "Program", null, this, CodeDomUnitFactory.CreateEntryPointModuleUnit("%folder%", "Program"));

            LanguageDescriptor.GetLanguage<CSharpLanguage>().Templates.Add(new NetProjectTemplate(
                "Console Application",
                Properties.Resources.console,
                LanguageDescriptor.GetLanguage<CSharpLanguage>(),
                SubSystem.Console,programTemplate));

            LanguageDescriptor.GetLanguage<VisualBasicLanguage>().Templates.Add(new NetProjectTemplate(
                "Console Application",
                Properties.Resources.console,
                LanguageDescriptor.GetLanguage<VisualBasicLanguage>(),
                SubSystem.Console,
                programTemplate));

            programTemplate = new NetAstFileTemplate("Class1", "Class1", null, this, CodeDomUnitFactory.CreateClassUnit("%folder%", "Class1"));

            LanguageDescriptor.GetLanguage<CSharpLanguage>().Templates.Add(new NetProjectTemplate(
                "Class Library",
                Properties.Resources.dll,
                LanguageDescriptor.GetLanguage<CSharpLanguage>(),
                SubSystem.Library, programTemplate));

            LanguageDescriptor.GetLanguage<VisualBasicLanguage>().Templates.Add(new NetProjectTemplate(
                "Class Library",
                Properties.Resources.dll,
                LanguageDescriptor.GetLanguage<VisualBasicLanguage>(),
                SubSystem.Library,
                programTemplate));
        }
        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);
        }
Ejemplo n.º 4
0
 public NetFormTemplate(string name, Bitmap icon, IFileHandler extensionToUse, NetAstFileTemplate designerTemplate, NetAstFileTemplate classTemplate)
     : base(name, icon, extensionToUse)
 {
     DesignerClassFile = designerTemplate;
     ClassFile = classTemplate;
 }