public void RenameProjectFolder(RenameContext context)
 {
     using(SvnClient svnClient = new SvnClient())
     {
         svnClient.Move(context.OldProject.ProjectDirectory, context.NewProject.ProjectDirectory);
     }
 }
        public void Rename(RenameContext renameContext)
        {
            var renameSuccessfull = true;
            var rollbackSuccessfull = true;

            this.context = renameContext;

            try
            {
                if(Setup(this.context.Solution))
                {
                    renamer = renamerFactory.GetInstance(this.context.IsUnderVersionControl);
                    Rename(this.context.CommitChanges);
                }
                else
                {
                    string message = string.Format(localizationService.GetString(LocalizationResourceNames.RenameErrorNoSupportedProjectFound), context.OldProject.ProjectDirectory);
                    errorDialogService.HandleError(message);
                    renameSuccessfull = false;
                }
            }
            catch(Exception exception)
            {
                renameSuccessfull = false;
                errorDialogService.HandleError(string.Format("Exception:{0}{1}{2}Stacktrace:{3}{4}{5}", Environment.NewLine, exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace, Environment.NewLine));
                rollbackSuccessfull = Rollback();
            }
            finally
            {
                InvokeRenameFinished(new RenameFinishedEventArgs(true, renameSuccessfull, rollbackSuccessfull));
            }
        }
        public void RenameProjectFile(RenameContext context)
        {
            string oldProjectFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, context.OldProject.ProjectExtension);
            string newProjectFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, context.NewProject.ProjectExtension);

            if (File.Exists(oldProjectFile))
            {
                File.Move(oldProjectFile, newProjectFile);
            }
        }
        public void RenameMainEntryFile(RenameContext context)
        {
            string oldMainEntryFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, ".cpp");
            string newMainEntryFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, ".cpp");

            // Only if the main entry file in c++ projects has the same name as the project itself, move it.
            if(File.Exists(oldMainEntryFile))
            {
                using (SvnClient svnClient = new SvnClient())
                {
                    svnClient.Move(oldMainEntryFile, newMainEntryFile);
                }
            }
        }
        public void RenameProjectFiltersFile(RenameContext context)
        {
            if (!context.OldProject.ProjectType.Equals(ProjectType.Cplusplus))
            {
                return;
            }

            string oldProjectFiltersFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, ".vcxproj.filters");
            string newProjectFiltersFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, ".vcxproj.filters");

            if (File.Exists(oldProjectFiltersFile))
            {
                File.Move(oldProjectFiltersFile, newProjectFiltersFile);
            }
        }
        public bool Rollback(string solutionDirectoryPath, RenameContext context)
        {
            using(SvnClient svnClient = new SvnClient())
            {
                // TODO NKO Do someting with the changelist
                Collection<SvnListChangeListEventArgs> changeList;
                svnClient.GetChangeList(solutionDirectoryPath, out changeList);

                SvnRevertArgs revertArgs = new SvnRevertArgs { Depth = SvnDepth.Infinity };
                svnClient.Revert(solutionDirectoryPath, revertArgs);
            }

            // Now delete the folder that was created for the new project.
            // Note: Can not use svnclient.Delete because the folder and all containing files werent ever checked in.
            Directory.Delete(context.NewProject.ProjectDirectory, true);

            // And do an update to get a clean repository state again.
            UpdateWorkingCopy(solutionDirectoryPath);

            return true;
        }
        public void RenameProjectFolder(RenameContext context)
        {
            // Since this method is called first, we do a backup here.
            CreateBackup(context.OldProject);

            Directory.Move(context.OldProject.ProjectDirectory, context.NewProject.ProjectDirectory);
        }
        public bool Rollback(string solutionDirectoryPath, RenameContext context)
        {
            // Remove the new created folder and the modified solution file.
            string newProjectDirectory = context.NewProject.ProjectDirectory;
            string modifiedSolutionFile = context.OldProject.SolutionPath;

            if (Directory.Exists(newProjectDirectory))
            {
                Directory.Delete(newProjectDirectory, true);
            }

            if (File.Exists(modifiedSolutionFile))
            {
                File.Delete(modifiedSolutionFile);
            }

            // Now rename the backup folders / files to the old names.
            string backupDirectory = string.Format("{0}{1}", context.OldProject.ProjectDirectory, Constants.ProjectDirectoryBackupExtension);
            string backupSolutionFile = string.Format("{0}{1}", context.OldProject.SolutionPath, Constants.SolutionBackupExtension);

            if (Directory.Exists(backupDirectory))
            {
                Directory.Move(backupDirectory, context.OldProject.ProjectDirectory);
            }

            if (File.Exists(backupSolutionFile))
            {
                File.Move(backupSolutionFile, context.OldProject.SolutionPath);
            }

            return true;
        }
        internal void Rename(string solution, Project oldProject, Project newProject, bool isUnderVersionControl, bool commitChanges, bool adjustFolderNameProjectNameMissmatch, bool renameMainEntryFile ,MainForm form = null)
        {
            RenameContext context = new RenameContext
                {
                    Solution = solution,
                    OldProject = oldProject,
                    NewProject = newProject,
                    IsUnderVersionControl = isUnderVersionControl,
                    CommitChanges = commitChanges,
                    AdjustFolderNameProjectNameMissmatch = adjustFolderNameProjectNameMissmatch,
                    RenameMainEntryFile = renameMainEntryFile
                };

            if(form != null)
            {
                renamerService.RenameFinished += form.RenameFinished;
            }

            Task.Factory.StartNew(() => renamerService.Rename(context), CancellationToken.None, TaskCreationOptions.None, MyStaTaskScheduler);
        }