static void Main(string[] args) { PPTLibrary.PPT ppt = new PPTLibrary.PPT(); PPTPaneManager manager = new PPTPaneManager(ppt); manager.ShapeMarker = new DefaultShapeMarker(); // Not currently working b/c of PPT Shadow.Visible bug (demonstrated by HandleTestWSC above and: create two objects, select them, group them, ungroup them, unselect them, select one of them. ppt.App.Activate(); Console.ReadLine(); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { ppt = new PPTLibrary.PPT(this.Application); pptpm = new PPTPaneManagement.PPTPaneManager(ppt, ribbon); }
//public PPTPaneManager(string[] modes) : this(modes, new PPTLibrary.PPT()) { } public PPTPaneManager(string[] modes, PPTLibrary.PPT ppt, InstructorModeRibbon r) { if (modes == null) { modes = DEFAULT_MODES; } if (ppt == null) { throw new ArgumentNullException("ppt"); } this.myPPT = ppt; this.ribbon = r; // Set up the list of modes; should match the ordering of the buttons in the mode button bars. this.myModes = new string[modes.Length + 1]; System.Array.Copy(modes, 0, this.myModes, 1, modes.Length); this.myModes[0] = DEFAULT_MODE; this.ribbon.PresentationModeChanged += new ChangedEventHandler(this.HandlePresentationModeClick); this.ribbon.ShapeModeChanged += new ChangedEventHandler(this.HandleShapeModeClick); /* DONE CMPRINCE: Add the appropriate code here to hook up to the button events * // Set up the bars. * this.myPresentationModeBar = this.myPPT.AddCommandBar(PRESENTATION_MODEBAR_NAME, * Core.MsoBarPosition.msoBarTop, true, true); * this.myShapeModeBar = this.myPPT.AddCommandBar(SHAPE_MODEBAR_NAME, * Core.MsoBarPosition.msoBarTop, true, true); * * // Add the "base" buttons * Core.CommandBarButton button = (Core.CommandBarButton) * this.myPPT.AddControl(this.myPresentationModeBar, Core.MsoControlType.msoControlButton, "Projected View"); * button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandlePresentationModeClick); * button.TooltipText = "Switch to base mode in which only unrestricted objects are visible."; * button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; * * button = (Core.CommandBarButton) * this.myPPT.AddControl(this.myShapeModeBar, Core.MsoControlType.msoControlButton, "Unrestricted"); * button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleShapeModeClick); * button.TooltipText = "Set shape(s) to be unrestricted, making them visible in all modes."; * button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; * * foreach (string mode in modes) { * button = (Core.CommandBarButton) * this.myPPT.AddControl(this.myPresentationModeBar, Core.MsoControlType.msoControlButton, mode + " View"); * button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandlePresentationModeClick); * button.TooltipText = "Toggle '" + mode + " View'.\nOnly unrestricted objects and objects restricted to '" + mode + " View' are visible in '" + mode + " View'."; * button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; * * button = (Core.CommandBarButton) * this.myPPT.AddControl(this.myShapeModeBar, Core.MsoControlType.msoControlButton, mode + " Note"); * button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleShapeModeClick); * button.TooltipText = "Toggle restriction of shape(s) to '" + mode + "' mode.\nUnrestricted objects are visible in all modes.\nRestricted objects are visible only in the modes to which they are restricted."; * button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; * } */ // Hook to relevant PPT events. this.myPPT.App.WindowActivate += new PowerPoint.EApplication_WindowActivateEventHandler(this.HandleWindowActivate); this.myPPT.App.WindowDeactivate += new PowerPoint.EApplication_WindowDeactivateEventHandler(this.HandleWindowDeactivate); this.myPPT.App.WindowSelectionChange += new PowerPoint.EApplication_WindowSelectionChangeEventHandler(this.HandleWindowSelectionChange); // New presentation event doesn't seem to be working in pre-SP2 (or possibly SP1). this.myPPT.App.AfterNewPresentation += new PowerPoint.EApplication_AfterNewPresentationEventHandler(this.HandleAfterNewPresentation); this.myPPT.App.PresentationSave += new PowerPoint.EApplication_PresentationSaveEventHandler(this.HandlePresentationSave); this.myPPT.App.AfterPresentationOpen += new PowerPoint.EApplication_AfterPresentationOpenEventHandler(this.HandleAfterPresentationOpen); this.myPPT.App.PresentationNewSlide += new PowerPoint.EApplication_PresentationNewSlideEventHandler(this.HandlePresentationNewSlide); this.ConfigurePresentationModeBar(); this.ConfigureShapeModeBar(); foreach (PowerPoint.Presentation presentation in this.myPPT.App.Presentations) { this.RebuildCache(presentation); } }
//public PPTPaneManager(string[] modes) : this(modes, new PPTLibrary.PPT()) { } public PPTPaneManager(string[] modes, PPTLibrary.PPT ppt) { if (modes == null) modes = DEFAULT_MODES; if (ppt == null) throw new ArgumentNullException("ppt"); this.myPPT = ppt; // Set up the list of modes; should match the ordering of the buttons in the mode button bars. this.myModes = new string[modes.Length + 1]; System.Array.Copy(modes, 0, this.myModes, 1, modes.Length); this.myModes[0] = DEFAULT_MODE; // Set up the bars. this.myPresentationModeBar = this.myPPT.AddCommandBar(PRESENTATION_MODEBAR_NAME, Core.MsoBarPosition.msoBarTop, true, true); this.myShapeModeBar = this.myPPT.AddCommandBar(SHAPE_MODEBAR_NAME, Core.MsoBarPosition.msoBarTop, true, true); // Add the "base" buttons Core.CommandBarButton button = (Core.CommandBarButton) this.myPPT.AddControl(this.myPresentationModeBar, Core.MsoControlType.msoControlButton, "Projected View"); button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandlePresentationModeClick); button.TooltipText = "Switch to base mode in which only unrestricted objects are visible."; button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; button = (Core.CommandBarButton) this.myPPT.AddControl(this.myShapeModeBar, Core.MsoControlType.msoControlButton, "Unrestricted"); button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleShapeModeClick); button.TooltipText = "Set shape(s) to be unrestricted, making them visible in all modes."; button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; foreach (string mode in modes) { button = (Core.CommandBarButton) this.myPPT.AddControl(this.myPresentationModeBar, Core.MsoControlType.msoControlButton, mode + " View"); button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandlePresentationModeClick); button.TooltipText = "Toggle '" + mode + " View'.\nOnly unrestricted objects and objects restricted to '" + mode + " View' are visible in '" + mode + " View'."; button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; button = (Core.CommandBarButton) this.myPPT.AddControl(this.myShapeModeBar, Core.MsoControlType.msoControlButton, mode + " Note"); button.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleShapeModeClick); button.TooltipText = "Toggle restriction of shape(s) to '" + mode + "' mode.\nUnrestricted objects are visible in all modes.\nRestricted objects are visible only in the modes to which they are restricted."; button.Style = Core.MsoButtonStyle.msoButtonWrapCaption; } // Hook to relevant PPT events. this.myPPT.App.WindowActivate += new PowerPoint.EApplication_WindowActivateEventHandler(this.HandleWindowActivate); this.myPPT.App.WindowDeactivate += new PowerPoint.EApplication_WindowDeactivateEventHandler(this.HandleWindowDeactivate); this.myPPT.App.WindowSelectionChange += new PowerPoint.EApplication_WindowSelectionChangeEventHandler(this.HandleWindowSelectionChange); // New presentation event doesn't seem to be working in pre-SP2 (or possibly SP1). this.myPPT.App.AfterNewPresentation += new PowerPoint.EApplication_AfterNewPresentationEventHandler(this.HandleAfterNewPresentation); this.myPPT.App.PresentationSave += new PowerPoint.EApplication_PresentationSaveEventHandler(this.HandlePresentationSave); this.myPPT.App.AfterPresentationOpen += new PowerPoint.EApplication_AfterPresentationOpenEventHandler(this.HandleAfterPresentationOpen); this.myPPT.App.PresentationNewSlide += new PowerPoint.EApplication_PresentationNewSlideEventHandler(this.HandlePresentationNewSlide); this.ConfigurePresentationModeBar(); this.ConfigureShapeModeBar(); foreach (PowerPoint.Presentation presentation in this.myPPT.App.Presentations) this.RebuildCache(presentation); }
public static void Main(string[] args) { PPTLibrary.PPT ppt = new PPTLibrary.PPT(); PPTPaneManagement.PPTPaneManager paneMgr = new PPTPaneManagement.PPTPaneManager(ppt); PPTDeckBuilder builder = new PPTDeckBuilder(ppt, paneMgr #if SIP_MODE , null #endif ); ppt.App.Activate(); Console.ReadLine(); }
//public PPTPaneManager() : this(DEFAULT_MODES) { } public PPTPaneManager(PPTLibrary.PPT ppt, InstructorModeRibbon r) : this(DEFAULT_MODES, ppt, r) { }
public const int PPT_SAVE_AS_ID = 748; // Determined by experimentation; should hold regardless of language. /// <summary> /// Creates the PPT automation component which handles exporting CSD decks from PPT. /// </summary> /// <param name="ppt">non-null ppt library accessor</param> /// <param name="paneManager">pane manager or null if no pane management is to be used</param> public PPTDeckBuilder(PPTLibrary.PPT ppt, PPTPaneManagement.PPTPaneManager paneManager) #endif { if (ppt == null) throw new ArgumentNullException("ppt"); // Hook up to arguments. this.myPPT = ppt; // Prepare the loader. this.myLoader = new PPTSlideLoader(DEFAULT_SIZE, DEFAULT_COMMENT_TYPE, this.myPPT, paneManager #if SIP_MODE , propertyManager #endif ); // Find the menubar. Core.CommandBar menu = null; foreach (Core.CommandBar cb in this.myPPT.App.CommandBars) if (cb.Id == PPT_MENU_BAR_ID) { menu = cb; break; } if (menu == null) throw new Exception("PPTDeckBuilderAddin: Unable to find the PowerPoint menu bar."); // Find the file menu. Core.CommandBarPopup fileMenu = null; foreach (Core.CommandBarControl bar in menu.Controls) if (bar.Id == PPT_FILE_ID) { fileMenu = (Core.CommandBarPopup)bar; break; } if (fileMenu == null) throw new Exception("PPTDeckBuilderAddin: Unable to find the PowerPoint file menu."); // Find the Save As.. button. // And see if the export to CSD button is already there. Core.CommandBarControl saveAs = null; foreach (Core.CommandBarControl control in fileMenu.Controls) { if (control.Id == PPT_SAVE_AS_ID) saveAs = control; if (control.Caption == "&Export to CSD...") control.Delete(false); // Delete permanently. if (control.Caption == "Load &Feedback Menu...") control.Delete(false); } // Add and configure the export to CSD button... this.myExportButton = (Core.CommandBarButton)fileMenu.Controls.Add( Core.MsoControlType.msoControlButton, System.Reflection.Missing.Value, // Not a built in button: no ID. System.Reflection.Missing.Value, // No parameters used. (saveAs == null) ? (object)System.Reflection.Missing.Value : (object)(saveAs.Index + 1), // Place just after Save As... if possible. true); // Temporary (disappear on closing PPT). this.myExportButton.Caption = "&Export to CSD..."; this.myExportButton.DescriptionText = "Export the current presentation to the Conferencing Slide Deck format."; this.myExportButton.TooltipText = this.myExportButton.DescriptionText; this.myExportButton.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleCSDButtonClick); this.myExportButton.Visible = true; this.ConfigureButton(); // Add and configure the load feedback menu button... this.myFeedbackButton = (Core.CommandBarButton)fileMenu.Controls.Add( Core.MsoControlType.msoControlButton, System.Reflection.Missing.Value, // Not a built in button: no ID. System.Reflection.Missing.Value, // No parameters used. (object)(this.myExportButton.Index + 1), // Place just after Export to CSD true); // Temporary (disappear on closing PPT). this.myFeedbackButton.Caption = "Load &Feedback Menu..."; this.myFeedbackButton.DescriptionText = "Load a feedback menu to associate with this deck."; this.myFeedbackButton.TooltipText = this.myFeedbackButton.DescriptionText; this.myFeedbackButton.Click += new Core._CommandBarButtonEvents_ClickEventHandler(this.HandleFeedbackButtonClick); this.myFeedbackButton.Visible = true; this.ConfigureButton(); // Hook up to events to enable/disable the export button. this.myPPT.App.PresentationClose += new PowerPoint.EApplication_PresentationCloseEventHandler(this.HandlePresentation); this.myPPT.App.PresentationOpen += new PowerPoint.EApplication_PresentationOpenEventHandler(this.HandlePresentation); this.myPPT.App.WindowActivate += new PowerPoint.EApplication_WindowActivateEventHandler(this.HandleWindow); this.myPPT.App.WindowDeactivate += new PowerPoint.EApplication_WindowDeactivateEventHandler(this.HandleWindow); }
/// <param name="ppt">non-null ppt library accessor</param> /// <param name="paneManager">pane manager or null if no pane management is to be used</param> public PPTSlideLoader(Size viewerSize, int commentMenuType, PPTLibrary.PPT ppt, PPTPaneManagement.PPTPaneManager paneManager) #endif { if (ppt == null) throw new ArgumentNullException("ppt"); this.myPPT = ppt; this.myPaneManager = paneManager; #if SIP_MODE this.myPropertyManager = propertyManager; #endif this.myViewerSize = viewerSize; this.myDefaultCommentMenuType = commentMenuType; this.myFilesLoaded = 0; this.myTemporaryDirectoryPath = Path.GetTempPath() + "\\DeckBuilderTempFiles"; try { if (Directory.Exists(this.myTemporaryDirectoryPath)) Directory.Delete(this.myTemporaryDirectoryPath, true); // Delete directory to clean up old files Directory.CreateDirectory(this.myTemporaryDirectoryPath); } catch (IOException e) { Console.WriteLine(e.Message); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { if (!(application is PowerPoint.Application)) throw new ArgumentException("must be a PowerPoint Application object.. perhaps you are running the add-in with the wrong application?", "application"); // Start PPT. this.myPPT = new PPTLibrary.PPT((PowerPoint.Application)application); this.myPPT.CloseOnExit = PPTLibrary.PPT.CloseConditions.Never; // I don't trust PPT objects to close PowerPoint correctly. this.myPaneManager = new PPTPaneManagement.PPTPaneManager(this.myPPT); this.myDeckBuilder = new PPTDeckBuilder.PPTDeckBuilder(this.myPPT, this.myPaneManager); applicationObject = application; addInInstance = addInInst; }
/// <summary> /// Implements the OnDisconnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being unloaded. /// </summary> /// <param term='disconnectMode'> /// Describes how the Add-in is being unloaded. /// </param> /// <param term='custom'> /// Array of parameters that are host application specific. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom) { if (this.myPaneManager != null) this.myPaneManager.Hide(); this.myPaneManager = null; this.myDeckBuilder = null; this.myPPT = null; }