Exemplo n.º 1
0
        public AdPane(JournalPresentation journal)
        {
            if (journal == null) throw new ArgumentNullException("journal");
            InitializeComponent();

            this.journal = journal;
            this.window = journal.Presentation.Windows[1];

            adType.Properties.Items.AddRange(Names.AdTypes);
            adType.Properties.DropDownRows = Names.AdTypes.Count;

            colMensSeats.Caption = MelaveMalkaSeat.MensSeatsCaption;
            colWomensSeats.Caption = MelaveMalkaSeat.WomensSeatsCaption;

            //The grids are bound indirectly through two FrameworkBindingSource
            //so that they don't re-apply settings at every change.
            paymentsSource.DataMember = pledgesSource.DataMember = null;
            pledgesGrid.DataSource = pledgesSource;
            paymentsGrid.DataSource = paymentsSource;
            SetAd(window.CurrentAd(), force: true);

            adSearcher.Properties.DataSource = new FilteredTable<Pledge>(
                Program.Table<Pledge>(),
                p => p.ExternalSource == "Journal " + journal.Year
            );
            EditorRepository.PersonOwnedLookup.Apply(adSearcher.Properties);
            adSearcher.Properties.Columns.Add(new DataSourceColumn("SubType") { Caption = "Type" });
            adSearcher.Properties.Columns.Insert(0, new DataSourceColumn("ExternalId", 35) { Caption = "ID" });
            adSearcher.Properties.Columns.RemoveAt(adSearcher.Properties.Columns.FindIndex(c => c.Caption == "Zip code"));

            window.Application.WindowSelectionChange += Application_WindowSelectionChange;
        }
Exemplo n.º 2
0
        private void Application_WindowActivate(PowerPoint.Presentation Pres, PowerPoint.DocumentWindow Wn)
        {
            //throw new NotImplementedException();
            //            MessageBox.Show("hehe");

            try
            {
                Office.DocumentProperties prp = this.Application.ActivePresentation.CustomDocumentProperties;

                bool isSenitive = false;

                foreach (Office.DocumentProperty documentProperty in prp)
                {
                    if (documentProperty.Name.Equals("Sensitive"))
                    {
                        InitRabbionControl(documentProperty.Value);
                        isSenitive = true;
                    }
                }

                if (isSenitive == false)
                {
                    InitRabbionControl(string.Empty);
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.ToString());
                throw;
            }
        }
Exemplo n.º 3
0
 private static PowerPoint.Shape createHeaderLine(PowerPoint.DocumentWindow window, PowerPoint.Shape shape)
 {
     PowerPoint.Shape conn = null;
     try
     {
         // starting x and y values
         float x = shape.Left + shape.Width;
         float y = shape.Top + shape.Height / 2;
         // add the connector line
         // from http://msdn.microsoft.com/en-us/library/ff744679(v=office.14).aspx
         // AddConnector(Type, BeginX, BeginY, EndX, EndY)
         conn = window.View.Slide.Shapes.
                AddConnector(Office.MsoConnectorType.msoConnectorStraight, x, y, x + 100, y);
         // connect it to the shape
         conn.ConnectorFormat.BeginConnect(shape, 4);
         // set height to 0 (need to make sure end is disconnected first)
         conn.ConnectorFormat.EndDisconnect();
         conn.Height = 0f;
     }
     catch (Exception)
     {
         if (conn != null)
         {
             conn.Delete();
         }
         throw;
     }
     // return the created header line
     return(conn);
 }
