private CommandID GetCommandID(Configuration.CommandBar commandBar) { if (commandBar.NameSpecified) { return(ShellCmdDef.GetPredefinedCommandID(commandBar.Name)); } else if (!string.IsNullOrEmpty(commandBar.Menu)) { if (menus.ContainsKey(commandBar.Menu)) { MenuGroup menuGroup = (MenuGroup)menus[commandBar.Menu]; return(menuGroup.Group); } else { throw new InvalidOperationException( String.Format(Properties.Resources.CTC_MenuDoesNotExist, commandBar.Menu)); } } else { int commandId = 0; Guid guid = ShellCmdDef.guidSHLMainMenu; if (commandBar.IDSpecified) { commandId = commandBar.ID; } if (commandBar.Guid != null) { guid = new Guid(commandBar.Guid); } return(new CommandID(guid, commandId)); } }
private CommandID GetIcon(Configuration.Icon icon) { if (icon != null) { Guid iconGuid = this.defaultIcon.Guid; int iconId = this.defaultIcon.ID; if (icon.IDSpecified) { iconId = icon.ID; if (icon.Guid == null) { iconGuid = ShellCmdDef.guidOfficeIcon; } } if (icon.Guid != null) { iconGuid = new Guid(icon.Guid); } return(ShellCmdDef.MapIconToBitmap(new CommandID(iconGuid, iconId))); } else { return(this.defaultIcon); } }
private CommandID CreateBitmap(IVsTemplate template) { if (!string.IsNullOrEmpty(template.IconFileName)) { string fileIcon = new FileInfo(template.FileName).Directory + "\\" + template.IconFileName; return(LoadBitmap(fileIcon)); } return(ShellCmdDef.MapIconToBitmap(template.Icon)); }
private void AddTemplateCommand(IVsTemplate template) { if (template.Kind == TemplateKind.Solution) { return; } Configuration.RecipeHostData hostData = null; if (template.ExtensionData != null && !string.IsNullOrEmpty(template.ExtensionData.Recipe)) { Configuration.Recipe recipeConfig = GetRecipeConfig(template.ExtensionData.Recipe); if (recipeConfig != null && recipeConfig.HostData != null && recipeConfig.HostData.CommandBar != null) { hostData = recipeConfig.HostData; // Set the host data to null to avoid registering two commands recipeConfig.HostData = null; } } int priority = CTCBuilder.defaultPriority; CommandID icon = CreateBitmap(template); if (hostData != null) { hostData.Icon = new Configuration.Icon(); hostData.Icon.Guid = icon.Guid.ToString(); hostData.Icon.ID = icon.ID; priority = hostData.Priority; } ; Button myButton = new Button(template.Command, this.PackageGroup.Group, priority, icon, CommandType.Button, Util.DisabledDefault, guidancePackage.Caption + "." + template.Name); AddCommand(myButton, hostData); if (hostData == null) { // Add the template command in the standard places CommandID parentCommand = null; if (template.Kind == TemplateKind.ProjectItem) { parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.ProjectAdd); AddGroupPlacement(myButton, parentCommand); } else if (template.Kind == TemplateKind.Project) { parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.SolutionAdd); AddGroupPlacement(myButton, parentCommand); } parentCommand = ShellCmdDef.GetPredefinedCommandID(Configuration.CommandBarName.SolutionFolderAdd); AddGroupPlacement(myButton, parentCommand); } }