static public string GetUniqueUIName(IVsProject project)
        {
            IVsSolution3 solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution3;
            string       name     = null;
            int          hr       = solution.GetUniqueUINameOfProject((IVsHierarchy)project, out name);

            System.Diagnostics.Debug.Assert(hr == VSConstants.S_OK, "GetUniqueUINameOfProject failed.");
            return(name);
        }
Пример #2
0
        /// <summary>
        /// Called by MyProjectTracker to get the name of the event's project.
        /// If project==null then gets the Solution name.
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public string GetProjectName(IVsProject project)
        {
            if (project == null)
            {
                return(Resources.RootSolution); // GetSolutionName();
            }

            IVsSolution3 solution    = Solution as IVsSolution3;
            string       projectName = null;

            ErrorHandler.ThrowOnFailure(solution.GetUniqueUINameOfProject((IVsHierarchy)project, out projectName));
            return(projectName);
        }
Пример #3
0
 protected override void OnExec()
 {
     if (template.IsVisibleFromContextMenu)
     {
         IConfigurationService configService =
             (IConfigurationService)ServiceProvider.GetService(typeof(IConfigurationService), true);
         if (template.Kind == TemplateKind.Project)
         {
             IVsSolution3             solution = (IVsSolution3)ServiceProvider.GetService(typeof(SVsSolution), true);
             IVsBrowseProjectLocation browseProjectLocation = null;
             uint cnpvdeFlags = (uint)(__VSCREATENEWPROJVIADLGEXFLAGS.VNPVDE_ALWAYSADDTOSOLUTION | __VSCREATENEWPROJVIADLGEXFLAGS.VNPVDE_ADDNESTEDTOSELECTION);
             //browseProjectLocation = this;
             //cnpvdeFlags |= (uint)(__VSCREATENEWPROJVIADLGEXFLAGS.VNPVDE_OVERRIDEBROWSEBUTTON);
             solution.CreateNewProjectViaDlgEx(Microsoft.Practices.RecipeFramework.VisualStudio.Properties.Resources.IDD_ADDPROJECTDLG,
                                               null,
                                               configService.CurrentPackage.Caption,
                                               this.template.Name,
                                               null,
                                               cnpvdeFlags,
                                               browseProjectLocation);
         }
         else if (template.Kind == TemplateKind.ProjectItem)
         {
             uint                  itemid            = 0;
             IVsProject            vsProject         = DteHelper.GetCurrentSelection(this.ServiceProvider, out itemid) as IVsProject;
             IVsAddProjectItemDlg2 addProjectItemDlg =
                 (IVsAddProjectItemDlg2)ServiceProvider.GetService(typeof(SVsAddProjectItemDlg), true);
             __VSADDITEMFLAGS addItemsFlags = __VSADDITEMFLAGS.VSADDITEM_AddNewItems | __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName;
             Guid             projectGuid   = this.template.ProjectFactory;
             string           location      = String.Empty;
             string           filter        = String.Empty;
             int dontShowAgain = VSConstantsEx.TRUE;
             addProjectItemDlg.AddProjectItemDlgTitled(itemid,
                                                       ref projectGuid,
                                                       vsProject,
                                                       (uint)addItemsFlags,
                                                       null,
                                                       configService.CurrentPackage.Caption,
                                                       this.template.Name,
                                                       ref location,
                                                       ref filter,
                                                       out dontShowAgain);
         }
     }
 }
Пример #4
0
 public SolutionWrapper(
     IVsSolution solution,
     IVsSolution2 solution2 = null,
     IVsSolution3 solution3 = null,
     IVsSolution4 solution4 = null,
     IVsSolution5 solution5 = null,
     IVsSolution6 solution6 = null,
     IVsSolution7 solution7 = null,
     IVsSolution8 solution8 = null
     )
 {
     _solution  = solution;
     _solution2 = solution2;
     _solution3 = solution3;
     _solution4 = solution4;
     _solution5 = solution5;
     _solution6 = solution6;
     _solution7 = solution7;
     _solution8 = solution8;
 }
Пример #5
0
        public static bool AddProjectDialog(
            IServiceProvider provider,
            string title,
            string templateName)
        {
            Guard.ArgumentNotNull(provider, "provider");
            Guard.ArgumentNotNullOrEmptyString(title, "title");
            Guard.ArgumentNotNullOrEmptyString(templateName, "templateName");

            try
            {
                IVsSolution solution = provider.GetService(typeof(IVsSolution)) as IVsSolution;
                uint        pitemid  = 0;
                using (HierarchyNode hierarchy = new HierarchyNode(solution, DteHelper2.GetCurrentSelection(provider, out pitemid)))
                {
                    if (hierarchy.IsSolution)
                    {
                        string       templatePath = null;// (hierarchy.Hierarchy as EnvDTE.Solution).TemplatePath;
                        IVsSolution3 sln          = (IVsSolution3)hierarchy.Hierarchy;
                        ErrorHandler.ThrowOnFailure(sln.CreateNewProjectViaDlgEx(
                                                        title, templatePath, "Visual C#", templateName, null, (uint)__VSCREATENEWPROJVIADLGEXFLAGS.VNPVDE_ALWAYSADDTOSOLUTION, null));
                    }
                }
                return(true);
            }
            catch (COMException comEx)
            {
                if (comEx.ErrorCode != VSConstants.OLE_E_PROMPTSAVECANCELLED)
                {
                    Logger.Write(comEx);
                }
            }
            catch (Exception error)
            {
                Logger.Write(error);
            }
            return(false);
        }
Пример #6
0
 public ISolutionNode Adapt(IVsSolution3 from)
 {
     return(CreateNode((IVsHierarchy)from) as ISolutionNode);
 }
Пример #7
0
 public VsSolution3(IVsSolution3 solution)
 {
     _solution = solution;
 }