コード例 #1
0
ファイル: ThisAddIn.cs プロジェクト: zhufucdev/PPTHelper
 public override void Next()
 {
     view.Next();
 }
コード例 #2
0
 /// <summary>
 /// Show the next slide
 /// </summary>
 public void ShowNextSlide()
 {
     oSlideShowView.Application.SlideShowWindows[1].Activate();
     oSlideShowView.Next();
 }
コード例 #3
0
        protected override void Execute(CodeActivityContext context)
        {
            var filename      = Filename.Get(context);
            var startingslide = StartingSlide.Get(context);
            var kioskmode     = KioskMode.Get(context);
            var endingslide   = EndingSlide.Get(context);
            var advancetime   = AdvanceTime.Get(context);

            filename = Environment.ExpandEnvironmentVariables(filename);
            Application  activeObject = null;
            Presentation document     = null;

            try
            {
                activeObject = (Application)Marshal.GetActiveObject("Powerpoint.Application");
                foreach (Presentation current in activeObject.Presentations)
                {
                    if (current.FullName == filename)
                    {
                        document = current;
                        break;
                    }
                }
            }
            catch
            {
                activeObject = null;
            }
            finally
            {
                if (activeObject == null)
                {
                    activeObject = (Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("91493441-5A91-11CF-8700-00AA0060263B")));
                }
                activeObject.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            }
            if (document == null)
            {
                document = activeObject.Presentations.Open(filename);
            }
            document.Close();
            document = activeObject.Presentations.Open(filename);

            if (startingslide < 1)
            {
                startingslide = 1;
            }
            if (endingslide < 1 || endingslide > document.Slides.Count)
            {
                endingslide = document.Slides.Count;
            }
            if (kioskmode)
            {
                document.SlideShowSettings.ShowType = PpSlideShowType.ppShowTypeKiosk;
            }
            document.SlideShowSettings.ShowType    = PpSlideShowType.ppShowTypeSpeaker;
            document.SlideShowSettings.RangeType   = PpSlideShowRangeType.ppShowSlideRange;
            document.SlideShowSettings.AdvanceMode = PpSlideShowAdvanceMode.ppSlideShowManualAdvance;
            document.Slides.Range().SlideShowTransition.AdvanceTime = 0;
            document.Slides.Range().SlideShowTransition.AdvanceOnTime = Microsoft.Office.Core.MsoTriState.msoFalse;
            document.Slides.Range().SlideShowTransition.AdvanceOnClick = Microsoft.Office.Core.MsoTriState.msoTrue;
            //activeObject.ActivePresentation.Application.ActivePresentation.Slides[startingslide].Select();

            // StartingSlide does not seem to work the first time we open a powerpoint, so lets manually move forward
            document.SlideShowSettings.StartingSlide = startingslide;
            //activeObject.ActivePresentation.Application.ActiveWindow.Panes[2].Activate();


            SlideShowWindow obj          = document.SlideShowSettings.Run();
            SlideShowView   objSlideShow = document.SlideShowWindow.View;

            try
            {
                //while (objSlideShow.CurrentShowPosition < startingslide)
                //{
                //    objSlideShow.Next();
                //}
                while (objSlideShow.CurrentShowPosition < endingslide || objSlideShow.State != PpSlideShowState.ppSlideShowDone)
                {
                    if (advancetime != TimeSpan.Zero)
                    {
                        System.Threading.Thread.Sleep(advancetime);
                        objSlideShow.Next();
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(500);
                    }
                }
            }
            catch (COMException)
            {
            }
            catch (Exception)
            {
                throw;
            }
            try
            {
                if (objSlideShow != null && advancetime != TimeSpan.Zero)
                {
                    objSlideShow.Exit();
                }
            }
            catch (Exception)
            {
            }
            if (CloseAtEnd.Get(context))
            {
                try
                {
                    document.Close();
                    if (activeObject.Presentations.Count == 0)
                    {
                        activeObject.Quit();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #4
0
ファイル: Ribbon1.cs プロジェクト: ashphy/WiimotePresentation
        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
        {
            //Does thw wiimote use?
            if (!connectWiimoteButton.Checked)
            {
                return;
            }
            if (Globals.ThisAddIn == null)
            {
                return;
            }

            //Wiimote state
            WiimoteState ws = e.WiimoteState;

            Presentation ap = Globals.ThisAddIn.Application.ActivePresentation;

            try
            {
                if (isSlideShowMode)
                {
                    SlideShowView view = ap.SlideShowWindow.View;

                    if (ws.ButtonState.One && ws.ButtonState.Two)
                    {
                        //Exit slide show
                        view.Exit();
                    }
                    else if (ws.ButtonState.Left)
                    {
                        //Back to the slide show
                        view.Previous();
                    }
                    else if (ws.ButtonState.A)
                    {
                        //Go to the next slide
                        view.Next();
                    }
                    else if (ws.ButtonState.Home)
                    {
                        //Go to slide sorter view
                        view.Exit();
                        DocumentWindow aw = Globals.ThisAddIn.Application.ActiveWindow;
                        aw.ViewType = PpViewType.ppViewSlideSorter;
                    }
                }
                else if (Globals.ThisAddIn.Application.ActiveWindow.ViewType == PpViewType.ppViewSlideSorter)
                {
                    DocumentWindow aw = Globals.ThisAddIn.Application.ActiveWindow;

                    //If slide sorter view
                    if (ws.ButtonState.Up)
                    {
                        SendKeys.SendWait("{UP}");
                    }
                    else if (ws.ButtonState.Down)
                    {
                        SendKeys.SendWait("{down}");
                    }
                    else if (ws.ButtonState.Left)
                    {
                        SendKeys.SendWait("{LEFT}");
                    }
                    else if (ws.ButtonState.Right)
                    {
                        SendKeys.SendWait("{RIGHT}");
                    }
                    else if (ws.ButtonState.Home)
                    {
                        aw.ViewType = PpViewType.ppViewNormal;
                    }
                    else if (ws.ButtonState.A)
                    {
                        showPresentationFromSelection();
                    }
                    else if (ws.ButtonState.Minus)
                    {
                        //Scalling down
                        int current = aw.View.Zoom;
                        if (0 < current - 10)
                        {
                            aw.View.Zoom = current - 10;
                        }
                    }
                    else if (ws.ButtonState.Plus)
                    {
                        //Scalling up
                        int current = aw.View.Zoom;

                        if (current + 10 <= 100)
                        {
                            aw.View.Zoom = current + 10;
                        }
                        else if (current + 10 > 100)
                        {
                            aw.View.Zoom = 100;
                        }
                    }
                }
                else
                {
                    DocumentWindow aw          = Globals.ThisAddIn.Application.ActiveWindow;
                    int            currentPage = aw.Selection.SlideRange.SlideIndex;

                    //Normal view mode
                    if (ws.ButtonState.Up)
                    {
                        if (1 < currentPage)
                        {
                            ap.Slides.Range(currentPage - 1).Select();
                        }
                    }
                    else if (ws.ButtonState.Down)
                    {
                        if (currentPage < ap.Slides.Count)
                        {
                            ap.Slides.Range(currentPage + 1).Select();
                        }
                    }
                    else if (ws.ButtonState.A)
                    {
                        showPresentationFromSelection();
                    }
                    else if (ws.ButtonState.Home)
                    {
                        aw.ViewType = PpViewType.ppViewSlideSorter;
                    }
                }
            }
            catch (COMException ce)
            {
                Console.WriteLine(ce.StackTrace);
            }

            refreshBattery(ws);
        }