Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Set license key to use GemBox.Presentation in Free mode.
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
            var presentation = new PresentationDocument();
            var slide        = presentation.Slides.AddNew(SlideLayoutType.Custom);
            var textBox      = slide.Content.AddTextBox(0, 0, 5, 5, LengthUnit.Centimeter);

            textBox.AddParagraph().AddRun("Hello World!");



            // Save to PPTX and PDF files.
            presentation.Save("Presentation.pptx");
            //open it
            var app  = new PowerPoint.Application();
            var pres = app.Presentations;
            var file = pres.Open(@"C:\Users\real1\Desktop\Crypto_project\Audit\Audit\bin\Debug\Presentation.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoFalse);

            PowerPoint.SlideShowSettings slideSetting = file.SlideShowSettings;
            slideSetting.Run();

            PowerPoint.SlideShowWindows slideShowWindows = app.SlideShowWindows;
            while (true)
            {
                if (slideShowWindows.Count <= 0)
                {
                    break;
                }
                System.Threading.Thread.Sleep(100);
            }
        }
Ejemplo n.º 2
0
        public int loadFile(String filename)
        {
            //Create app and open file
            app = new PPT.Application();
            pres = app.Presentations.Open(filename, Core.MsoTriState.msoFalse,
                Core.MsoTriState.msoFalse, Core.MsoTriState.msoFalse);

            if (pres == null)
            {
                sss = null;
                ssw = null;
                ssv = null;

                loaded = false;
                visible = false;
                return -1;
            }

            app.Visible = Core.MsoTriState.msoFalse;

            sss = pres.SlideShowSettings;
            sss.ShowType = PPT.PpSlideShowType.ppShowTypeKiosk;
            ssw = sss.Run();
            ssv = ssw.View;

            loaded = true;
            visible = true;
            return pres.Slides.Count;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 打开PPT文档并播放显示。
        /// </summary>
        /// <param name="filePath">PPT文件路径</param>
        public void PPTOpen(string filePath)
        {
            try
            {
                CurrentFile = filePath;
                Thread.Sleep(100);
                //防止连续打开多个PPT程序.
                if (this.objApp != null)
                {
                    this.objApp.Quit();
                    this.objApp = null;
                }
                Thread.Sleep(100);

                objApp = new POWERPOINT.ApplicationClass();
                //以非只读方式打开,方便操作结束后保存.
                objPresSet = objApp.Presentations.Open(filePath, MsoTriState.msoCTrue, MsoTriState.msoCTrue, MsoTriState.msoFalse);
                //Prevent Office Assistant from displaying alert messages:
                //bAssistantOn = objApp.Assistant.On;
                //objApp.Assistant.On = false;
                objSSS = this.objPresSet.SlideShowSettings;
                objSSS.Run();
                currentPage = 1;
                pageCount   = objPresSet.Slides.Count;
                //this.objPresSet.SlideShowWindow.View.GotoSlide(2, OFFICECORE.MsoTriState.msoFalse);
            }
            catch (Exception)
            {
                //this.objApp.Quit();
                //Thread.Sleep(1000);
                //PPTOpen(filePath);
            }
        }
Ejemplo n.º 4
0
 public void PptAction(PptDetails pptDetails)
 {
     pptDetailsMain = pptDetails;
     DodoMediaPlayer.Stop();
     this.Hide();
     if (pptDetails != null)
     {
         try
         {
             //Create a new presentation based on a template.
             objApp = new powerpointinterop.Application();
             //  objApp.SlideShowBegin += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowBeginEventHandler(powerpnt_SlideShowBegin);
             objApp.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(powerpnt_SlideShowEnd);
             //objApp.SlideShowNextSlide += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowNextSlideEventHandler(powerpnt_SlideShowNextSlide);
             objApp.Visible = MsoTriState.msoTrue;
             objPresSet     = objApp.Presentations;
             string pptName = pptDetails.Name;
             string pptPath = System.IO.Path.Combine(Mocker.debugPath, "Ppts", pptName);
             objPres   = objPresSet.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoTrue);
             objSlides = objPres.Slides;
             objSSS    = objPres.SlideShowSettings;
             objSSS.Run();
         }
         catch (Exception)
         {
         }
     }
     else
     {
         MessageBox.Show("Media Not Found");
     }
 }
