/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var dteSolutionHelper = new DteSolutionHelper(); var messageBoxHelper = new MessageBoxHelper(this.ServiceProvider); var selectedProject = dteSolutionHelper.GetSelectedProject(); if (!selectedProject.Saved) { messageBoxHelper.ShowInfoMessage("Build/rebuild project before renaming"); return; } if (!dteSolutionHelper.IsProjectFilesSaved(selectedProject)) { messageBoxHelper.ShowInfoMessage("Some files are not saved. Save them or build/rebuild project"); return; } var renameOptions = new RenameOptions { ProjectName = selectedProject.Name, ProjectFullName = selectedProject.FullName }; var dialog = new FullRenameDialog(renameOptions); var isOkButtonClicked = dialog.ShowModal(); if (isOkButtonClicked == false) { return; } if (renameOptions.ProjectName == selectedProject.Name) { return; } try { var projectRenamer = ProjectRenamerFactory.Create(selectedProject, renameOptions); projectRenamer.FullRename(); messageBoxHelper.ShowSuccessMessage(); } catch (UnauthorizedAccessException uae) { messageBoxHelper.ShowErrorMessage(uae, "You don't have enough permisssion"); } catch (IOException ioe) { messageBoxHelper.ShowErrorMessage(ioe, "Close all folders, text editors related to the project"); } catch (Exception ex) { messageBoxHelper.ShowErrorMessage(ex); } }
public FullRenameDialog(RenameOptions renameOptions) { InitializeComponent(); DataContext = renameOptions; }