internal void AddNewProject() { Wizard wiz = new Wizard(); ArrayList keys = new ArrayList(projtypes.Keys); keys.Sort(TypeComparer.Default); foreach (Type prj in keys) { wiz.prjtype.Items.Add(prj); } if (wiz.ShowDialog(ServiceHost.Window.MainForm) == DialogResult.OK) { Project prj = wiz.Tag as Project; Add(prj); prj.ProjectCreated(); prj.OnOpened(); if (Opened != null) { Opened(prj, EventArgs.Empty); } } }
//BuildProject solution; public Project Create(Type prjtype, string name, string rootdir) { Project proj = new Project(); proj.RootDirectory = rootdir; proj.Location = rootdir + Path.DirectorySeparatorChar + name + ".proj"; proj.ProjectName = name; proj.ProjectCreated(); return(proj); }
public Project AddProject(Type prjtype, string name, string rootdir) { Project proj = Activator.CreateInstance(prjtype) as Project; proj.RootDirectory = rootdir; proj.Location = rootdir + Path.DirectorySeparatorChar + name + ".proj"; proj.ProjectName = name; proj.ProjectCreated(); Add(proj); return(proj); }
public Project[] Open(string prjfile) { prjfile = Path.GetFullPath(prjfile); if (!File.Exists(prjfile)) { return(null); } Environment.CurrentDirectory = Path.GetDirectoryName(prjfile); foreach (MRUFile mru in recentfiles) { if (string.Compare(mru.filename, prjfile, true) == 0) { mru.Update(); goto DONE; } } recentfiles.Add(new MRUFile(prjfile)); DONE: string ext = Path.GetExtension(prjfile); if (ext == ".xaccproj") { BuildService bm = ServiceHost.Build as BuildService; bm.solution = new Microsoft.Build.BuildEngine.Project(); bm.solution.Load(prjfile); bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar); ArrayList projects = new ArrayList(); foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject")) { Environment.CurrentDirectory = Path.GetDirectoryName(prjfile); Project bp = new Project(); bp.SolBuildItem = prj; bp.Load(prj.Include); //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar; bp.ProjectCreated(); Add(bp); bp.OnOpened(); projects.Add(bp); if (Opened != null) { Opened(bp, EventArgs.Empty); } } if (File.Exists(Path.ChangeExtension(prjfile, ".xaccdata"))) { ServiceHost.Window.Document.Load(Path.ChangeExtension(prjfile, ".xaccdata")); } else { ProjectTab.Show(); } return(projects.ToArray(typeof(Project)) as Project[]); } else if (ext.EndsWith("proj")) { Project bp = new Project(); bp.Load(prjfile); bp.MSBuildProject.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar); bp.ProjectCreated(); Add(bp); bp.OnOpened(); if (Opened != null) { Opened(bp, EventArgs.Empty); } ProjectTab.Show(); return(new Project[] { bp }); } else if (ext == ".sln") { BuildService bm = ServiceHost.Build as BuildService; bm.solution = new Microsoft.Build.BuildEngine.Project(); bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar); using (TextReader r = new StreamReader(prjfile, Encoding.Default, true)) { string all = r.ReadToEnd(); foreach (Match m in SLNPARSE.Matches(all)) { string name = m.Groups["name"].Value; if (name == "Solution Items") { continue; } string location = m.Groups["location"].Value; if (File.Exists(Path.Combine(Path.GetDirectoryName(prjfile), location))) { bm.solution.AddNewItem("BuildProject", location); } } } bm.solution.AddNewImport(Path.Combine(Application.StartupPath, "xacc.imports"), ""); bm.solution.Save(Path.ChangeExtension(prjfile, ".xaccproj")); ArrayList projects = new ArrayList(); foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject")) { Environment.CurrentDirectory = Path.GetDirectoryName(prjfile); Project bp = new Project(); bp.Load(prj.Include); bp.SolBuildItem = prj; bp.ProjectCreated(); //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar; Add(bp); bp.OnOpened(); projects.Add(bp); if (Opened != null) { Opened(bp, EventArgs.Empty); } } ServiceHost.State |= ApplicationState.Project; ProjectTab.Show(); return(projects.ToArray(typeof(Project)) as Project[]); } else { return(null); } }