コード例 #1
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");
     }
 }
コード例 #2
0
        protected void ClearObject()
        {
            if (this.PptPresentation != null)
            {
                if (this.IsPresentationOpened)
                {
                    this.PptPresentation.Close();
                    this.IsPresentationOpened = false;
                }

                ReleaseObj.Marshal.ReleaseComObject(PptPresentation);
                this.PptPresentation = null;
            }


            if (this.PptApplication != null)
            {
                if (this.IsAppOpened)
                {
                    this.PptApplication.Quit();
                    this.IsAppOpened = false;
                }

                ReleaseObj.Marshal.ReleaseComObject(PptApplication);
                this.PptApplication = null;
            }

            this.ClearnGarbage();
        }
コード例 #3
0
        private void Form2_Load(object sender, EventArgs e)
        {
            string fileName   = @"C:\Users\Tridip\Desktop\KPIDashBoard20170125 125513.pptx";
            string exportName = "video_of_presentation";
            string exportPath = @"D:\test\Export\{0}.wmv";

            Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
            ppApp.Visible     = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppApp.WindowState = PpWindowState.ppWindowMinimized;
            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(fileName,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse);
            try
            {
                //oPres.CreateVideo(exportName);
                oPres.SaveCopyAs(String.Format(exportPath, exportName),
                                 Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsEMF,
                                 Microsoft.Office.Core.MsoTriState.msoCTrue);
            }
            finally
            {
                ppApp.Quit();
            }
        }
