public static void OpenInVisualStudio(ProjectBase project) { string solutionName = ProjectSyncer.LocateSolution(project.FullFileName); string fileToOpen = null; if (string.IsNullOrEmpty(solutionName)) { if (!PluginManager.OpenProject(project.FullFileName)) { fileToOpen = ProjectManager.ProjectBase.FullFileName; } } else { if (!PluginManager.OpenSolution(solutionName)) { fileToOpen = solutionName; } } if (!string.IsNullOrEmpty(fileToOpen)) { var startedProcess = Process.Start(fileToOpen); if (startedProcess != null && startedProcess.ProcessName == "Glue") { MessageBox.Show("Your machine has the file\n\n" + fileToOpen + "\n\nassociated with Glue. " + "It should probably be associated with a programming IDE like Visual Studio"); } } }
public static void OpenInVisualStudio(ProjectBase project) { string solutionName = null; try { solutionName = ProjectSyncer.LocateSolution(project.FullFileName); } catch (FileNotFoundException fnfe) { MessageBox.Show(fnfe.Message); } string fileToOpen = null; if (string.IsNullOrEmpty(solutionName)) { // I don't think we should do anything here. This could confuse users if // the solution isn't found. Let LocateSolution do its job, dont' second guess it... //if (!PluginManager.OpenProject(project.FullFileName)) //{ // fileToOpen = ProjectManager.ProjectBase.FullFileName; //} } else { if (!PluginManager.OpenSolution(solutionName)) { fileToOpen = solutionName; } } if (!string.IsNullOrEmpty(fileToOpen)) { var startedProcess = Process.Start(fileToOpen); if (startedProcess != null) { bool openedWithGlue = false; try { openedWithGlue = startedProcess.ProcessName == "Glue"; if (openedWithGlue) { MessageBox.Show("Your machine has the file\n\n" + fileToOpen + "\n\nassociated with Glue. " + "It should probably be associated with a programming IDE like Visual Studio"); } } catch (InvalidOperationException) { // An error with this code has been reported, but I'm not sure why. It's not damaging to just ignore it, and say that there was a failure: GlueCommands.Self.PrintOutput("An error has occurred when trying to open the project. Please try again if Visual Studio has not opened."); } } } }
private VSSolution GetMainSolution() { string mainSln = ProjectSyncer.LocateSolution(GlueState.Self.CurrentMainProject.FullFileName); var solution = VSSolution.FromFile(mainSln); return(solution); }
private List <VSSolution> GetSyncedSolutions() { List <VSSolution> toReturn = new List <VSSolution>(); foreach (var project in GlueState.Self.SyncedProjects) { var syncedSolutionFileName = ProjectSyncer.LocateSolution(project.FullFileName); var syncedSolution = VSSolution.FromFile(syncedSolutionFileName); toReturn.Add(syncedSolution); } return(toReturn); }
private void PrepareSyncedProjects(string projectFileName) { SetInitWindowText("Loading synced projects Entities"); for (int i = ProjectManager.GlueProjectSave.SyncedProjects.Count - 1; i > -1; i--) { string projectName; if (FileManager.IsRelative(ProjectManager.GlueProjectSave.SyncedProjects[i])) { projectName = FileManager.RelativeDirectory + ProjectManager.GlueProjectSave.SyncedProjects[i]; projectName = FileManager.RemoveDotDotSlash(projectName); } else { projectName = ProjectManager.GlueProjectSave.SyncedProjects[i]; } bool succeeded = AddSyncedProjectToProjectManager(projectName); if (!succeeded) { ProjectManager.GlueProjectSave.SyncedProjects.RemoveAt(i); } } if (!projectFileName.Equals(ProjectLoader.Self.LastLoadedFilename)) { lock (ProjectManager.SyncedProjects) { foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects) { try { ProjectSyncer.SyncProjects(ProjectManager.ProjectBase, syncedProject, false); } catch (Exception e) { MessageBox.Show("Error syncing project:\n\n" + syncedProject.Name + "\n\nThe main project will still function properly - Glue just won't be able " + "to maintain the synced project. Error details:\n\n" + e.ToString()); } } } } }
private bool HandleOpenInXamarinStudioClick(string solution) { string standardizedSolution = FileManager.Standardize(solution).ToLowerInvariant(); ProjectBase project = null; string mainSolution = ProjectSyncer.LocateSolution(GlueState.Self.CurrentMainContentProject.FullFileName); if (standardizedSolution == FileManager.Standardize(mainSolution).ToLowerInvariant()) { project = GlueState.Self.CurrentMainContentProject; } if (project == null) { // Maybe this is a synced project? foreach (var potentialProject in GlueState.Self.SyncedProjects) { string potentialSolutionName = FileManager.Standardize(ProjectSyncer.LocateSolution(potentialProject.FullFileName)).ToLowerInvariant(); if (potentialSolutionName == standardizedSolution) { project = potentialProject; break; } } } bool shouldHandle = project != null && project is AndroidProject; if (shouldHandle) { try { string xamarinStudioLocation = GetProgramFilesx86() + "Xamarin Studio/bin/XamarinStudio.exe"; Process.Start(xamarinStudioLocation, solution); } catch (Exception ex) { PluginManager.ReceiveError(ex.ToString()); MessageBox.Show("Error opening Xamarin Studio - see error in output"); } } return(shouldHandle); }
static void SaveGluxSync(bool sendMessageToRefresh) { if (ProjectManager.GlueProjectSave != null) { if (MainGlueWindow.Self.HasErrorOccurred) { string projectName = FileManager.RemovePath(FileManager.RemoveExtension(ProjectManager.GlueProjectFileName)); MessageBox.Show("STOP RIGHT THERE!!!! There was an error in Glue at some point. To prevent " + "corruption in the GLUX file, Glue will no longer save any changes that you make to the project. " + "You should exit out of Glue immediately and attempt to solve the problem.\n\n" + "Glue has saved your work in a temporary file called " + projectName + ".gluxERROR" ); ProjectManager.GlueProjectSave.Save("GLUE", ProjectManager.GlueProjectFileName + "ERROR"); } else { ProjectSyncer.SyncGlux(); // October 27, 2011 // Instead of saving // directly to disk we're // going to serialize to a // string. If the serialization // fails, we won't try to save the // file to disk. try { ProjectManager.GlueProjectSave.TestSave("GLUE"); } catch (Exception e) { string errorLogLocation = FileManager.UserApplicationDataForThisApplication + "ExceptionInGlue.txt"; MessageBox.Show("Error trying to save your .glux file. Because of this error, Glue did not make any changes to the .glux file on disk.\n\nAn error log has been saved here:\n" + errorLogLocation); try { FileManager.SaveText(e.ToString(), errorLogLocation); } catch { // If this fails that's okay, we're already in a failed state. } PluginManager.ReceiveError("Error saving glux:\n\n" + e.ToString()); MainGlueWindow.Self.HasErrorOccurred = true; } if (!MainGlueWindow.Self.HasErrorOccurred) { FileWatchManager.IgnoreNextChangeOnFile(GlueState.Self.GlueProjectFileName); Exception lastException; var succeeded = ProjectManager.GlueProjectSave.Save("GLUE", GlueState.Self.GlueProjectFileName, out lastException); if (!succeeded) { MessageBox.Show("Error saving the .glux:\n" + lastException); } else { if (sendMessageToRefresh) { PluginManager.ReactToGluxSave(); } } } } } }
public static void SaveProjects() { lock (mProjectBase) { bool shouldSync = false; // IsDirty means that the project has items that haven't // been updated to the "evaluated" list, not if it needs to // be saved. //if (mProjectBase != null && mProjectBase.IsDirty) if (mProjectBase != null) { bool succeeded = true; try { mProjectBase.Save(mProjectBase.FullFileName); } catch (UnauthorizedAccessException) { MessageBox.Show("Could not save the file because the file is in use"); succeeded = false; } if (succeeded) { shouldSync = true; } } if (ContentProject != null && ContentProject != mProjectBase) { ContentProject.Save(ContentProject.FullFileName); shouldSync = true; } //Save projects in case they are dirty foreach (var syncedProject in mSyncedProjects) { try { syncedProject.Save(syncedProject.FullFileName); } catch (Exception e) { PluginManager.ReceiveError(e.ToString()); syncedProject.IsDirty = true; } if (syncedProject.ContentProject != syncedProject) { syncedProject.ContentProject.Save(syncedProject.ContentProject.FullFileName); } } //Sync all synced projects if (shouldSync || mHaveNewProjectsBeenSyncedSinceSave) { var syncedProjects = mSyncedProjects.ToArray(); foreach (var syncedProject in syncedProjects) { ProjectSyncer.SyncProjects(mProjectBase, syncedProject, false); } } // It may be that only the synced projects have changed, so we have to save those: foreach (var syncedProject in mSyncedProjects) { syncedProject.Save(syncedProject.FullFileName); if (syncedProject != syncedProject.ContentProject) { syncedProject.ContentProject.Save(syncedProject.ContentProject.FullFileName); } } mHaveNewProjectsBeenSyncedSinceSave = false; } }
private void OpenInXamarinStudio(object sender, RoutedEventArgs e) { string solutionName = ProjectSyncer.LocateSolution(Project.FullFileName); HandleOpenInXamarinStudioClick(solutionName); }