Ejemplo n.º 5
0
 public static String CreateObj()
 {
     String eString = "";
     if (objpre != null)
     {
         eString = "PC端已打开了PPT文件。若要打开其它PPT,请先关闭当前文件,并点击一次next或prev按钮";
         Debug.WriteLine(eString);
         return eString;
     }
     try
     {
         objpre = objapp.Presentations.Open(filepath, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoTrue);
         objset = objpre.SlideShowSettings;
         objset.Run();
         eString = "调用PPT文件成功 :";
         intNowPage = 0;
         intPer = 0;
         intPageSize = objpre.Slides.Count;
         Debug.WriteLine(eString);
     }
     catch (Exception)
     {
         intNowPage = 0;
         intPer = 0;
         intPageSize = 1;
         eString = "打开PPT文件失败,异常原因是没有选择文件或选择的文件不是PPT " ;
     }
     return eString;
 }
    //Begin Presentation
    public void BeginPresentation(SocketIOEvent socketIOEvent)
    {
        CheckPowerPoint();

        if (pptApplication == null)
        {
            return;
        }

        pptApplication.Activate();
        PPt.SlideShowSettings slideShowSettings = presentation.SlideShowSettings;
        slideShowSettings.Run();
    }
Ejemplo n.º 7
0
        public void end()
        {
            if (loaded)
            {
                pres.Close();
                app.Quit();

                sss = null;
                ssw = null;
                ssv = null;

                loaded = false;
                visible = false;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPTy文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        public void PPTAuto(string filePath, int playTime)
        {
            //防止连续打开多个PPT程序.
            if (this.objApp != null)
            {
                return;
            }

            objApp     = new POWERPOINT.Application();
            objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoCTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);

            // 自动播放的代码(开始)
            int Slides = objPresSet.Slides.Count;

            int[] SlideIdx = new int[Slides];
            for (int i = 0; i < Slides; i++)
            {
                SlideIdx[i] = i + 1;
            }
            ;
            objSldRng = objPresSet.Slides.Range(SlideIdx);
            objSST    = objSldRng.SlideShowTransition;
            //设置翻页的时间.
            objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
            objSST.AdvanceTime   = playTime;
            //翻页时的特效!
            objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;

            //Prevent Office Assistant from displaying alert messages:
            bAssistantOn        = objApp.Assistant.On;
            objApp.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPresSet.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide   = Slides;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1)
            {
                System.Threading.Thread.Sleep(playTime * 100);
            }

            this.objPresSet.Close();
            this.objApp.Quit();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 打开PPT文档并播放显示。
 /// </summary>
 /// <param name="filePath">PPT文件路径</param>
 public void PPTOpen(string filePath)
 {
     //防止连续打开多个PPT程序.
     if (this.objApp != null)
     {
         return;
     }
     try
     {
         objApp = new POWERPOINT.Application();
         //以非只读方式打开,方便操作结束后保存.
         objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);
         //Prevent Office Assistant from displaying alert messages:
         bAssistantOn        = objApp.Assistant.On;
         objApp.Assistant.On = false;
         objSSS = this.objPresSet.SlideShowSettings;
         objSSS.Run();
     }
     catch (Exception ex)
     {
         this.objApp.Quit();
     }
 }
