Ejemplo n.º 1
0
 public static bool ShowQuestionForAddingLicenseHeaderFile(Project activeProject, IDefaultLicenseHeaderPage page)
 {
     string message = Resources.Error_NoHeaderDefinition.Replace (@"\n", "\n");
       var messageBoxResult = MessageBox.Show (message, Resources.Error, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
       if (messageBoxResult != MessageBoxResult.Yes)
     return false;
       return AddLicenseHeaderDefinitionFileToProject(activeProject, page);
 }
 private void AddMissingLicenseHeaderFiles(List<Project> projectsWithoutLicenseHeader, IDefaultLicenseHeaderPage page)
 {
     foreach (Project project in projectsWithoutLicenseHeader)
     {
       if (projectsWithoutLicenseHeader.Contains (project))
     LicenseHeader.AddLicenseHeaderDefinitionFile (project, page, false);
     }
 }
        public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IVsStatusbar statusBar, IDefaultLicenseHeaderPage licenseHeaderPage)
        {
            this.statusBar = statusBar;
              this.licenseReplacer = licenseReplacer;
              this.licenseHeaderPage = licenseHeaderPage;

              addLicenseHeaderToAllFilesCommand = new AddLicenseHeaderToAllFilesCommand(licenseReplacer);
        }
 public static bool ShowQuestionForAddingLicenseHeaderFile(Project activeProject, IDefaultLicenseHeaderPage page)
 {
     string message = string.Format(Resources.Error_NoHeaderDefinition, activeProject.Name).Replace (@"\n", "\n");
       var messageBoxResult = MessageBox.Show (message, Resources.Error, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
       if (messageBoxResult != MessageBoxResult.Yes)
     return false;
       var licenseHeaderDefinitionFile = AddLicenseHeaderDefinitionFile(activeProject, page);
       licenseHeaderDefinitionFile.Open(Constants.vsViewKindCode).Activate();
       return true;
 }
        /// <summary>
        /// Adds a new License Header Definition file to a folder
        /// </summary>
        public static ProjectItem AddLicenseHeaderDefinitionFile(ProjectItem folder, IDefaultLicenseHeaderPage page)
        {
            if (folder == null || folder.Kind != Constants.vsProjectItemKindPhysicalFolder)
            return null;

              var fileName = GetNewFullName (folder.Properties.Item("FullPath").Value.ToString());
              File.WriteAllText (fileName, page.LicenseHeaderFileText, Encoding.UTF8);

              var newProjectItem = folder.ProjectItems.AddFromFile (fileName);

              OpenNewProjectItem(newProjectItem);

              return newProjectItem;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a new License Header Definition file to a folder
        /// </summary>
        public static ProjectItem AddLicenseHeaderDefinitionFile(ProjectItem folder, IDefaultLicenseHeaderPage page)
        {
            if (folder == null || folder.Kind != Constants.vsProjectItemKindPhysicalFolder)
            {
                return(null);
            }

            var fileName = GetNewFullName(folder.Properties.Item("FullPath").Value.ToString());

            File.WriteAllText(fileName, page.LicenseHeaderFileText, Encoding.UTF8);

            var newProjectItem = folder.ProjectItems.AddFromFile(fileName);

            OpenNewProjectItem(newProjectItem);

            return(newProjectItem);
        }
        /// <summary>
        /// Adds a new License Header Definition file to the active project.
        /// </summary>
        public static ProjectItem AddLicenseHeaderDefinitionFile(Project activeProject, IDefaultLicenseHeaderPage page)
        {
            if (activeProject == null)
            return null;

              var fileName = GetNewFullName (activeProject);
              File.WriteAllText (fileName, page.LicenseHeaderFileText, Encoding.UTF8);
              var newProjectItem = activeProject.ProjectItems.AddFromFile (fileName);

              if (newProjectItem == null)
              {
            string message = string.Format(Resources.Error_CreatingFile).Replace(@"\n", "\n");
            MessageBox.Show(message, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
              }

              return newProjectItem;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds a new License Header Definition file to the active project.
        /// </summary>
        public static ProjectItem AddHeaderDefinitionFile(Project activeProject, IDefaultLicenseHeaderPage page)
        {
            if (IsValidProject(activeProject))
            {
                return(null);
            }

            var fileName = GetNewFullName(activeProject);

            File.WriteAllText(fileName, page.LicenseHeaderFileText, Encoding.UTF8);
            var newProjectItem = activeProject.ProjectItems.AddFromFile(fileName);

            if (newProjectItem == null)
            {
                string message = string.Format(Resources.Error_CreatingFile).Replace(@"\n", "\n");
                MessageBox.Show(message, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(newProjectItem);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds a new License Header Definition file to the active project.
        /// </summary>
        public static bool AddLicenseHeaderDefinitionFileToProject(Project activeProject, IDefaultLicenseHeaderPage page)
        {
            if (activeProject == null)
            return false;

              var fileName = GetNewFileName (activeProject);
              File.WriteAllText (fileName, page.LicenseHeaderFileText);
              var newProjectItem = activeProject.ProjectItems.AddFromFile (fileName);

              if (newProjectItem != null)
              {
            var window = newProjectItem.Open (Constants.vsViewKindCode);
            window.Activate();
            return true;
              }
              else
              {
            string message = string.Format (Resources.Error_CreatingFile).Replace (@"\n", "\n");
            MessageBox.Show (message, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            return false;
              }
        }
Ejemplo n.º 10
0
        public static bool ShowQuestionForAddingLicenseHeaderFile(Project activeProject, IDefaultLicenseHeaderPage page)
        {
            string message          = string.Format(Resources.Error_NoHeaderDefinition, activeProject.Name).Replace(@"\n", "\n");
            var    messageBoxResult = MessageBox.Show(message, Resources.Error, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (messageBoxResult != MessageBoxResult.Yes)
            {
                return(false);
            }
            var licenseHeaderDefinitionFile = AddHeaderDefinitionFile(activeProject, page);

            licenseHeaderDefinitionFile.Open(Constants.vsViewKindCode).Activate();
            return(true);
        }
 public AddLicenseHeaderToAllProjectsButtonHandler(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage defaultLicenseHeaderPage, DTE2 dte2)
 {
     _licenseReplacer          = licenseReplacer;
     _defaultLicenseHeaderPage = defaultLicenseHeaderPage;
     _dte2 = dte2;
 }
 public AddLicenseHeaderToAllProjectsButtonHandler(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage defaultLicenseHeaderPage, DTE2 dte2)
 {
   _licenseReplacer = licenseReplacer;
   _defaultLicenseHeaderPage = defaultLicenseHeaderPage;
   _dte2 = dte2;
 }
        private static IEnumerable<ProjectItem> AddNewLicenseHeaderDefinitionFilesToProjects(List<Project> projectsWithoutLicenseHeader,
      IDefaultLicenseHeaderPage page)
        {
            List<ProjectItem> newLicenseHeaders = new List<ProjectItem>();

              foreach (Project project in projectsWithoutLicenseHeader)
              {
            if (projectsWithoutLicenseHeader.Contains(project))
              newLicenseHeaders.Add(LicenseHeader.AddLicenseHeaderDefinitionFile(project, page));
              }

              return newLicenseHeaders;
        }
 public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage licenseHeaderPage, SolutionUpdateViewModel solutionUpdateViewModel)
 {
     _licenseHeaderPage       = licenseHeaderPage;
     _licenseReplacer         = licenseReplacer;
     _solutionUpdateViewModel = solutionUpdateViewModel;
 }
        private IEnumerable <ProjectItem> AddNewLicenseHeaderDefinitionFilesToProjects(List <Project> projectsWithoutLicenseHeader,
                                                                                       IDefaultLicenseHeaderPage page)
        {
            List <ProjectItem> newLicenseHeaders = new List <ProjectItem>();

            foreach (Project project in projectsWithoutLicenseHeader)
            {
                if (projectsWithoutLicenseHeader.Contains(project))
                {
                    newLicenseHeaders.Add(LicenseHeader.AddLicenseHeaderDefinitionFile(project, page));
                }
            }

            return(newLicenseHeaders);
        }
 public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage licenseHeaderPage, SolutionUpdateViewModel solutionUpdateViewModel)
 {
   _licenseHeaderPage = licenseHeaderPage;
   _licenseReplacer = licenseReplacer;
   _solutionUpdateViewModel = solutionUpdateViewModel;
 }