Exemplo n.º 4
0
        public void PresentationNewTest()
        {
            PptApplication_Accessor target = new PptApplication_Accessor(this.application);

            PowerPoint.Presentation   presentation = this.application.Presentations.Open(this.demoDoc.FullName, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
            PowerPoint.DocumentWindow window       = this.application.ActiveWindow;
            target.PresentationNew(presentation, window);
            presentation.Close();
        }
Exemplo n.º 5
0
 public PowerPoint.Pane GetSlidePane(PowerPoint.DocumentWindow window)
 {
     if (window.ViewType == PowerPoint.PpViewType.ppViewNormal)
     {
         return(window.Panes[2]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Get the active presentation, returning null if there is none.
        /// </summary>
        public PowerPoint.Presentation GetActivePresentation()
        {
            // Assume that the activepresentation == the activewindow's presentation
            PowerPoint.DocumentWindow window = this.GetActiveWindow();
            if (window == null)
            {
                return(null);
            }

            return(window.Presentation);
        }
Exemplo n.º 7
0
 private void btnLineBelow_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         PowerPoint.DocumentWindow window = Globals.ThisAddIn.Application.ActiveWindow;
         ToolsAndFormatting.LineBelow(window);
     }
     catch (Exception ex)
     {
         Exceptions.Handle(ex);
     }
 }
Exemplo n.º 8
0
        public List <IFileItem> AppendShapes(List <PPT.Shape> srcShapes)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;
            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                pptPresentation = pres.Open(FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                PPT.DocumentWindow wnd = pptPresentation.Windows[1];
                //wnd.Height = 200;
                //wnd.Top = -200;
                wnd.WindowState = PPT.PpWindowState.ppWindowMinimized;
                wnd             = null;

                PPT.Slides gSlides    = pptPresentation.Slides;
                int        startIndex = gSlides.Count + 1;
                int        count      = 0;
                foreach (PPT.Shape shape in srcShapes)
                {
                    PPT.Slide slide = gSlides.Add(startIndex + count++, PPT.PpSlideLayout.ppLayoutBlank);
                    shape.Copy();
                    slide.Shapes.Paste();
                    slide.Tags.Add(ShapeTag.Tag, ShapeTag.Value);

                    slide.ReleaseCOM();
                    slide = null;
                }
                List <IFileItem> newItems = new List <IFileItem>();
                newItems = fileIndex.UpdateIndex(pptPresentation, startIndex);

                return(newItems);
            }
            finally
            {
                if (pptPresentation != null)
                {
                    pptPresentation.Save();
                    pptPresentation.Close();
                }
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
Exemplo n.º 9
0
        public static void LineBelow(PowerPoint.DocumentWindow window)
        {
            foreach (PowerPoint.Shape shape in window.Selection.ShapeRange)
            {
                // make line and fill "no color"
                shape.Fill.Visible = Office.MsoTriState.msoFalse;
                shape.Line.Visible = Office.MsoTriState.msoFalse;

                window.View.Slide.Shapes.AddLine(
                    shape.Left, shape.Top + shape.Height, shape.Left + shape.Width, shape.Top + shape.Height);
            }
        }
Exemplo n.º 10
0
        private void btnHeaderLine_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                PowerPoint.DocumentWindow window = Globals.ThisAddIn.Application.ActiveWindow;

                ToolsGuidelines.HeaderLine(window);
            }
            catch (Exception ex)
            {
                Exceptions.Handle(ex);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Find the currently active slide or slide master.
        /// </summary>
        /// <param name="slide">The active slide or master (if it exists); must be null, a PowerPoint.Slide, or a PowerPoint.Master</param>
        /// <param name="isMaster">whether the slide output parameter is a PowerPoint.Master or not</param>
        /// <returns>true iff an active slide or master was found</returns>
        public bool GetCurrentSlideOrMaster(out object slide, out bool isMaster)
        {
            slide    = null;
            isMaster = false;

            PowerPoint.DocumentWindow window = this.GetActiveWindow();
            if (window == null)
            {
                return(false);
            }

            return(this.GetSlideFromWindow(window, out slide, out isMaster));
        }
Exemplo n.º 12
0
/*
 *              /// <summary>
 *              /// Finds the named bar in the top-level command bars. (Only looks at the top level, not in sub-menus.)
 *              /// </summary>
 *              /// <param name="name">non-null name of the bar to search for</param>
 *              /// <returns>the bar or null if no such bar exists</returns>
 *              public Core.CommandBar FindCommandBar(string name)
 *              {
 *                      return this.FindCommandBar(this.App.CommandBars, name);
 *              }
 *
 *              /// <summary>
 *              /// Finds the named bar in the set of bars given. (Only looks at the top level, not in sub-menus.)
 *              /// </summary>
 *              /// <param name="bars">non-null bars object</param>
 *              /// <param name="name">non-null name of the bar to search for</param>
 *              /// <returns>the bar or null if no such bar exists</returns>
 *              public Core.CommandBar FindCommandBar(Core.CommandBars bars, string name)
 *              {
 *                      if (bars == null) throw new ArgumentNullException("bars");
 *                      if (name == null) throw new ArgumentNullException("name");
 *
 *                      foreach (Core.CommandBar bar in bars)
 *                              if (bar.Name == name)
 *                                      return bar;
 *                      return null;
 *              }
 *
 *              /// <summary>
 *              /// Add a new command bar to PPT.
 *              /// </summary>
 *              /// <param name="bars">the bars object to which to add the new bar</param>
 *              /// <param name="name">the name of the bar.</param>
 *              /// <param name="position">the position of the bar.</param>
 *              /// <param name="visible">should the bar be visible immediately</param>
 *              /// <param name="replace">should existing bars of the same name be deleted (an error is thrown if replace is false and a bar of the same name exists)</param>
 *              /// <returns>the newly created bar</returns>
 *              public Core.CommandBar AddCommandBar(Core.CommandBars bars, string name,
 *                      Core.MsoBarPosition position, bool visible, bool replace)
 *              {
 *                      Debug.Assert(bars != null, "bars must be non-null");
 *                      Debug.Assert(name != null && name != "", "name must be non-null and non-empty");
 *                      Debug.Assert(Enum.IsDefined(position.GetType(), position), "position has an invalid value");
 *
 *                      Core.CommandBar newBar = null;
 *
 *                      // Delete all bars with the same name.
 *                      foreach (Core.CommandBar bar in bars)
 *                              if (bar.Name == name)
 *                              {
 *                                      if (replace)
 *                                      {
 *                                              newBar = bar;
 *                                              break;
 *                                      }
 *                                      else
 *                                              throw new Exception("A bar by the name \"" + name + "\" already exists.");
 *                              }
 *                      if (newBar == null)
 *                              newBar = bars.Add(name, position, false, false);
 *                      if (newBar.Visible != visible)
 *                              newBar.Visible = visible;
 *                      this.myObjectCache.Add(newBar);
 *                      return newBar;
 *              }
 *
 *              /// <summary>
 *              /// Add a new command bar to PPT. (Adds to the primary command bars list.)
 *              /// </summary>
 *              /// <param name="name">the name of the bar.</param>
 *              /// <param name="position">the position of the bar.</param>
 *              /// <param name="visible">should the bar be visible immediately</param>
 *              /// <param name="replace">should existing bars of the same name be deleted (an error is thrown if replace is false and a bar of the same name exists)</param>
 *              /// <returns>the newly created bar</returns>
 *              public Core.CommandBar AddCommandBar(string name,
 *                      Core.MsoBarPosition position, bool visible, bool replace)
 *              {
 *                      return this.AddCommandBar(this.App.CommandBars, name,
 *                              position, visible, replace);
 *              }
 *
 *              public Core.CommandBarControl AddControl(Core.CommandBar bar,
 *                      Core.MsoControlType type, string name)
 *              {
 *                      Core.CommandBarControl newControl = null;
 *                      foreach (Core.CommandBarControl control in bar.Controls)
 *                      {
 *                              // Find an existing control by the same name and reuse it.. unless it's the wrong type.
 *                              if (control.Caption == name)
 *                              {
 *                                      if (control.Type != type)
 *                                              control.Delete(false);
 *                                      else
 *                                      {
 *                                              newControl = control;
 *                                              break;
 *                                      }
 *                              }
 *                      }
 *                      if (newControl == null)
 *                      {
 *                              newControl = bar.Controls.Add(type, Missing.Value, Missing.Value, Missing.Value, false);
 *                              newControl.Caption = name;
 *                      }
 *                      if (newControl is Core.CommandBarButton)
 *                              ((Core.CommandBarButton)newControl).Style = Core.MsoButtonStyle.msoButtonCaption;
 *                      newControl.Visible = true;
 *                      this.myObjectCache.Add(newControl);
 *                      return newControl;
 *              }
 */
        /// <summary>
        /// Get the active window, returning null if there is none.
        /// </summary>
        public PowerPoint.DocumentWindow GetActiveWindow()
        {
            PowerPoint.DocumentWindow window = null;
            foreach (PowerPoint.DocumentWindow w in this.App.Windows)
            {
                if (w.Active == Office.MsoTriState.msoTrue)
                {
                    window = w;
                    break;
                }
            }
            return(window);
        }
Exemplo n.º 13
0
        private void HandleWindowActivate(PowerPoint.Presentation presentation, PowerPoint.DocumentWindow window)
        {
            // TODO: need to make a method for building the presentation at this point
            // in case when it was opened/newed it didn't have an active window but
            // now it does. Suggestion: add a tag to the presentation that contains a
            // GUID unique to this instance which will tell us whether THIS INSTANCE
            // has ever built the presentation before? That's actually no good b/c
            // it could have been closed, changed elsewhere, and reopened all while
            // this instance is running. :(

            // Update the mode bars.
            this.ConfigurePresentationModeBar();
            this.ConfigureShapeModeBar();
        }
Exemplo n.º 14
0
 internal static void HeaderLine(PowerPoint.DocumentWindow window)
 {
     // If one shape selected, add connector line to it
     if (window.Selection.ShapeRange.Count == 1)
     {
         // get the shape and its position
         PowerPoint.Shape shape = window.Selection.ShapeRange[1];
         // create the line
         createHeaderLine(window, shape);
     }
     // If two shapes, align the connector to the shape
     else
     {
         // Determine which shape is the bottom box (/shape)
         var shapes      = window.Selection.ShapeRange;
         var bottomIndex = shapes[1].Top > shapes[2].Top ? 1 : 2;
         var bottom      = shapes[bottomIndex];
         var top         = bottomIndex == 1 ? shapes[2] : shapes[1];
         // newly created connector to align
         PowerPoint.Shape conn;
         // if top shape is not a connector, create a new connector based on the top shape
         if (top.Connector == Office.MsoTriState.msoFalse)
         {
             // create the line (inside try to be able to return)
             conn = createHeaderLine(window, top);
         }
         // else connector is obviously the top shape
         else
         {
             conn = top;
         }
         // Set the width (and height) of the connector aligning it
         var width = bottom.Left + bottom.Width - conn.Left;
         if (width > 0)
         {
             conn.Width = width;
             conn.ConnectorFormat.EndDisconnect();
             conn.Height = 0f;
         }
         else
         {
             MessageBox.Show("Cannot align header line, because top shape overlaps bottom shape on the right");
             return;
         }
     }
 }
Exemplo n.º 15
0
        private static PowerPoint.Presentation FindPresentation(PowerPoint.DocumentWindows windows,
                                                                COMObjectsHelper comHelper,
                                                                string title)
        {
            PowerPoint.DocumentWindow matchingWindow = null;

            for (var i = 1; i <= windows.Count; i++)
            {
                var window = comHelper.Register(() => windows[i]);

                if (title.Contains(window.Caption))
                {
                    matchingWindow = window;
                    break;
                }
            }

            return(comHelper.Register(() => matchingWindow?.Presentation));
        }
Exemplo n.º 16
0
 private void PresentationNew(PowerPoint.Presentation presentation, PowerPoint.DocumentWindow window)
 {
     ActivateDocument(presentation);
 }
Exemplo n.º 17
0
        private void AfterCopyEventHandler(PowerPoint.Selection selection)
        {
            try
            {
                _copyFromWnd = Application.ActiveWindow;

                if (selection.Type == PowerPoint.PpSelectionType.ppSelectionSlides)
                {
                    _copiedSlides.Clear();

                    foreach (var sld in selection.SlideRange)
                    {
                        var slide = sld as PowerPoint.Slide;

                        _copiedSlides.Add(slide);
                    }

                    _copiedSlides.Sort((x, y) => (x.SlideIndex - y.SlideIndex));
                }
                else if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
                {
                    _copiedShapes.Clear();
                    _previousSlideForCopyEvent = Application.ActiveWindow.View.Slide as PowerPoint.Slide;
                    _previousPptName = Application.ActivePresentation.Name;
                    foreach (var sh in selection.ShapeRange)
                    {
                        var shape = sh as PowerPoint.Shape;
                        _copiedShapes.Add(shape);
                    }

                    _copiedShapes.Sort((x, y) => (x.Id - y.Id));
                }
            }
            catch
            {
                //TODO: log in ThisAddIn.cs
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Get the "slide" from a document window in PPT. The result (placed in
        /// slide) may be either a PowerPoint.Slide object or a PowerPoint.Master
        /// object. Both have similar fields but share no base type.
        /// </summary>
        /// <param name="window">A non-null document window in the currently active PowerPoint application.</param>
        /// <param name="slide">the slide found (if any, check return value)</param>
        /// <param name="isMaster">true if the returned slide is a Master, false otherwise (so if there is a return, it's a Slide)</param>
        /// <returns>true iff a slide was found</returns>
        /// <remarks>This method may activate the pane of the slide that is returned.</remarks>
        public bool GetSlideFromWindow(PowerPoint.DocumentWindow window,
                                       out object slide, out bool isMaster)
        {
            /*
             * Notes on views:
             *
             * Normal view is, well, the normal view and the only one with "panes":
             * multiple selectable windows embedded in a single window. The current
             * pane can be detected by checking the ViewType of the Active Pane: PpViewSlide,
             * PpViewThumbnails, PpViewNotesPage, PpViewOutline, PpViewSlideMaster,
             * PpViewMasterThumbnails, or PpViewTitleMaster. Note that the *type* of
             * the slide field can vary depending on whether Pane #2 (guaranteed to be
             * the "slide" pane) is a master or a slide. (It should be either PowerPoint.Master
             * or PowerPoint.Slide, I believe. Both have a Shapes field.)
             *
             * As far as I can tell, only PpViewNotesPage can also be a Window ViewType.
             * Note that if a pane other than pane #2 is selected, the Slide property
             * of the view is NOT VALID and accessing it will cause an error.
             *
             * Of the window (non-pane, usually) views, I've been able to find:
             *
             ** HandoutMaster (View > Masters > Handout master)
             ** NotesMaster (as w/HandoutMaster)
             ** NotesPage (View > Notes Page)
             ** PrintPreview (File > Print Preview)
             ** SlideSorter (View > Slide Sorter)
             *
             * It seems to me that the right thing to do to get the Shapes field of any
             * Normal view is to activate the "Slide" pane (#2) and grab the Shapes field
             * of the resulting Master or Slide. For all others, should probably just
             * report inability to get the Shapes field. Note that for SlideSorter or
             * NotesPage, it *might* also make sense to activate whatever the current slide
             * is in a normal view and then return the shapes field.
             *
             */
            Debug.Assert(window != null, "window parameter must be non-null");

            slide    = null;
            isMaster = false;

            // Make sure there's at least one slide!
            if (window.Presentation.Slides.Count == 0)
            {
                //DebugForm.WriteLine("No slides in presentation while trying to find slide.");
                return(false);
            }
            else if (window.ViewType == PowerPoint.PpViewType.ppViewNormal)
            {
                // Pane 2 is guaranteed to be the slide/master pane. Make sure it's active so that
                // the slide member will be accessible.
                if (GetSlidePane(window) != window.ActivePane)
                {
                    GetSlidePane(window).Activate();
                }
                slide = window.View.Slide;
                // Should be one of PpViewSlide, PpViewSlideMaster, or PpViewTitleMaster.
                PowerPoint.PpViewType paneType = GetSlidePane(window).ViewType;
                Debug.Assert(paneType == PowerPoint.PpViewType.ppViewSlide ||
                             paneType == PowerPoint.PpViewType.ppViewSlideMaster ||
                             paneType == PowerPoint.PpViewType.ppViewTitleMaster,
                             "Unexpected pane type encountered: " + paneType);
                isMaster = paneType != PowerPoint.PpViewType.ppViewSlide;
                return(true);
            }
            else
            {
                // Not currently trying to track down slide for any other type.
                return(false);
            }
        }
Exemplo n.º 19
0
        public List <IFileItem> AppendSlides(List <PPT.Slide> srcSlides)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;
            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                pptPresentation = pres.Open(FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                PPT.DocumentWindow wnd = pptPresentation.Windows[1];
                //wnd.Height = 200;
                //wnd.Top = -200;
                wnd.WindowState = PPT.PpWindowState.ppWindowMinimized;
                wnd             = null;

                #region Alt. slower approach by copy ppt and insert slides from file
                //Copy
                //string tempFile = @"c:\WRK\Temp.pptx";
                //ppt.ActivePresentation.SaveCopyAs(tempFile, PPT.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
                //PPT.Presentation tempPPT = ppt.Presentations.Open(tempFile,MsoTriState.msoFalse,MsoTriState.msoFalse, MsoTriState.msoFalse);

                //List<string> slideNames = slides.Select(slide => slide.Name).ToList();
                //var v = from PPT.Slide sl in tempPPT.Slides where !slideNames.Contains(sl.Name) select sl;
                //foreach(PPT.Slide s in v)
                //{
                //    s.Delete();
                //}
                //tempPPT.Save();
                //tempPPT.Close();
                //gallery.Slides.InsertFromFile(tempFile, gallery.Slides.Count);
                #endregion

                PPT.Slides gSlides    = pptPresentation.Slides;
                int        startIndex = gSlides.Count + 1;
                foreach (PPT.Slide slide in srcSlides)
                {
                    slide.Copy();
                    gSlides.Paste();
                }
                List <IFileItem> newItems = new List <IFileItem>();
                newItems = fileIndex.UpdateIndex(pptPresentation, startIndex);

                return(newItems);
            }
            finally
            {
                if (pptPresentation != null)
                {
                    pptPresentation.Save();
                    pptPresentation.Close();
                }
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Finds the shapes selected in the active window.
        /// </summary>
        /// <returns>A shapes object representing the selected shape(s)
        /// or null if no selected shapes could be found. If non-null,
        /// guaranteed to contain at least one shape.</returns>
        public PowerPoint.ShapeRange GetSelectedShapes()
        {
            PowerPoint.DocumentWindow window = this.GetActiveWindow();

            // Only gather the selection of a slide if it is in the active window.
            // TODO: may want to restrict this to regular slides rather than slide masters.
            // Would look something like: GetSlidePane(window).ViewType == PowerPoint.PpViewType.ppViewSlide
            if (window == null || window.ViewType != PowerPoint.PpViewType.ppViewNormal ||
                window.ActivePane != GetSlidePane(window))
            {
                return(null);
            }

            PowerPoint.Selection selection = window.Selection;
            if (selection == null)
            {
                return(null);
            }

            // Find the shapes associated with this selection.
            PowerPoint.ShapeRange shapes = null;
            // Only one of shapes and shape should be set in this switch; the other
            // should be left null.
            switch (selection.Type)
            {
            case PowerPoint.PpSelectionType.ppSelectionShapes:
                shapes = selection.ShapeRange;
                break;

            case PowerPoint.PpSelectionType.ppSelectionText:
                // Try to find a shape associated with the text.
                PowerPoint.Shape shape  = null;
                object           parent = selection.TextRange.Parent;
                if (parent is PowerPoint.Shape)
                {
                    shape = (PowerPoint.Shape)parent;
                }
                else if (parent is PowerPoint.TextFrame)
                {
                    parent = ((PowerPoint.TextFrame)parent).Parent;
                    if (parent is PowerPoint.Shape)
                    {
                        shape = (PowerPoint.Shape)parent;
                    }
                }

                // Transform the shape into a ShapeRange
                if (shape != null && window.View.Slide is PowerPoint.Slide)
                {
                    PowerPoint.Shapes slideShapes = ((PowerPoint.Slide)window.View.Slide).Shapes;
                    int i;
                    for (i = 1; i <= slideShapes.Count; i++)
                    {
                        if (ShapeKey.ShapesMatch(slideShapes[i], this.GetSlideFromShape(slideShapes[i]).SlideID, shape, this.GetSlideFromShape(shape).SlideID))
                        {
                            break;
                        }
                    }
                    if (i <= slideShapes.Count)
                    {
                        shapes = ((PowerPoint.Slide)window.View.Slide).Shapes.Range(i);
                    }
                }
                break;

            default:
                break;
            }

            if (shapes == null || shapes.Count == 0)
            {
                return(null);
            }
            else
            {
                return(shapes);
            }
        }
Exemplo n.º 21
0
 private void HandleWindowDeactivate(PowerPoint.Presentation presentation, PowerPoint.DocumentWindow window)
 {
     // Update the mode bars.
     this.ConfigurePresentationModeBar();
     this.ConfigureShapeModeBar();
 }
Exemplo n.º 22
0
 private static void ApplicationOnWindowActivate(PowerPoint.Presentation pres, PowerPoint.DocumentWindow wn)
 {
     try
     {
         WakaTime.HandleActivity(pres.FullName, false, string.Empty);
     }
     catch (Exception ex)
     {
         WakaTime.Logger.Error("ApplicationOnWindowActivate", ex);
     }
 }
Exemplo n.º 23
0
 private void Application_WindowActivate(PowerPoint.Presentation Pres, PowerPoint.DocumentWindow Wn)
 {
     UpdatePointer();
 }
Exemplo n.º 24
0
 private void WindowActivate_Event(PowerPoint.Presentation Pres, PowerPoint.DocumentWindow Wn)
 {
     ResetSidebar();
 }
Exemplo n.º 25
0
        private void InsertItem(IFileItem item)
        {
            if (item == null)
            {
                return;
            }

            PPT.Application   app  = new PPT.Application();
            PPT.Presentations pres = app.Presentations;

            PPT.Presentation pptx   = pres.Open(item.File.FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
            PPT.Slides       slides = pptx.Slides;
            PPT.Slide        slide  = slides[item.Index];

            if (item.Type == ItemType.Slide)
            {
                slide.Copy();
            }
            else
            {
                PPT.Shapes shapes = slide.Shapes;
                PPT.Shape  shape  = shapes[1];

                shape.Copy();

                shapes.ReleaseCOM();
                shapes = null;
                shape.ReleaseCOM();
                shape = null;
            }

            PPT.Presentation dstpptx = app.ActivePresentation;

            PPT.DocumentWindow wnd  = app.ActiveWindow;
            PPT.View           view = wnd.View;

            //TODO: Check if there is no selection (selection between slides)
            PPT.Slides dstSlides = dstpptx.Slides;
            PPT.Slide  dstSlide  = null;

            dstSlide = view.Slide as PPT.Slide;
            int ix = dstSlide.SlideIndex + 1;

            if (item.Type == ItemType.Slide)
            {
                dstSlide.Copy();

                var r = dstSlides.Paste(); //TODO: dstSlides.Paste(ix) Hangs here
                var s = r[1];

                s.MoveTo(ix);

                s.ReleaseCOM();
                s = null;

                r.ReleaseCOM();
                r = null;
            }
            else
            {
                view.Paste();
            }

            dstSlide.ReleaseCOM();
            dstSlide = null;

            wnd.ReleaseCOM();
            wnd = null;

            view.ReleaseCOM();
            view = null;

            dstpptx.ReleaseCOM();
            dstpptx = null;


            slide.ReleaseCOM();
            slide = null;

            slides.ReleaseCOM();
            slides = null;

            pptx.Close();
            pptx.ReleaseCOM();
            pptx = null;

            pres.ReleaseCOM();
            pres = null;

            app.ReleaseCOM();
            app = null;

            dstSlides.ReleaseCOM();
            dstSlides = null;
        }
Exemplo n.º 26
0
        protected void AddSelectedShapes(IFile libraryFile)
        {
            PPT.Application    ppt = null;
            PPT.Presentation   pr  = null;
            PPT.DocumentWindow aw  = null;
            PPT.Selection      sel = null;

            try
            {
                timerCheckForUpdates.Enabled = false;

                ppt = new PPT.Application();
                pr  = ppt.ActivePresentation;

                if (pr.FullName == libraryFile.FullPath)
                {
                    MessageBox.Show("You can't add slides to the same presentation");
                    return;
                }

                aw  = ppt.ActiveWindow;
                sel = aw.Selection;
                List <PPT.Shape> shapesToAdd = new List <PPT.Shape>();

                if (sel.Type == PPT.PpSelectionType.ppSelectionShapes)
                {
                    foreach (PPT.Shape slide in sel.ShapeRange)
                    {
                        shapesToAdd.Add(slide);
                    }
                }
                else
                {
                    shapesToAdd.Add(aw.View.Slide as PPT.Shape);
                }

                if (shapesToAdd.Count > 0)
                {
                    libraryFile.AppendShapes(shapesToAdd);
                    uxImagesView.DataSource = LibraryData.GetAllItems().ToList();
                    Filter();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sel.ReleaseCOM();
                sel = null;

                pr.ReleaseCOM();
                pr = null;

                aw.ReleaseCOM();
                aw = null;

                ppt.ReleaseCOM();
                ppt = null;

                timerCheckForUpdates.Enabled = !needsUpdate;
            }
        }
 public void CurrentViewChanged(object currentView)
 {
     currentWindow = (PowerPoint.DocumentWindow)currentView;
 }
Exemplo n.º 28
0
 public void CurrentViewChanged(object currentView)
 {
     currentWindow = (PowerPoint.DocumentWindow)currentView;
 }
Exemplo n.º 29
0
 private void Application_WindowDeactivate(PowerPoint.Presentation Doc, PowerPoint.DocumentWindow Wn)
 {
     Close();
 }