Ejemplo n.º 10
0
        public void OpenPPT(string filePath)
        {
            if (this.objApp == null)
            {
                objApp = new POWERPOINT.Application();
                objApp.PresentationCloseFinal += ObjApp_PresentationCloseFinal;
            }

            try
            {
                var objPresSet = PresentationInstanceRepository.Instance[filePath];
                if (objPresSet == null)
                {
                    objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoCTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);
                    PresentationInstanceRepository.Instance[filePath] = objPresSet;
                    objPresSet.Windows.Application.PresentationClose += Application_PresentationClose;;
                }
                objSSS                  = objPresSet.SlideShowSettings;
                objSSS.ShowType         = POWERPOINT.PpSlideShowType.ppShowTypeSpeaker;
                objSSS.LoopUntilStopped = OFFICECORE.MsoTriState.msoCTrue;
                objSSS.RangeType        = POWERPOINT.PpSlideShowRangeType.ppShowSlideRange;

                objSSWs   = objSSS.Run();
                pptIntPtr = (IntPtr)objSSWs.HWND;
                SetParent(pptIntPtr, this.Handle);
                isManualClose = true;
                _movePPTWindowTimer.Change(300, 300);
            }
            catch
            {
                try
                {
                    this.objApp.Quit();
                }
                catch (Exception) { }
            }
        }
