Пример #1
0
 public void EndPresentation()
 {
     if (pPre != null && pPre.SlideShowWindow.View.CurrentShowPosition > 1)
     {
         pPre.SlideShowWindow.View.EndNamedShow();
         pPre.Close();
         pApp.Quit();
         pApp = null;
         pPre = null;
     }
 }
Пример #2
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;
             *
             */
        }
Пример #3
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;
            }
        }
Пример #4
0
        public static void ConvertirPowerPoint(string nombrearchivo)
        {
            string logFile = BusinessVariables.Directorios.RepositorioRepositorio + @"LogArchivosWord.txt";

            if (!File.Exists(logFile))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(logFile))
                {
                    sw.WriteLine("Inicio Log" + DateTime.Now.ToString());
                }
            }
            PowerPoint._Application winWord = null;
            using (StreamWriter file = new StreamWriter(logFile))
            {
                try
                {
                    file.WriteLine("Inicia Proceso");
                    string htmlFilePath = BusinessVariables.Directorios.RepositorioInformacionConsultaHtml + Path.GetFileNameWithoutExtension(nombrearchivo) + ".htm";
                    string fileName     = BusinessVariables.Directorios.RepositorioInformacionConsulta + nombrearchivo;

                    PowerPoint.Application ppApp = new PowerPoint.Application();
                    ppApp.Visible = MsoTriState.msoTrue;
                    PowerPoint.Presentations ppPresens = ppApp.Presentations;
                    PowerPoint.Presentation  objPres   = ppPresens.Open(fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                    file.WriteLine("Abrio Presentacion");
                    file.WriteLine("Guardara Nueva Presentacion nuevo formato");
                    file.WriteLine(htmlFilePath);
                    objPres.SaveAs(htmlFilePath, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoCTrue);
                    file.WriteLine("Guardo nuevo formato");
                    PowerPoint.Slides objSlides = objPres.Slides;
                    //PowerPoint.SlideShowWindows objSSWs;
                    //PowerPoint.SlideShowSettings objSSS;
                    ////Run the Slide show
                    //objSSS = objPres.SlideShowSettings;
                    //objSSS.Run();
                    //objSSWs = ppApp.SlideShowWindows;
                    //while (objSSWs.Count >= 1)
                    //    System.Threading.Thread.Sleep(100);
                    ////Close the presentation without saving changes and quit PowerPoint
                    //objPres.Close();
                    ppApp.Quit();



                    //file.WriteLine("Inicia aplicacion");
                    //winWord = new PowerPoint.ApplicationClass();
                    //file.WriteLine("Abre Archivo");
                    //PowerPoint.Presentation prsPres = winWord.Presentations.Open(fileName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                    //file.WriteLine("Abrio Archivo");
                    //file.WriteLine(htmlFilePath);
                    //file.WriteLine("GuardaraNuevo Documento nuevo formato");
                    //prsPres.SaveAs(htmlFilePath, PowerPoint.PpSaveAsFileType.ppSaveAsHTML);
                    //file.WriteLine("Guardo nuevo formato");
                    //prsPres.Close();
                    //file.WriteLine("cerro documento");
                    //winWord.Quit();
                    //file.WriteLine("Cerro Word");
                }
                catch (Exception e)
                {
                    if (winWord != null)
                    {
                        winWord.Quit();
                    }
                    throw new Exception(e.Message);
                }
                finally
                {
                    GC.Collect();
                }
            }
        }