public static void CreateNewProject() { // Run the new project creator // First see if the NewProjectCreator is in this directory Process process = NewProjectHelper.RunNewProjectCreator(); if (process == null) { MessageBox.Show(@"Unable to create new project because the New Project Creator could not be run."); return; } while (!process.HasExited) { Thread.Sleep(300); } string createdProject = GetCreatedProjectName(process); if (!String.IsNullOrEmpty(createdProject)) { GlueCommands.Self.LoadProject(createdProject); } }
public static void CreateNewSyncedProject() { if (ProjectManager.ProjectBase == null) { MessageBox.Show(@"Can not create a new Synced Project because there is no open project."); return; } // Gotta find the .sln of this project so we can put the synced project in there var directory = GlueState.Self.CurrentSlnFileName?.GetDirectoryContainingThis(); Process process = NewProjectHelper.RunNewProjectCreator(directory, GlueState.Self.ProjectNamespace, creatingSyncedProject: true); if (process != null) { while (!process.HasExited) { Thread.Sleep(100); } string createdProject = GetCreatedProjectName(process); ProjectBase newProjectBase = null; if (!String.IsNullOrEmpty(createdProject)) { // The return value could be null if the project being added // already exists as a synced project, but this should never be // the case here. newProjectBase = ProjectManager.AddSyncedProject(createdProject); ProjectManager.SyncedProjects[ProjectManager.SyncedProjects.Count - 1].SaveAsRelativeSyncedProject = true; GluxCommands.Self.SaveGlux(); // These are now part of the engine, so don't do anything here. // Wait, these may be part of old templates, so let's keep this here. if (File.Exists(newProjectBase.Directory + "Screens/Screen.cs")) { newProjectBase.RemoveItem(newProjectBase.Directory + "Screens/Screen.cs"); File.Delete(newProjectBase.Directory + "Screens/Screen.cs"); } if (File.Exists(newProjectBase.Directory + "Screens/ScreenManager.cs")) { newProjectBase.RemoveItem(newProjectBase.Directory + "Screens/ScreenManager.cs"); File.Delete(newProjectBase.Directory + "Screens/ScreenManager.cs"); } // Remove Game1.cs so that it will just use the same Game1 of the master project. if (File.Exists(newProjectBase.Directory + "Game1.cs")) { newProjectBase.RemoveItem(newProjectBase.Directory + "Game1.cs"); File.Delete(newProjectBase.Directory + "Game1.cs"); } // This line is slow. Not sure why..maybe the project is saving after every file is added? // I could make it an async call but I want to figure out why it's slow at the core. newProjectBase.SyncTo(ProjectManager.ProjectBase, false); ProjectManager.SaveProjects(); } } }