コード例 #4
0
 protected void InitPresentation()
 {
     this.Validate();
     this.InitApplication();
     this.PptPresentation      = PptApplication.Presentations.Open(strFile, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
     this.IsPresentationOpened = true;
 }
コード例 #5
0
 /// <summary>
 /// Sets all internal state back to null
 /// </summary>
 private void ResetState()
 {
     m_presentation     = null;
     m_originalFileName = null;
     m_newFileName      = null;
     m_statusFileName   = null;
 }
コード例 #6
0
 public override void Dispose()
 {
     if (_presentation != null)
     {
         Marshal.ReleaseComObject(_presentation);
         _presentation = null;
     }
 }
コード例 #7
0
ファイル: MyUI.cs プロジェクト: SHAREVIEW/ppt-network
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp         = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet     = objApp.Presentations;
     objPres        = objPresSet.Open(strTemplate,
                                      MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
コード例 #8
0
        private string ConvertPowerPoint(string FilePath)
        {
            try
            {
                // new object
                //objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                //var objPresentation = objPP.ActivePresentation;

                // get file name
                string[] file         = FilePath.Split('\\');
                string   FullFileName = file[file.Length - 1];
                // get extension
                string[] splittedFile = FullFileName.Split('.');
                string   ext          = splittedFile[splittedFile.Length - 1].ToUpper();
                string   filename     = splittedFile[splittedFile.Length - 2].ToUpper();


                // get convert folder directory
                string convertFolder = ConfigurationManager.AppSettings["ProjectHTMLRoot"];
                object target        = HttpContext.Current.Server.MapPath(convertFolder) + GetConvertPath(FilePath) + filename + ".htm";
                object source        = FilePath;


                if (ext == "PPT" || ext == "PPTX")
                {
                    //open the file internally in word. In the method all the parameters should be passed by object reference
                    string i = source.ToString();

                    objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                    objPP.DisplayAlerts = PpAlertLevel.ppAlertsNone;
                    Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = objPP.Presentations;
                    Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(FilePath,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse);
                    string t = target.ToString();
                    oPres.SaveAs(t, PpSaveAsFileType.ppSaveAsHTMLv3, Microsoft.Office.Core.MsoTriState.msoTrue);

                    return("../" + convertFolder + "/" + filename + ".htm");
                }
                else
                {
                    return("");
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                //Close/quit word
                //objPres.Close();
                objPP.Quit();
                Marshal.ReleaseComObject(objPP);
            }
        }
コード例 #9
0
 /// <summary>
 /// Opens the original word file and initializes the Word.Document object.
 /// The original file may be HTML, DOC, or RTF
 /// </summary>
 private void OpenDocument()
 {
     // Open the presentation (ppt file) based on the given file name
     // Note that the last parameter determines whether the
     // presentation should be opened within a visible window,
     // which in our case in "false".  Since in PowerPoint no
     // hiding of app is allowed ( i.e."pptApp.Visible = falseFlag;"
     //  won't work), we should not call pptApp.Activate();
     m_presentation = m_pptApp.Presentations.Open(m_originalFileName,
                                                  MS_FALSE, MS_FALSE, MS_FALSE);
 }
コード例 #10
0
        public void CreateNewPPT()
        {
            application        = new PowerPoint.Application();
            pptPresentationSet = application.Presentations;
            pptPresentation    = pptPresentationSet.Open(_fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            //customLayout = pptPresentationSet.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
            pptSlides = pptPresentation.Slides;
            pptSlide  = pptSlides.AddSlide(1, customLayout);

            textRng           = pptSlide.Shapes[1].TextFrame.TextRange;
            textRng.Font.Name = textDefaultFontName;
            textRng.Font.Size = textDefaultFontSize;
        }
コード例 #11
0
        public MainWindow()
        {
            InitializeComponent();


            mmiC          = new MmiCommunication("localhost", 8000, "User1", "GUI");
            mmiC.Message += MmiC_Message;
            mmiC.Start();
            oPowerPoint   = new PowerPoint.Application();
            oPresentation = oPowerPoint.Presentations.Add();
            examplePresentation();
            openpowerpoint   = true;
            presentationMode = false;
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: vinsource/vincontrol
        private static void GenerateVideoFromPowerPoint()
        {
            var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                oPresSet.Open(@"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.pptx",
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoTrue);

            string movie = @"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.wmv";

            oPres.CreateVideo(movie, true, 4, 480, 30, 100);
        }
コード例 #13
0
        /// <summary>
        /// Saves the document out with the appropriate new filename and format.
        /// Also does any special handling such as accepting/rejecting changes
        /// before saving.
        /// </summary>
        private void SaveDocument()
        {
            m_presentation.SaveAs(m_newFileName, m_newFormatType, MS_FALSE);

            try
            {
                m_presentation.Close();
            }
            catch (Exception e)
            {
                Logger.LogError("Failed to close PowerPoint presentation", e);
            }

            m_presentation = null;
        }
コード例 #14
0
        /// <summary>
        /// 初始化抓图线程
        /// </summary>
        /// <param name="objPres"></param>
        /// <returns></returns>
        private static Thread InitCaptureThread(PowerPoint._Presentation objPres)
        {
            var thread = new Thread(() =>
            {
                while (true)
                {
                    try
                    {
                        var bmp       = new Bitmap(width, height);
                        Graphics gSrc = Graphics.FromHwnd((IntPtr)objPres.SlideShowWindow.HWND);
                        IntPtr hdcSrc = gSrc.GetHdc();
                        Graphics gDes = Graphics.FromImage(bmp);
                        IntPtr hdcDes = gDes.GetHdc();

                        BitBlt(hdcDes, 0, 0, width, height, hdcSrc, 0, 0,
                               (int)(CopyPixelOperation.SourceCopy));

                        gSrc.ReleaseHdc(hdcSrc);
                        gDes.ReleaseHdc(hdcDes);
                        gSrc.Dispose();
                        gDes.Dispose();

                        _imageList.Enqueue(bmp);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    // 图片索引+1
                    _index++;

                    Thread.Sleep(5);
                }
            });

            // 设置最大优先级
            thread.Priority = ThreadPriority.Highest;

            return(thread);
        }
コード例 #15
0
        private bool GenerateVideoFromPowerPoint(DealerViewModel dealer, CarShortViewModel car)
        {
            try
            {
                var sourcePath     = (ConfigurationHandler.DealerImages + "/" + dealer.DealerId + "/" + car.Vin + "/NormalSizeImages");
                var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
                Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                    oPresSet.Open(sourcePath + String.Format(@"\{0} {1} {2} {3}.pptx", car.ModelYear, car.Make, car.Model, car.Trim),
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoTrue);

                string movie = sourcePath + String.Format(@"\{0} {1} {2} {3}.wmv", car.ModelYear, car.Make, car.Model, car.Trim);
                oPres.CreateVideo(movie, true, 4, 480, 30, 100);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #16
0
ファイル: Powerpoint.cs プロジェクト: skaulana/eflash
        /// <summary>
        /// Constructor that creates the PowerPoint object, so that we can add slides to it
        /// </summary>
        public Powerpoint()
        {
            String strTemplate;
            strTemplate = Constant.ePath + "eFlash.pot";
            //strTemplate = "C:\\Program Files\\eFlash\\Data\\Media\\" + "blank.pot";

            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
                MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;

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

            //start sCount at 1
            sCount = 1;
            oCount = 1;
        }
コード例 #17
0
        /// <summary>
        /// Constructor that creates the PowerPoint object, so that we can add slides to it
        /// </summary>
        public Powerpoint()
        {
            String strTemplate;

            strTemplate = Constant.ePath + "eFlash.pot";
            //strTemplate = "C:\\Program Files\\eFlash\\Data\\Media\\" + "blank.pot";

            //Create a new presentation based on a template.
            objApp         = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet     = objApp.Presentations;
            objPres        = objPresSet.Open(strTemplate,
                                             MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;

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

            //start sCount at 1
            sCount = 1;
            oCount = 1;
        }
コード例 #18
0
ファイル: TriggerForm.cs プロジェクト: GCRGCR/SSV
        /*      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();
            }
        }
コード例 #19
0
ファイル: TriggerForm.cs プロジェクト: GCRGCR/SSV
 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();
 }
コード例 #20
0
        private void MmiC_Message(object sender, MmiEventArgs e)
        {
            Console.WriteLine(e.Message);
            var     doc  = XDocument.Parse(e.Message);
            var     com  = doc.Descendants("command").FirstOrDefault().Value;
            dynamic json = JsonConvert.DeserializeObject(com);

            //json.recognized
            Console.WriteLine(json);
            Console.WriteLine("0: ");
            Console.WriteLine(json.recognized[0].ToString());
            Console.WriteLine("1: ");
            Console.WriteLine(json.recognized[1].ToString());



            //TODO: See where should have the method cleanAllConfirmations()
            //https://docs.microsoft.com/en-us/office/vba/api/powerpoint.slide
            switch ((string)json.recognized[0].ToString())
            {
            //TODO: pôr tudo o que está para baixo aqui dentro
            case "openPowerPoint":

                oPowerPoint   = new PowerPoint.Application();
                oPresentation = oPowerPoint.Presentations.Add();
                examplePresentation();
                openpowerpoint   = true;
                presentationMode = false;
                break;

            case "slide":
                switch ((string)json.recognized[1].ToString())
                {
                case "NEXT":
                    oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex + 1].Select();
                    break;

                case "NEXT_PRESENTATION":
                    oPresentation.SlideShowWindow.View.Next();
                    break;

                case "PREVIOUS":
                    oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex - 1].Select();
                    break;

                case "PREVIOUS_PRESENTATION":
                    oPresentation.SlideShowWindow.View.Previous();
                    break;

                case "JUMP_TO":
                    oPresentation.Slides[Int32.Parse(json.recognized[3].ToString())].Select();
                    break;

                case "JUMP_TO_SLIDE_PRESENTATION":
                    oPresentation.SlideShowWindow.View.GotoSlide(Int32.Parse(json.recognized[3].ToString()));
                    break;
                }
                break;

            case "read":
                switch ((string)json.recognized[1].ToString())
                {
                case "TITLE":
                    var title = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].Shapes.Title.TextFrame.TextRange.Text;
                    SendMsg_Tts(title, "speak");
                    break;

                case "TEXT":
                    var text = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].Shapes[2].TextFrame.TextRange.Text;
                    SendMsg_Tts(text, "speak");
                    break;

                case "NOTE":
                    var notas = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].NotesPage.Shapes[2].TextFrame.TextRange.Text;
                    SendMsg_Tts(notas, "speak");
                    break;

                case "TITLE_PRESENTATION":
                    var title_pres = oPresentation.SlideShowWindow.View.Slide.Shapes.Title.TextFrame.TextRange.Text;
                    SendMsg_Tts(title_pres, "speak");
                    break;

                case "TEXT_PRESENTATION":
                    var text_pres = oPresentation.SlideShowWindow.View.Slide.Shapes[2].TextFrame.TextRange.Text;
                    SendMsg_Tts(text_pres, "speak");
                    break;

                case "NOTE_PRESENTATION":
                    var note_pres = oPresentation.SlideShowWindow.View.Slide.NotesPage.Shapes[2].TextFrame.TextRange.Text;
                    SendMsg_Tts(note_pres, "speak");
                    break;
                }
                break;

            case "1":
                switch ((string)json.recognized[1].ToString())
                {
                case "CropI":
                    Console.WriteLine("DO CROP IN!");
                    SendMsg_Tts("Crop In encontra-se ativo.", "speak");
                    tShape.PictureFormat.CropLeft   = imgWidth * 20 / 100;
                    tShape.PictureFormat.CropRight  = imgWidth * 20 / 100;
                    tShape.PictureFormat.CropBottom = imgHeight * 20 / 100;
                    tShape.PictureFormat.CropTop    = imgHeight * 20 / 100;

                    break;
                }
                break;

            case "2":
                switch ((string)json.recognized[1].ToString())
                {
                case "CropO":
                    Console.WriteLine("DO CROP OUT!");
                    //crop Picture
                    SendMsg_Tts("Crop Out encontra-se ativo.", "speak");
                    tShape.PictureFormat.CropLeft   = imgWidth * (20 / 100);
                    tShape.PictureFormat.CropRight  = imgWidth * (20 / 100);
                    tShape.PictureFormat.CropBottom = imgHeight * (20 / 100);
                    tShape.PictureFormat.CropTop    = imgHeight * (20 / 100);

                    break;
                }
                break;

            case "3":
                switch ((string)json.recognized[1].ToString())
                {
                case "NextR":
                    if (presentationMode == true)
                    {
                        oPresentation.SlideShowWindow.View.Next();
                    }
                    else
                    {
                        oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex + 1].Select();
                    }
                    break;
                }
                break;

            case "5":
                switch ((string)json.recognized[1].ToString())
                {
                case "PreviouL":
                    Console.WriteLine("DO PREVIOUS!");
                    if (presentationMode == true)
                    {
                        oPresentation.SlideShowWindow.View.Previous();
                    }
                    else
                    {
                        oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex - 1].Select();
                    }
                    break;
                }
                break;

            case "6":
                switch ((string)json.recognized[1].ToString())
                {
                case "ThemaR":
                    switch ((string)json.recognized[3].ToString())
                    {
                    case "1":
                        SendMsg_Tts("Tema 1 encontra-se ativo.", "speak");

                        string dir = @"C:\Program Files (x86)\Microsoft Office\";
                        if (Directory.Exists(dir))
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Facet.thmx");
                        }
                        else
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Facet.thmx");
                        }


                        break;

                    case "2":
                        SendMsg_Tts("Tema 2 encontra-se ativo.", "speak");

                        string dir1 = @"C:\Program Files (x86)\Microsoft Office\";
                        if (Directory.Exists(dir1))
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Gallery.thmx");
                        }
                        else
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Gallery.thmx");
                        }
                        break;

                    case "3":
                        SendMsg_Tts("Tema 3 encontra-se ativo.", "speak");

                        string dir2 = @"C:\Program Files (x86)\Microsoft Office\";
                        if (Directory.Exists(dir2))
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Ion.thmx");
                        }
                        else
                        {
                            oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Ion.thmx");
                        }
                        break;
                    }
                    break;
                }
                break;

            case "7":
                switch ((string)json.recognized[1].ToString())
                {
                case "ZoomI":
                    Console.WriteLine("DO ZOOM IN!");
                    SendMsg_Tts("O modo Zoom In encontra-se ativo.", "speak");
                    tShape.ScaleHeight(1.2f, Microsoft.Office.Core.MsoTriState.msoFalse);
                    tShape.ScaleWidth(1.2f, Microsoft.Office.Core.MsoTriState.msoFalse);


                    break;
                }
                break;


            case "8":
                switch ((string)json.recognized[1].ToString())
                {
                case "ZoomO":
                    SendMsg_Tts("O modo Zoom Out encontra-se ativo.", "speak");
                    Console.WriteLine("DO ZOOM OUT!");
                    tShape.ScaleHeight(0.8f, Microsoft.Office.Core.MsoTriState.msoFalse);
                    tShape.ScaleWidth(0.8f, Microsoft.Office.Core.MsoTriState.msoFalse);

                    break;
                }
                break;


            case "4":
                switch ((string)json.recognized[1].ToString())
                {
                case "Open":

                    Console.WriteLine("OPEN Presentation Mode!");
                    oPresentation.SlideShowSettings.Run();
                    presentationMode = true;
                    SendMsg_Tts("open presentation grammer", "presentation");
                    SendMsg_Tts("O modo apresentação encontra-se ativo.", "speak");
                    break;
                }
                break;

            case "0":
                switch ((string)json.recognized[1].ToString())
                {
                case "Close":
                    Console.WriteLine("DO CLOSE!");
                    oPresentation.SlideShowWindow.View.Exit();
                    presentationMode = false;
                    SendMsg_Tts("change to edition grammer", "stop_presentation");
                    SendMsg_Tts("O modo apresentação foi desativado.", "speak");
                    break;
                }
                break;

            case "presentation":
                switch ((string)json.recognized[0].ToString())
                {
                case "START":
                    SendMsg_Tts("O modo apresentação foi ativado.", "speak");
                    oPresentation.SlideShowSettings.Run();
                    break;

                case "STOP_PRESENTATION":
                    SendMsg_Tts("O modo apresentação foi ativado.", "speak");
                    oPresentation.SlideShowWindow.View.Exit();
                    break;
                }
                break;


            case "close":
                oPowerPoint.Quit();
                System.Diagnostics.Process[] pros = System.Diagnostics.Process.GetProcesses();
                for (int i = 0; i < pros.Count(); i++)
                {
                    if (pros[i].ProcessName.ToLower().Contains("powerpnt"))
                    {
                        pros[i].Kill();
                    }
                }
                presentationMode = false;
                SendMsg_Tts("Power Point foi fechado", "speak");

                break;
            }
        }
コード例 #21
0
ファイル: MyUI.cs プロジェクト: prafulliu/ppter-network
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet = objApp.Presentations;
     objPres = objPresSet.Open(strTemplate,
         MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
コード例 #22
0
        static void Main(string[] args)
        {
            ParseArgs(args);

            var fileName = Path.GetFileNameWithoutExtension(_filePath);

            _noteFilePath   = Path.Combine(_outputPath, fileName + "_note.txt");
            _resultFilePath = Path.Combine(_outputPath, fileName + "_result.txt");

            if (!Directory.Exists(Path.Combine(_outputPath, "images")))
            {
                Directory.CreateDirectory(Path.Combine(_outputPath, "images"));
            }

            var imgsPath = Path.Combine(_outputPath, "images.jpg");

            try
            {
                _objApp  = new PowerPoint.Application();
                _objPres = _objApp.Presentations.Open(_filePath, WithWindow: MsoTriState.msoFalse);

                _objPres.SaveAs(imgsPath, PowerPoint.PpSaveAsFileType.ppSaveAsPNG, MsoTriState.msoTrue);


                // 保存备注
                SaveNoteInfo();

                // 设置呈现窗口
                SetSildeShowWindow();

                var pptRenderThread = InitPPTRenderThread();
                var imageSaveThread = InitImageSaveThread();

                pptRenderThread.Start();
                imageSaveThread.Start();

                while (_objApp.SlideShowWindows.Count >= 1)
                {
                    Thread.Sleep(deplyTime / 10);
                }

                pptRenderThread.Abort();
                //pptRenderThread.Join();
                imageSaveThread.Abort();
                //imageSaveThread.Join();

                _objPres.Save();

                _objApp.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // 杀死powerpnt
            KillProcess("powerpnt");

            SaveResult();

            // 退出
            Environment.Exit(0);
        }
コード例 #23
0
        /// <summary>
        /// Open a PPT deck and create a directory of jpg images, one for each slide in the deck.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="file"></param>
        private void processPpt(Guid g, FileInfo file)
        {
            if (stopNow)
            {
                return;
            }

            if (pptApp == null)
            {
                try {
                    pptApp = new PowerPoint.Application();
                    // Check if PPT was already running.
                    pptAlreadyOpen = (pptApp.Visible == MsoTriState.msoTrue);
                }
                catch (Exception e) {
                    log.WriteLine("Failed to create PowerPoint application instance. " + e.ToString());
                    log.ErrorLevel = 6;
                    pptApp         = null;
                    return;
                }
            }

            try {
                PowerPoint._Presentation ppPres = pptApp.Presentations.Open(file.FullName, MsoTriState.msoTrue,
                                                                            MsoTriState.msoFalse, MsoTriState.msoFalse);

                PowerPoint.Slides slides = ppPres.Slides;

                String tempDirName = Utility.GetTempDir();
                Directory.CreateDirectory(tempDirName);
                int slideCount = slides.Count;
                int ptStart    = progressTracker.CurrentValue;
                for (int i = 1; i <= slides.Count; i++)
                {
                    if (stopNow)
                    {
                        break;
                    }
                    //The image looks much better and is reasonably small if we save to wmf format first, then
                    // convert to jpg.  I guess the .Net jpeg encoder is better than the PPT encoder??
                    // Sometimes we may want to use the jpeg export with certain decks because we can get better
                    // fidelity with some less common symbols.

                    PowerPoint._Slide ppSlide = (PowerPoint._Slide)slides._Index(i);
                    String            jpgfile = Path.Combine(tempDirName, "slide" + i.ToString() + ".jpg");
                    Image             img     = null;
                    string            tmpfile = null;
                    if (useNativeJpegExport)
                    {
                        tmpfile = Path.Combine(tempDirName, "slidetmp" + i.ToString() + ".JPG");
                        ppSlide.Export(tmpfile, "JPG", 0, 0);
                        img = Image.FromFile(tmpfile);
                    }
                    else
                    {
                        tmpfile = Path.Combine(tempDirName, "slide" + i.ToString() + ".WMF");
                        ppSlide.Export(tmpfile, "WMF", 0, 0);
                        img = Image.FromFile(tmpfile);
                    }
                    try {
                        //The right shift is used to work around a CP3 issue: Some slide decks are shifted to the right, so we also
                        // need to do this to keep ink from being mis-aligned.  As of 2013 this should no longer be needed when
                        // using a current version of CP3.
                        if (rightShift > 0)
                        {
                            Image shiftedImage;
                            RightImageShift(img, rightShift, out shiftedImage);
                            shiftedImage.Save(jpgfile, ImageFormat.Jpeg);
                            shiftedImage.Dispose();
                        }
                        else
                        {
                            img.Save(jpgfile, ImageFormat.Jpeg);
                        }
                    }
                    catch (Exception e) {
                        log.WriteLine("Failed to save image for slide " + jpgfile + " exception: " + e.ToString());
                        log.ErrorLevel = 6;
                    }
                    img.Dispose();
                    System.IO.File.Delete(tmpfile);

                    progressTracker.CurrentValue = ((i * 100) / slideCount) + ptStart;
                }

                ppPres.Close();
                ppPres = null;

                this.outputDirs.Add(g, tempDirName);
            }
            catch (Exception e) {
                log.WriteLine(e.ToString());
                log.ErrorLevel = 6;
            }
        }
コード例 #24
0
 //-------------------------------------------------------------------------------
 protected void InitializePPT()
 {
     application = (PowerPoint.ApplicationClass)Server.CreateObject("PowerPoint.Application");
      presentations = application.Presentations;
      presentation = presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue);
      slides = presentation.Slides;
 }
コード例 #25
0
        public static void ShowPresentation(string path)
        {
            String strTemplate ; //, strPic;
            string Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            string LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", "");

            strTemplate = System.IO.Path.Combine(LocalDir, "Resources", "Template.pptx");
            //"\\\\flrblr001\\windows_data\\From-SLI-Fileserver\\E\\Product Engineering\\Sundar\\svn\\trunk\\CommonBase\\DeviceSpecific\\Si53300\\sample_data\\Template.pptx";
            //strPic = "C:\\Windows\\Blue Lace 16.bmp";
            //bool bAssistantOn;
            if (!System.IO.File.Exists(strTemplate)) {
                System.Windows.MessageBox.Show("Template file is missing, create the file: " + strTemplate);
            }
            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
              MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;
            objApp.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized;
        }
コード例 #26
0
        public void RunPPTMacro(string pptFileName, string excelFile, string macro, bool visible)
        {
            //### improve & cleanup code

            // Define Workbooks
            PowerPoint.Application   oPP         = null;
            PowerPoint.Presentations oPresSet    = null;
            PowerPoint._Presentation _activePres = null;
            object oMissing = System.Reflection.Missing.Value;

            string mess = "";

            try
            {
                //open Excel
                //System.Diagnostics.Process excelProc = System.Diagnostics.Process.Start(excelFile);

                Excel2.Application oExcel = new Excel2.Application();
                oExcel.Visible       = false;
                oExcel.DisplayAlerts = false;
                Excel2.Workbooks oBooks = oExcel.Workbooks;
                Excel2._Workbook oBook  = oBooks.Open(excelFile, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
                                                      oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);

                FileInfo fi = new FileInfo(pptFileName);

                //string pptTempName = fi.DirectoryName + @"\TEMP.pptm";

                oPP = new PowerPoint.Application();
                oPP.DisplayAlerts = Microsoft.Office.Interop.PowerPoint.PpAlertLevel.ppAlertsNone;
                //oPP.Visible = MsoTriState.msoFalse;

                oPresSet    = oPP.Presentations;
                _activePres = oPresSet.Open(fi.FullName, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                //Object[] oRunArgs = { "'" + fi.Name + "'!M2" };
                Object[] oRunArgs = { "'" + fi.Name + "'!" + macro };
                oPP.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null,
                                           oPP, oRunArgs);

                //close Excel
                try
                {
                    //excelProc.CloseMainWindow();
                    //excelProc.Close();
                    //excelProc.Dispose();
                    //excelProc.Kill();
                }
                catch (Exception exCloseExcel)
                {
                    //excelProc.Kill();
                }

                //save excel file
                //oBook.Save();

                // Quit Excel and clean up.
                Thread.Sleep(1000);
                oBook.Close(false, oMissing, oMissing);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook);
                oBook = null;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks);
                oBooks = null;
                oExcel.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel);
                oExcel = null;


                mess += "kill excel" + Environment.NewLine;

                //_activePres.Final = false;

                Thread.Sleep(2000);

                _activePres.Save();

                //_activePres.SaveAs(pptTempName);

                mess += "save ppt temp" + Environment.NewLine;

                Thread.Sleep(2000);

                //_activePres.Final = true;

                // Quit PPT and clean up.
                if (_activePres != null)
                {
                    mess += "check activepres = null" + Environment.NewLine;
                    try
                    {
                        _activePres.Close();
                        mess += "activepres close" + Environment.NewLine;
                    }
                    catch (Exception exClosePresentation) { }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_activePres);
                    mess       += "release activepres" + Environment.NewLine;
                    _activePres = null;
                    mess       += "activepres = null" + Environment.NewLine;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPresSet);
                    mess    += "release presset" + Environment.NewLine;
                    oPresSet = null;
                    mess    += "presset null" + Environment.NewLine;
                    try
                    {
                        Thread.Sleep(1000);
                        oPP.Quit();
                        mess += "opp quit" + Environment.NewLine;
                    }
                    catch (Exception exQuitPPT) { }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPP);
                    mess += "release opp" + Environment.NewLine;
                    oPP   = null;
                    mess += "opp = null" + Environment.NewLine;
                }

                GC.Collect();
                mess += "garbage" + Environment.NewLine;

                //Kill PPT File
                var processes = from p in Process.GetProcessesByName("POWERPNT") select p;

                foreach (var process in processes)
                {
                    //if (process.MainWindowTitle == "TEMP.pptm")
                    try
                    {
                        mess += "test process null" + Environment.NewLine;
                        if (process != null)
                        {
                            process.Close();
                            Thread.Sleep(1000);
                            mess += "close process" + Environment.NewLine;

                            if (process != null)
                            {
                                process.Kill();
                                mess += "kil process" + Environment.NewLine;
                            }
                        }
                    }
                    catch (Exception exCloseProc) { }
                }

                //rename file & delete temp file
                //if (File.Exists(pptFileName))
                //{
                //    File.Delete(pptFileName);
                //    mess += "delete ppt" + Environment.NewLine;
                //    File.Move(pptTempName, pptFileName);
                //    mess += "move temp" + Environment.NewLine;
                //}

                //if (File.Exists(pptTempName))
                //    File.Delete(pptTempName);
                //mess += "delete temp" + Environment.NewLine;
            }
            catch (Exception ex)
            {
                if (_activePres != null)
                {
                    try
                    {
                        _activePres.Close();
                    }
                    catch (Exception ex2) { }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPresSet);
                    oPresSet = null;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_activePres);
                    _activePres = null;
                }

                if (oPP != null)
                {
                    try
                    {
                        oPP.Quit();
                    }
                    catch (Exception ex2) { }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPP);
                    oPP = null;
                }

                log.Error("Error :: RunPPTMacro : " + ex.Message);
                throw ex;
            }
        }
コード例 #27
0
        private void MmiC_Message(object sender, MmiEventArgs e)
        {
            Console.WriteLine(e.Message);
            var     doc  = XDocument.Parse(e.Message);
            var     com  = doc.Descendants("command").FirstOrDefault().Value;
            dynamic json = JsonConvert.DeserializeObject(com);

            Console.WriteLine(json);
            Console.WriteLine((string)json.recognized[0].ToString());
            Console.WriteLine((string)json.keys[0].ToString());

            Tts t = new Tts();

            //TODO: See where should have the method cleanAllConfirmations()
            //https://docs.microsoft.com/en-us/office/vba/api/powerpoint.slide
            switch ((string)json.keys[0].ToString())
            {
            //TODO: pôr tudo o que está para baixo aqui dentro
            case "openPowerPoint":
                oPowerPoint   = new PowerPoint.Application();
                oPresentation = oPowerPoint.Presentations.Add();
                break;

            case "slide":
                switch ((string)json.recognized[0].ToString())
                {
                case "NEXT_PRESENTATION":
                    oPresentation.SlideShowWindow.View.Next();
                    break;

                case "PREVIOUS_PRESENTATION":
                    oPresentation.SlideShowWindow.View.Previous();
                    break;

                case "NEXT":
                    oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex + 1].Select();
                    break;

                case "PREVIOUS":
                    oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex - 1].Select();
                    break;

                case "JUMP_TO":
                    oPresentation.Slides[Int32.Parse(json.recognized[1].ToString())].Select();
                    break;

                case "JUMP_TO_SLIDE_PRESENTATION":
                    oPresentation.SlideShowWindow.View.GotoSlide(Int32.Parse(json.recognized[1].ToString()));
                    break;

                case "NEW_SLIDE":
                    if (oPresentation.Slides.Count == 0)
                    {
                        oPresentation.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitle).Select();
                    }
                    else
                    {
                        oPresentation.Slides.Add(oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex + 1, PowerPoint.PpSlideLayout.ppLayoutTitle).Select();;
                    }
                    break;


                case "REMOVE_SLIDE":
                    if (oPresentation.Slides.Count > 0)
                    {
                        oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].Delete();
                        t.Speak("Slide removido!");
                    }
                    else
                    {
                        t.Speak("Não existe nenhum slide.");
                    }
                    break;
                }
                break;

            case "read":
                switch ((string)json.recognized[0].ToString())
                {
                case "TITLE":
                    var title = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].Shapes.Title.TextFrame.TextRange.Text;
                    t.Speak(title);
                    break;

                case "TEXT":
                    var text = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].Shapes[2].TextFrame.TextRange.Text;
                    t.Speak(text);
                    break;

                case "NOTE":
                    var notas = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex].NotesPage.Shapes[2].TextFrame.TextRange.Text;
                    t.Speak(notas);
                    break;

                case "TITLE_PRESENTATION":
                    var title_pres = oPresentation.SlideShowWindow.View.Slide.Shapes.Title.TextFrame.TextRange.Text;
                    t.Speak(title_pres);
                    break;

                case "TEXT_PRESENTATION":
                    var text_pres = oPresentation.SlideShowWindow.View.Slide.Shapes[2].TextFrame.TextRange.Text;
                    t.Speak(text_pres);
                    break;

                case "NOTE_PRESENTATION":
                    var note_pres = oPresentation.SlideShowWindow.View.Slide.NotesPage.Shapes[2].TextFrame.TextRange.Text;
                    t.Speak(note_pres);
                    break;
                }
                break;



            case "theme":
                switch ((string)json.recognized[0].ToString())
                {
                case "1":

                    string dir = @"C:\Program Files (x86)\Microsoft Office\";
                    if (Directory.Exists(dir))
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Facet.thmx");
                    }
                    else
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Facet.thmx");
                    }


                    break;

                case "2":

                    string dir1 = @"C:\Program Files (x86)\Microsoft Office\";
                    if (Directory.Exists(dir1))
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Gallery.thmx");
                    }
                    else
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Gallery.thmx");
                    }
                    break;

                case "3":
                    string dir2 = @"C:\Program Files (x86)\Microsoft Office\";
                    if (Directory.Exists(dir2))
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files (x86)\Microsoft Office\root\Document Themes 16\Ion.thmx");
                    }
                    else
                    {
                        oPresentation.ApplyTheme(@"C:\Program Files\Microsoft Office\root\Document Themes 16\Ion.thmx");
                    }
                    break;
                }
                break;

            case "save":
                oPresentation.Save();
                break;

            case "color":
                Slide     activeSlide = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex];;
                TextRange textRange   = activeSlide.Shapes.Title.TextFrame.TextRange;;
                if (json.recognized.Count > 1)
                {
                    switch ((string)json.recognized[0].ToString())
                    {
                    /*case "TITLE":
                     *  activeSlide = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex];
                     *  textRange = activeSlide.Shapes.Title.TextFrame.TextRange;
                     *  break;*/
                    case "TEXT":
                        activeSlide = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex];
                        textRange   = activeSlide.Shapes[2].TextFrame.TextRange;
                        break;
                    }
                }
                switch ((string)json.recognized[1].ToString())
                {
                case "YELLOW":
                    textRange.Font.Color.RGB = 379903;
                    t.Speak("Mudado para Amarelo");
                    break;

                case "RED":
                    textRange.Font.Color.RGB = 255;
                    t.Speak("Mudado para Vermelho");
                    break;

                case "BLUE":
                    textRange.Font.Color.RGB = 16711680;
                    t.Speak("Mudado para Azul");
                    break;

                case "GREEN":
                    textRange.Font.Color.RGB = 2540123;
                    t.Speak("Mudado para Verde");
                    break;

                case "BLACK":
                    textRange.Font.Color.RGB = 0;
                    t.Speak("Mudado para Preto");
                    break;
                }
                break;

            case "example":
                String presentationTitle = "Proposta de Trabalho 2";

                //Save the file
                //oPresentation.SaveAs(presentationTitle, PowerPoint.PpSaveAsFileType.ppSaveAsPresentation);

                //Add a new slide with Title Layout
                oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutTitle);
                tShape = oSlide.Shapes.Title;
                tShape.TextFrame.TextRange.Text = presentationTitle;
                tShape = oSlide.Shapes[2];
                tShape.TextFrame.TextRange.Text = "Carlos Ribeiro\nGisela Pinto";

                oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutText);
                tShape = oSlide.Shapes.Title;
                tShape.TextFrame.TextRange.Text = "Tema";
                tShape = oSlide.Shapes[2];
                tShape.TextFrame.TextRange.Text = "Interação por voz do Powerpoint";

                //Add Image
                //tShape = oSlide.Shapes.AddPicture("imagePowerPoint.png", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0);

                oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutText);
                tShape = oSlide.Shapes.Title;
                tShape.TextFrame.TextRange.Text = "Features para utilizar durante uma apresentação";
                tShape = oSlide.Shapes[2];
                tShape.TextFrame.TextRange.Text = "Avançar slide.\n" +
                                                  "Recuar slide.\n" +
                                                  "Saltar slides, por exemplo mudar do slide 2 para o 5.\n" +
                                                  "Ler texto de um slide.\n" +
                                                  "Ler notas de um slide fazendo assim a apresentação completa.\n" +
                                                  "Terminar a apresentação.\n" +
                                                  "Controlar um video que esteja integrado no slide(Iniciar/ parar).";

                oSlide.NotesPage.Shapes[2].TextFrame.TextRange.Text = "Eu, Salvador, estou a ler notas do slide 3, beijinhos e abraços";

                //oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutText);

                //tShape = oSlide.Shapes.AddMediaObject2(@"C:\Users\Gisela Pinto\Documents\IM\Trabalho1\im_2019_2020\Basis4Assignment2\ppt.mp4", MsoTriState.msoTrue, MsoTriState.msoTrue, 8, 8, 530, 530);

                oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutText);
                tShape = oSlide.Shapes.Title;
                tShape.TextFrame.TextRange.Text = "Features para construção de uma apresentação";
                tShape = oSlide.Shapes[2];
                tShape.TextFrame.TextRange.Text = "Iniciar a criação da apresentação com um dos temas sugeridos.\n" +
                                                  "Acrescentar um novo slide em branco/ duplicado.\n" +
                                                  "Remover determinado slide.\n" +
                                                  "Escrever o que o utilizador ditar.\n" +
                                                  "Guardar alterações.\n" +
                                                  "Mudar cor do texto(algumas cores mais usadas).";
                oPresentation.Slides[oSlide.SlideIndex].Select();
                break;

            case "presentation":
                switch ((string)json.recognized[0].ToString())
                {
                case "START":
                    oPresentation.SlideShowSettings.Run();
                    break;

                case "STOP_PRESENTATION":
                    oPresentation.SlideShowWindow.View.Exit();
                    break;
                }
                break;

            case "close":
                oPowerPoint.Quit();
                System.Diagnostics.Process[] pros = System.Diagnostics.Process.GetProcesses();
                for (int i = 0; i < pros.Count(); i++)
                {
                    if (pros[i].ProcessName.ToLower().Contains("powerpnt"))
                    {
                        pros[i].Kill();
                    }
                }
                break;
            }

            /*
             *
             *
             * //Edition
             *
             *
             *          case "COLOR_TITLE":
             *              var activeSlide = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex];
             *              rangeTitle = activeSlide.Shapes.Title.TextFrame.TextRange;
             *              if (json.recognized.Count > 1) {
             *                  switch ((string)json.recognized[1].ToString()) {
             *                      case "YELLOW":
             *                          rangeTitle.Font.Color.RGB = 379903;
             *                          t.Speak("Mudado para Amarelo");
             *                          break;
             *                      case "RED":
             *                          rangeTitle.Font.Color.RGB = 255;
             *                          t.Speak("Mudado para Vermelho");
             *                          break;
             *                      case "BLUE":
             *                          rangeTitle.Font.Color.RGB = 16711680;
             *                          t.Speak("Mudado para Azul");
             *                          break;
             *                      case "GREEN":
             *                          rangeTitle.Font.Color.RGB = 2540123;
             *                          t.Speak("Mudado para Verde");
             *                          break;
             *                      case "BLACK":
             *                          rangeTitle.Font.Color.RGB = 0;
             *                          t.Speak("Mudado para Preto");
             *                          break;
             *                  }
             *              }else {
             *                  t.Speak("Deseja mudar para que cor?");
             *                  selectColorTitle = true;
             *              }
             *              break;
             *
             *          case "COLOR_TEXT":
             *              t.Speak("Deseja mudar para que cor?");
             *              var activeSlide2 = oPresentation.Slides[oPowerPoint.ActiveWindow.Selection.SlideRange.SlideIndex];
             *              rangeShape = activeSlide2.Shapes[2].TextFrame.TextRange;
             *              if (json.recognized.Count > 1) {
             *                  switch ((string)json.recognized[1].ToString()) {
             *                      case "YELLOW":
             *                          rangeTitle.Font.Color.RGB = 379903;
             *                          t.Speak("Mudado para Amarelo");
             *                          break;
             *                      case "RED":
             *                          rangeTitle.Font.Color.RGB = 255;
             *                          t.Speak("Mudado para Vermelho");
             *                          break;
             *                      case "BLUE":
             *                          rangeTitle.Font.Color.RGB = 16711680;
             *                          t.Speak("Mudado para Azul");
             *                          break;
             *                      case "GREEN":
             *                          rangeTitle.Font.Color.RGB = 2540123;
             *                          t.Speak("Mudado para Verde");
             *                          break;
             *                      case "BLACK":
             *                          rangeTitle.Font.Color.RGB = 0;
             *                          t.Speak("Mudado para Preto");
             *                          break;
             *                  }
             *              } else {
             *                  t.Speak("Deseja mudar para que cor?");
             *                  selectColorText = true;
             *              }
             *              break;
             *
             *          case "YELLOW":
             *              if (selectColorTitle == true) {
             *                  selectColorTitle = false;
             *                  rangeTitle.Font.Color.RGB = 379903;
             *                  t.Speak("Mudado para Amarelo");
             *              } else if (selectColorText == true) {
             *                  selectColorText = false;
             *                  rangeShape.Font.Color.RGB = 379903;
             *                  t.Speak("Mudado para Amarelo");
             *              } else {
             *                  t.Speak("Devo ter percebido mal.");
             *
             *              }
             *              break;
             *
             *          case "RED":
             *              if (selectColorTitle == true) {
             *                  selectColorTitle = false;
             *                  rangeTitle.Font.Color.RGB = 255;
             *                  t.Speak("Mudado para Vermelho");
             *              } else if (selectColorText == true) {
             *                  selectColorText = false;
             *                  rangeShape.Font.Color.RGB = 255;
             *                  t.Speak("Mudado para Vermelho");
             *              } else {
             *                  t.Speak("Devo ter percebido mal.");
             *              }
             *              break;
             *
             *          case "BLUE":
             *              if (selectColorTitle == true) {
             *                  selectColorTitle = false;
             *                  rangeTitle.Font.Color.RGB = 16711680;
             *                  t.Speak("Mudado para Azul");
             *              } else if (selectColorText == true) {
             *                  selectColorText = false;
             *                  rangeShape.Font.Color.RGB = 16711680;
             *                  t.Speak("Mudado para Azul");
             *              } else {
             *
             *                  t.Speak("Devo ter percebido mal.");
             *
             *              }
             *              break;
             *
             *          case "GREEN":
             *              if (selectColorTitle == true) {
             *                  selectColorTitle = false;
             *                  rangeTitle.Font.Color.RGB = 2540123;
             *                  t.Speak("Mudado para Verde");
             *              } else if (selectColorText == true) {
             *                  selectColorText = false;
             *                  rangeShape.Font.Color.RGB = 2540123;
             *                  t.Speak("Mudado para Verde");
             *              } else {
             *                  t.Speak("Devo ter percebido mal.");
             *              }
             *              break;
             *
             *          case "BLACK":
             *              if (selectColorTitle == true) {
             *                  selectColorTitle = false;
             *                  rangeTitle.Font.Color.RGB = 0;
             *                  t.Speak("Mudado para Preto");
             *              } else if (selectColorText == true) {
             *                  selectColorTitle = false;
             *                  rangeShape.Font.Color.RGB = 0;
             *                  t.Speak("Mudado para Preto");
             *              } else {
             *                  t.Speak("Devo ter percebido mal.");
             *              }
             *              break;
             *
             */
        }