Ejemplo n.º 11
0
        public void LoadPPTSlides(string fileName, System.Windows.Forms.Panel slideShowPanel)
        {
            IntPtr screenClasshWnd = (IntPtr)0;
            IntPtr x = (IntPtr)0;

            application = new Microsoft.Office.Interop.PowerPoint.Application();

            Presentation = application.Presentations.Open(fileName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
            Microsoft.Office.Interop.PowerPoint.SlideShowSettings sst1 = Presentation.SlideShowSettings;

            sst1.ShowType = (Microsoft.Office.Interop.PowerPoint.PpSlideShowType) 1;
            Microsoft.Office.Interop.PowerPoint.SlideShowWindow sw = sst1.Run();

            sw.Height = (slideShowPanel.Height) - 150;
            sw.Width  = (slideShowPanel.Width) - 340;

            IntPtr formhWnd = FindWindow(x, "SlideShow");
            IntPtr pptptr   = (IntPtr)sw.HWND;

            screenClasshWnd = FindWindow(x, "screenClass");
            SetParent(pptptr, slideShowPanel.Handle);

            this.application.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(SlideShowEnds);
        }
Ejemplo n.º 12
0
        public void Save()
        {
            //Prevent Office Assistant from displaying alert messages:
            bool bAssistantOn = application.Assistant.On;

            application.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            slideSettings = pptPresentation.SlideShowSettings;
            slideSettings.StartingSlide = 1;
            slideSettings.EndingSlide   = 3;
            slideSettings.Run();

            //Wait for the slide show to end.
            slideWindows = application.SlideShowWindows;
            while (slideWindows.Count >= 1)
            {
                System.Threading.Thread.Sleep(100);
            }

            //Reenable Office Assisant, if it was on:
            if (bAssistantOn)
            {
                application.Assistant.On      = true;
                application.Assistant.Visible = false;
            }

            //Close the presentation without saving changes and quit PowerPoint.
            pptPresentation.Close();
            application.Quit();

            Thread.Sleep(200);
            string fileName = string.Format("朗开医疗体检报告[{0}][{1}].ppt", System.Net.Dns.GetHostName(), DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"));

            File.Copy(_fileName, Path.GetDirectoryName(_fileName) + "\\" + fileName);
        }
Ejemplo n.º 13
0
        public bool PPTOpen(string path)
        {
            filepath = path;
            filename = Path.GetFileName(path);

            if (this.objApp != null)
            {
                return(true);
            }

            if (Global.getPPTMaximize())
            {
                minisizeProc();
            }

            try
            {
                //TODO: 需要将Form12关闭否?
                if (Form1.f12 != null)
                {
                    Form1.f12.Hide();
                }

                //显示桌面
                //Type oleType = Type.GetTypeFromProgID("Shell.Application");
                //object oleObject = System.Activator.CreateInstance(oleType);
                //oleType.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, oleObject, null);


                objApp     = new POWERPOINT.Application();
                objPresSet = objApp.Presentations.Open(filepath, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);

                objSlides = objPresSet.Slides;
                pageTotal = objPresSet.Slides.Count;

                objSSS = this.objPresSet.SlideShowSettings;
                objSSS.LoopUntilStopped = MsoTriState.msoTrue;
                objSSS.Run();

                //最大化当前窗口
                maximizePPTProc();

                if (pageCurrent > 0)
                {
                    //GotoPage(pageCurrent);
                }
                else
                {
                    pageCurrent = 1;
                    pageLast    = 1;
                }
                Log.Info("PPTOpen ok.");
                return(true);
            }
            catch (Exception ex)
            {
                int errorcode = 0;
                var w32ex     = ex as Win32Exception;
                if (w32ex == null)
                {
                    w32ex = ex.InnerException as Win32Exception;
                }
                if (w32ex != null)
                {
                    errorcode = w32ex.ErrorCode;
                }

                Log.Error("PPTOpen exception. " + ex.Message + ", errorcode=" + errorcode);//Error HRESULT E_FAIL has been returned from a call to a COM component.
                this.objApp.Quit();
                objApp = null;
                MessageBox.Show("打开" + filename + "失败,请检查该文件!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }
            finally
            {
            }
        }
Ejemplo n.º 14
0
        private void btCameraSelectata_Click(object sender, EventArgs e)
        {
            if (cmbDisponibile.Text == "SINGLE")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA SINGLE";

                slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Single ofera oaspetilor o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele single sunt cu vedere spre curtea interioara si asigura liniste deplina atat pe timp de zi cat si pe timp de noapte." +
                                                           "Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei.";

                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }

            if (cmbDisponibile.Text == "DOUBLE")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA DOUBLE";

                slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Double oferta oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele double au vedere spre cladirea Cercului Militar si Calea Victoriei asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei";


                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }


            if (cmbDisponibile.Text == "APARTAMENT")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "APARTAMENT";

                slide.Shapes[2].TextFrame.TextRange.Text = "Apartamentele ofera oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Apartamentele au vedere spre cladirea Cercului Militar si Calea Victoriei, asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei.";


                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }


            PP.SlideRange          ssr = pres.Slides.Range();
            PP.SlideShowTransition sst = ssr.SlideShowTransition;
            sst.AdvanceOnTime = Office.MsoTriState.msoTrue;
            sst.AdvanceTime   = 3;
            sst.EntryEffect   = PP.PpEntryEffect.ppEffectRevealSmoothRight;
            PP.SlideShowSettings ssp = pres.SlideShowSettings;
            ssp.StartingSlide = 1;
            ssp.EndingSlide   = pres.Slides.Count;
            ssp.Run();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPT文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        /// <param name="timeout">超时限制【以秒为单位】</param>
        public void PPTAuto(object presSet, int playTime, int timeout)
        {
            iSlideShowTime = playTime;
            objPresSet = (POWERPOINT.Presentation)presSet;

            if (timeout > 0 && objPresSet.Slides.Count * playTime > timeout)
            {
                objApp_SlideShowNextSlide(null);
                return;
            }

            objApp = objPresSet.Application;
            iSlideIndex = 0;
            try
            {
                // 自动播放的代码(开始)
                int Slides = objPresSet.Slides.Count;
                int[] SlideIdx = new int[Slides];
                for (int i = 0; i < Slides; i++) { SlideIdx[i] = i + 1; };
                objSldRng = objPresSet.Slides.Range(SlideIdx);
                objSST = objSldRng.SlideShowTransition;
                //关闭助手显示
                objApp.Assistant.On = false;
                objApp.Assistant.Visible = false;
                //设置翻页的时间.
                objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
                objSST.AdvanceTime = playTime;
                //翻页时的特效!
                objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;
                //Run the Slide show from slides 1 thru 3.
                objSSS = objPresSet.SlideShowSettings;
                objSSS.StartingSlide = 1;
                objSSS.EndingSlide = Slides;
                objApp.SlideShowNextSlide += new POWERPOINT.EApplication_SlideShowNextSlideEventHandler(objApp_SlideShowNextSlide);

                hook.Hook_Clear();
                hook.Hook_Start();

                objSSS.Run();
            }
            catch
            {
                hook.Hook_Clear();
            }
        }
Ejemplo n.º 16
0
        public static void IncludeOthers(string path)
        {
            //Build Slide #2:
            //Add text to the slide title, format the text. Also add a chart to the
            //slide and change the chart type to a 3D pie chart.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
            objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
            objTextRng.Text = "My Chart";
            objTextRng.Font.Name = "Comic Sans MS";
            objTextRng.Font.Size = 48;
            objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320,
              "MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "",
              MsoTriState.msoFalse).OLEFormat.Object;
            objChart.ChartType = Graph.XlChartType.xl3DPie;
            objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom;
            objChart.HasTitle = true;
            objChart.ChartTitle.Text = "Here it is...";

            //Build Slide #3:
            //Change the background color of this slide only. Add a text effect to the slide
            //and apply various color schemes and shadows to the text effect.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank);
            objSlide.FollowMasterBackground = MsoTriState.msoFalse;
            objShapes = objSlide.Shapes;
            objShape = objShapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect27,
              "The End", "Impact", 96, MsoTriState.msoFalse, MsoTriState.msoFalse, 230, 200);

            //Save the presentation to disk
            objPres.SaveAs(path,
                  PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
                  Microsoft.Office.Core.MsoTriState.msoFalse);
            //Modify the slide show transition settings for all 3 slides in
            //the presentation.
            int[] SlideIdx = new int[3];
            for (int k = 0; k < 3; k++) SlideIdx[k] = k + 1;
            objSldRng = objSlides.Range(SlideIdx);
            objSST = objSldRng.SlideShowTransition;
            objSST.AdvanceOnTime = MsoTriState.msoTrue;
            objSST.AdvanceTime = 3;
            objSST.EntryEffect = PowerPoint.PpEntryEffect.ppEffectBoxOut;

            //Prevent Office Assistant from displaying alert messages:
            // bAssistantOn = objApp.Assistant.On;
            // objApp.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPres.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide = 3;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);

            ////Reenable Office Assisant, if it was on:
            //if (bAssistantOn)
            //{
            //    objApp.Assistant.On = true;
            //    objApp.Assistant.Visible = false;
            //}

            //Close the presentation without saving changes and quit PowerPoint.
            //  objPres.Close();
            //  objApp.Quit();
        }
