Пример #1
0
        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");
                }
            }
        }
Пример #2
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        private void OpenInXamarinStudio(object sender, RoutedEventArgs e)
        {
            string solutionName = ProjectSyncer.LocateSolution(Project.FullFileName);

            HandleOpenInXamarinStudioClick(solutionName);
        }