コード例 #28
0
        public static bool convertToNewOfficeDocument(string fileName, out string newFileName, out string newExt)
        {
            string ext = Path.GetExtension(fileName);

            newExt = ext;


            newFileName = fileName;


            if (!destinationDictionary.ContainsKey(ext))
            {
                return(false);
            }

            officeDestination dest = destinationDictionary[ext];

            newExt = dest.Extension;

            newFileName = fileName.Replace(ext, dest.Extension);

            object obj;

            bool result = true;

            switch (dest.Application)
            {
            case officeApplication.Word:
                Word._Application wordApp = new Word.Application();
                Word._Document    wordDoc = null;

                try
                {
                    wordDoc = wordApp.Documents.Open(fileName);
                    wordDoc.Convert();
                    wordDoc.SaveAs(newFileName, dest.FileFormat);
                }
                catch (Exception e)
                {
                    displayError(fileName, e);
                    newFileName = fileName;
                    result      = false;
                }
                finally
                {
                    wordDoc.Close();
                    wordApp.Quit();
                    obj = (object)wordDoc;
                    disposeInteropObject(ref obj);
                    obj = (object)wordApp;
                    disposeInteropObject(ref obj);
                }
                break;

            case officeApplication.Excel:
                Excel._Application excelApp = new Excel.Application();
                Excel._Workbook    excelDoc = null;
                try
                {
                    excelDoc = excelApp.Workbooks.Open(fileName);
                    excelDoc.SaveAs(newFileName, dest.FileFormat);
                }
                catch (Exception e)
                {
                    displayError(fileName, e);
                    newFileName = fileName;
                    result      = false;
                }
                finally
                {
                    excelDoc.Close();
                    excelApp.Quit();
                    obj = (object)excelDoc;
                    disposeInteropObject(ref obj);
                    obj = (object)excelApp;
                    disposeInteropObject(ref obj);
                }
                break;

            case officeApplication.PowerPoint:
                PowerPoint._Application  powerpointApp = new PowerPoint.Application();
                PowerPoint._Presentation powerpointDoc = null;
                try
                {
                    powerpointDoc = powerpointApp.Presentations.Open(fileName, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
                    powerpointDoc.SaveAs(newFileName, (PowerPoint.PpSaveAsFileType)dest.FileFormat);
                }
                catch (Exception e)
                {
                    displayError(fileName, e);
                    newFileName = fileName;
                    result      = false;
                }
                finally
                {
                    powerpointDoc.Close();
                    powerpointApp.Quit();
                    obj = (object)powerpointDoc;
                    disposeInteropObject(ref obj);
                    obj = (object)powerpointApp;
                    disposeInteropObject(ref obj);
                }
                break;
            }

            GC.Collect();
            return(result);
        }
コード例 #29
0
 private void Start_Click(object sender, EventArgs e)
 {
     PowerPoint.Presentations oPresSet = oPPT.Presentations;
     PowerPoint._Presentation oPres    = oPresSet.Open("c:\\pres1.ppt", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
     //oPres.SlideShowSettings.Run();
 }
コード例 #30
0
ファイル: Program.cs プロジェクト: wuqingman/PPT2Vedio
        static void Main(string[] args)
        {
            ParseArgs(args);

            var fileName = Path.GetFileNameWithoutExtension(_filePath);

            _noteFilePath =  Path.Combine(_outputPath, fileName + "_note.txt");
            _resultFilePath = Path.Combine(_outputPath, fileName + "_result.txt");

            if (!Directory.Exists(Path.Combine(_outputPath, "images")))
            {
                Directory.CreateDirectory(Path.Combine(_outputPath, "images"));
            }

            var imgsPath = Path.Combine(_outputPath, "images.jpg");
            try
            {
                _objApp = new PowerPoint.Application();
                _objPres = _objApp.Presentations.Open(_filePath, WithWindow: MsoTriState.msoFalse);

                _objPres.SaveAs(imgsPath, PowerPoint.PpSaveAsFileType.ppSaveAsPNG, MsoTriState.msoTrue);

                // 保存备注
                SaveNoteInfo();

                // 设置呈现窗口
                SetSildeShowWindow();

                var pptRenderThread = InitPPTRenderThread();
                var imageSaveThread = InitImageSaveThread();

                pptRenderThread.Start();
                imageSaveThread.Start();

                while (_objApp.SlideShowWindows.Count >= 1) Thread.Sleep(deplyTime / 10);

                pptRenderThread.Abort();
                //pptRenderThread.Join();
                imageSaveThread.Abort();
                //imageSaveThread.Join();

                _objPres.Save();

                _objApp.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // 杀死powerpnt
            KillProcess("powerpnt");

            SaveResult();

            // 退出
            Environment.Exit(0);
        }
コード例 #31
0
 public PowerPointActivePresentation(IOfficeApplication application, MsPowerPoint._Presentation presentation)
     : base(application, presentation.FullName)
 {
     _presentation = presentation;
     InitializeWsDocument(FullPath);
 }
コード例 #32
0
ファイル: create_new_pres.cs プロジェクト: AliHosny/Vote-MZ
        //Create a new and initialize it;s presentation
        public void Init()
        {
            objApp = new PowerPoint.Application();

            flag = 0;

            objPresSet = objApp.Presentations;
            //objPres = objPresSet.Add(MsoTriState.msoTrue);

               objPres= objPresSet.Open("c://sample.pptx");
            objSlides = objPres.Slides;
        }