Ejemplo n.º 17
0
 private void PresentationStop()
 {
     Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
     objSSS = null;
         try
         {
             objPres.Close();
         }
         catch (System.NullReferenceException)
         {
         }
         catch(Exception objException)
         {
             //MessageBox.Show("Error"+ objException.StackTrace, "Error");
         }
     objPres = null;
     objPresSet = null;
     //WinApi.ShowTray();
     Taskbar.Show();
 }
Ejemplo n.º 18
0
        public void start_show1()
        {
            objSSWs = objApp.SlideShowWindows;

            objSlide.SlideShowTransition.AdvanceOnClick = MsoTriState.msoTrue;

            objApp.PresentationClose += new Microsoft.Office.Interop.PowerPoint.EApplication_PresentationCloseEventHandler(close_pres);
            // crate an instance with global hooks
            // hang on events

            //  actHook.KeyPress += new KeyPressEventHandler(key_pressed);
            objSSS = objPres.SlideShowSettings;
            objSSS.StartingSlide = (1);
            objSSS.EndingSlide = (1);
            objSSS.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowManualAdvance;

            objSSS.Run();
            objPres.SlideShowWindow.View.GotoSlide(1);
        }
Ejemplo n.º 19
0
        public ppt()
        {
            InitializeComponent();
            // Create an instance of the open file dialog box.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "PPT FILES (.pptx)|*.pptx|PPT Files (.ppt)|*.ppt|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = true;

            // Call the ShowDialog method to show the dialog box.
            DialogResult userClickedOK = openFileDialog1.ShowDialog();



            // Process input if the user clicked OK.
            if (userClickedOK == DialogResult.OK)
            {
                String file = openFileDialog1.FileName;

                pppt.Application application;

                try
                {
                    // For Display in Panel

                    IntPtr screenClasshWnd = (IntPtr)0;

                    IntPtr x = (IntPtr)0;

                    application = new pppt.Application();

                    presentation = application.Presentations.Open(@file, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);

                    panel1.Controls.Add(application as Control);

                    sst1 = presentation.SlideShowSettings;

                    sst1.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoCTrue;

                    pppt.Slides objSlides = presentation.Slides;

                    sst1.LoopUntilStopped = MsoTriState.msoTrue;

                    sst1.StartingSlide = 1;

                    sst1.EndingSlide = objSlides.Count;

                    panel1.Dock = DockStyle.Fill;

                    sst1.ShowType = pppt.PpSlideShowType.ppShowTypeKiosk;

                    pppt.SlideShowWindow sw = sst1.Run();

                    oSlideShowView = presentation.SlideShowWindow.View;

                    IntPtr pptptr = (IntPtr)sw.HWND;

                    //Gesteur Listener
                    Thread ges = new Thread(new ThreadStart(ges_listen));
                    ges.Start();
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 20
0
        /*      delegate void SetTextCallback(string text);
        private void SetText(string text)
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.lblSTrigger.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.lblSTrigger.Text = text;
            }
        }                  */
        private void PresentationStart()
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            try
            {
                objApp = new PowerPoint.Application();
                objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                objPres = objPresSet.Open(stSettings.strPPath, Microsoft.Office.Core.MsoTriState.msoFalse, // MsoTriState ReadOnly,
                Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);    //MsoTriState Untitled,MsoTriState WithWindow
            }
            catch (Exception e)
            {
                this.Activate();
                MessageBox.Show(e.Message);
                tsmPresentationStop_Click(null, null);
                return;
            }

            //objSlides = objPres.Slides;

            //Run the Slide show
            objSSS = objPres.SlideShowSettings;
            objSSS.ShowType = Microsoft.Office.Interop.PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
            objSSS.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoTrue;

            if (stSettings.bytRunMacro == 0 || stSettings.strPPMacroName=="")
            {
                objSSS.Run();
            }
            else
            {
                object[] oRunArgs = new Object[] { "'" + objPres.Name + "'!" + stSettings.strPPMacroName, stSettings.strMParam1, stSettings.strMParam2, stSettings.strMParam3 };
                try
                {
                    objApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, objApp, oRunArgs);
                    originalPWidth = objPres.SlideShowWindow.Width;
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    MessageBox.Show(e.Message + "\n" + "\n" + e.Source + "\n" + e.StackTrace);
                    return;
                }
                catch (Exception e)
                {
                    this.Activate();
                    MessageBox.Show(e.Message + "\n" + "\n" + e.InnerException.Source + "\nn" + e.InnerException.Message);
                    return;
                }
            }

            //handle
            //IntPtr hwnd = new IntPtr(objPres.SlideShowWindow.HWND);
            //WindowWrapper handleWrapper = new WindowWrapper(hwnd);
            //SetParent(handleWrapper.Handle, this.Handle);
            //this.Visible = true;
            if (stSettings.bytFullScreenPres==0)
            {
                SlideShowSize();
                //WinApi.HideTray();
                Taskbar.Hide();
            }
        }