private void EnsureSolutionsModule() { try { //Declarations Outlook.Folder solutionRoot; Outlook.Folder solutionCalendar; Outlook.Folder solutionContacts; Outlook.Folder solutionTasks; bool firstRun = false; Outlook.Folder rootStoreFolder = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder; //If solution root folder does not exist, create it //Note that solution root //could also be in PST or custom store try { solutionRoot = rootStoreFolder.Folders["Solution Demo"] as Outlook.Folder; } catch { firstRun = true; } if (firstRun == true) { solutionRoot = rootStoreFolder.Folders.Add("Solution Demo", Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder; solutionCalendar = solutionRoot.Folders.Add( "Solution Calendar", Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder; solutionContacts = solutionRoot.Folders.Add( "Solution Contacts", Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder; solutionTasks = solutionRoot.Folders.Add( "Solution Tasks", Outlook.OlDefaultFolders.olFolderTasks) as Outlook.Folder; } else { solutionRoot = rootStoreFolder.Folders["Solution Demo"] as Outlook.Folder; solutionCalendar = solutionRoot.Folders[ "Solution Calendar"] as Outlook.Folder; solutionContacts = solutionRoot.Folders[ "Solution Contacts"] as Outlook.Folder; solutionTasks = solutionRoot.Folders[ "Solution Tasks"] as Outlook.Folder; } //Get the icons for the solution stdole.StdPicture rootPict = PictureDispConverter.ToIPictureDisp( Properties.Resources.BRIDGE) as stdole.StdPicture; stdole.StdPicture calPict = PictureDispConverter.ToIPictureDisp( Properties.Resources.umbrella) as stdole.StdPicture; stdole.StdPicture contactsPict = PictureDispConverter.ToIPictureDisp( Properties.Resources.group) as stdole.StdPicture; stdole.StdPicture tasksPict = PictureDispConverter.ToIPictureDisp( Properties.Resources.SUN) as stdole.StdPicture; //Set the icons for solution folders solutionRoot.SetCustomIcon(rootPict); solutionCalendar.SetCustomIcon(calPict); solutionContacts.SetCustomIcon(contactsPict); solutionTasks.SetCustomIcon(tasksPict); //Obtain a reference to the SolutionsModule Outlook.Explorer explorer = Application.ActiveExplorer(); solutionsModule = explorer.NavigationPane.Modules.GetNavigationModule( Outlook.OlNavigationModuleType.olModuleSolutions) as Outlook.SolutionsModule; //Add the solution and hide folders in default modules solutionsModule.AddSolution(solutionRoot, Outlook.OlSolutionScope.olHideInDefaultModules); //The following code sets the position and visibility //of the SolutionsModule if (solutionsModule.Visible == false) { //Set Visibile to true solutionsModule.Visible = true; } if (solutionsModule.Position != 5) { //Move SolutionsModule to Position = 5 solutionsModule.Position = 5; } //Create instance variable for Outlook.NavigationPane Outlook.NavigationPane navPane = explorer.NavigationPane; if (navPane.DisplayedModuleCount != 5) { //Ensure that Solutions Module button is large navPane.DisplayedModuleCount = 5; } } catch (Exception ex) { Debug.Write(ex.Message); } }
///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. protected override void Initialize() { base.Initialize(); seEvents = new SolutionEvents(this); outWindow = new OutputWindowWriter(this); //Install commandbar and menu items // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. Build Command CommandID menuBuild = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleBuild); MenuCommand buildItem = new MenuCommand(MarbleBuildCallback, menuBuild); mcs.AddCommand(buildItem); //Rebuild Command CommandID menuRebuild = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleRebuild); MenuCommand rebuildItem = new MenuCommand(MarbleRebuildCallback, menuRebuild); mcs.AddCommand(rebuildItem); //Clean Command CommandID menuClean = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleClean); MenuCommand cleanItem = new MenuCommand(MarbleCleanCallback, menuClean); mcs.AddCommand(cleanItem); } bool bCmdsInstalled = false; applicationObject = (DTE)GetService(typeof(DTE)); CommandBars commandBars = (CommandBars)applicationObject.CommandBars; try { cbMarbleBar = commandBars["Marble"]; } catch (ArgumentException e) { } if (cbMarbleBar == null) { //Add Marble as an available command bar cbMarbleBar = commandBars.Add("Marble", MsoBarPosition.msoBarTop); } else { bCmdsInstalled = true; } //Get Red/Green Light icons for status picGreenLight = ImageHelper.GetIPictureFromImage(Resources.GreenLight.ToBitmap()); picRedLight = ImageHelper.GetIPictureFromImage(Resources.RedLight.ToBitmap()); //Add Marble Build Button CommandBarButton cbButtonBuildMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleBuild); cbButtonBuildMarble.Caption = "Marble Build"; cbButtonBuildMarble.TooltipText = "Builds using the Marble Framework"; cbButtonBuildMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonBuildMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Build.ToBitmap()); cbButtonBuildMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleBuildClick); //Add Marble Rebuild Button CommandBarButton cbButtonRebuildMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleRebuild); cbButtonRebuildMarble.Caption = "Marble Rebuild"; cbButtonRebuildMarble.TooltipText = "Rebuilds the solution using the Marble Framework"; cbButtonRebuildMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonRebuildMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Rebuild.ToBitmap()); cbButtonRebuildMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleRebuildClick); //Add Marble Clean Button CommandBarButton cbButtonCleanMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleClean); cbButtonCleanMarble.Caption = "Marble Clean"; cbButtonCleanMarble.TooltipText = "Cleans changes made by the Marble Framework"; cbButtonCleanMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonCleanMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Clean.ToBitmap()); cbButtonCleanMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleCleanClick); //Add Algorithm Name cbbAlgorithm = (CommandBarButton)cbMarbleBar.Controls.Add(); cbbAlgorithm.Caption = "Algorithm Used"; cbbAlgorithm.Style = MsoButtonStyle.msoButtonCaption; cbbAlgorithm.Enabled = false; //Add Current State cbbState = (CommandBarButton)cbMarbleBar.Controls.Add(); cbbState.Caption = sCleanText; cbbState.Style = MsoButtonStyle.msoButtonIconAndCaption; cbbState.State = MsoButtonState.msoButtonUp; cbbState.Picture = picGreenLight; //Start with green light cbbState.Enabled = true; //make command bar enabled and visible cbMarbleBar.Enabled = true; if (!bCmdsInstalled) { cbMarbleBar.Visible = true; } //Register for new/open solution events seEvents.RegisterSolutionEvents(); }