Ejemplo n.º 1
0
        /// <summary>
        ///   Adds a new License Header Definition file to the active folder.
        /// </summary>
        /// <param name="folder">The folder where the file will be inserted.</param>
        /// <param name="pageModel">The page model where the license header definition text is stored.</param>
        /// <returns></returns>
        public static ProjectItem AddLicenseHeaderDefinitionFile(ProjectItem folder, IDefaultLicenseHeaderPageModel pageModel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (folder == null || folder.Kind != Constants.vsProjectItemKindPhysicalFolder)
            {
                return(null);
            }

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

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

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

            OpenNewProjectItem(newProjectItem);

            return(newProjectItem);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Adds a new License Header Definition file to the active project.
        /// </summary>
        /// <param name="activeProject">The project where the defintion file will be inserted.</param>
        /// <param name="pageModel">The page model where the license header definition text is stored.</param>
        /// <returns></returns>
        public static ProjectItem AddHeaderDefinitionFile(Project activeProject, IDefaultLicenseHeaderPageModel pageModel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (IsInvalidProject(activeProject))
            {
                return(null);
            }

            var fileName = GetNewFullName(activeProject);

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

            if (newProjectItem == null)
            {
                var message = string.Format(Resources.Error_CreatingFile).ReplaceNewLines();
                MessageBoxHelper.ShowError(message);
            }

            return(newProjectItem);
        }
 public WpfDefaultLicenseHeader(IDefaultLicenseHeaderPageModel pageModel)
     : this()
 {
     _pageModel  = pageModel;
     DataContext = _pageModel;
 }
 public WpfEditDefaultLicenseHeaderDialog(IDefaultLicenseHeaderPageModel pageModel)
     : this()
 {
     DataContext = pageModel;
 }
Ejemplo n.º 5
0
        /// <summary>
        ///   Shows a message box that asks if a new License Header Definition File should be added to the active project.
        /// </summary>
        /// <param name="activeProject">The project where the definition file will be inserted.</param>
        /// <param name="pageModel">The page model where the license header definition text is stored.</param>
        /// <returns>True if a new License Header Definition file should be added to the current project, otherwise false.</returns>
        public static bool ShowQuestionForAddingLicenseHeaderFile(Project activeProject, IDefaultLicenseHeaderPageModel pageModel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var message = string.Format(Resources.Error_NoHeaderDefinition, activeProject.Name).ReplaceNewLines();

            if (!MessageBoxHelper.AskYesNo(message, Resources.Error))
            {
                return(false);
            }
            var licenseHeaderDefinitionFile = AddHeaderDefinitionFile(activeProject, pageModel);

            licenseHeaderDefinitionFile.Open(Constants.vsViewKindCode).Activate();
            return(true);
        }