Exemplo n.º 1
0
        public static void divideToLines(Slides slides, Slide slide, TextRange textRange)
        {
            var    slideNumber    = slide.SlideIndex;
            float  slideDuration  = slide.SlideShowTransition.AdvanceTime;
            int    divisionNumber = textRange.Lines().Count;
            float  duration       = durationAfterDivisions(slideDuration, divisionNumber / 2);
            string textFrmLines   = "";

            foreach (TextRange line in textRange.Lines())
            {
                if (textFrmLines.Length > 0)
                {
                    textFrmLines += line.Text;
                    SlidesManipulation.createNewSlide(slides, ++slideNumber, textFrmLines.Trim(), duration);
                    SlidesManipulation.createNewSlide(slides, ++slideNumber, "", 0.01F);
                    textFrmLines = "";
                }
                else
                {
                    textFrmLines += line.Text;
                }
            }
            //add the rest of textFrmLines
            if (textFrmLines.Length > 0)
            {
                SlidesManipulation.createNewSlide(slides, ++slideNumber, textFrmLines, duration);
                SlidesManipulation.createNewSlide(slides, ++slideNumber, "", 0.1F);
            }
            //delete slides
            slide.Delete();
            slides[slideNumber].Delete();
        }
Exemplo n.º 2
0
        public static void divideToSentences(Slides slides, Slide slide, TextRange textRange)
        {
            var   slideNumber   = slide.SlideIndex;
            float slideDuration = slide.SlideShowTransition.AdvanceTime;
            //the number represents to how many slides to divide
            int   divisionNumber = textRange.Sentences().Count;
            float duration       = durationAfterDivisions(slideDuration, divisionNumber);

            foreach (TextRange sentence in textRange.Sentences())
            {
                SlidesManipulation.createNewSlide(slides, ++slideNumber, sentence.Text.Trim(), duration);
                SlidesManipulation.createNewSlide(slides, ++slideNumber, "", 0.01F);
            }
            //delete slides
            slide.Delete();
            slides[slideNumber].Delete();
        }
Exemplo n.º 3
0
        public static void TestPresentation()
        {
            Application   PowerPoint_App      = new Application();
            Presentations multi_presentations = PowerPoint_App.Presentations;
            Presentation  presentation        = multi_presentations.Open(FilesController.openFile());
            string        presentation_text   = "";

            for (int i = 0; i < presentation.Slides.Count; i++)
            {
                foreach (var item in presentation.Slides[i + 1].Shapes)
                {
                    var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                    if (shape.HasTextFrame == MsoTriState.msoTrue)
                    {
                        if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            //Console.WriteLine("sentence: " + textRange.Sentences().Length);

                            //check if there are more than two lines, and needs additional divisions
                            if (textRange.Lines().Count > 2)
                            {
                                int   slideNumber   = shape.Parent.SlideIndex;
                                float slideDuration = presentation.Slides[i + 1].SlideShowTransition.AdvanceTime;
                                presentation.Slides[i + 1].Delete();
                                //CustomLayout customLayout = presentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];
                                if (textRange.Sentences().Count > 1)
                                {
                                    //the number represents to how many slides to divide
                                    int   divisionNumber = textRange.Sentences().Count;
                                    float duration       = TwoLines.durationAfterDivisions(slideDuration, divisionNumber);

                                    foreach (TextRange sentence in textRange.Sentences())
                                    {
                                        SlidesManipulation.createNewSlide(presentation.Slides, slideNumber++, sentence.Text.Trim(), duration);
                                    }
                                }
                                else
                                {
                                    int    divisionNumber = textRange.Lines().Count;
                                    float  duration       = TwoLines.durationAfterDivisions(slideDuration, divisionNumber / 2);
                                    string textFrmLines   = "";
                                    foreach (TextRange line in textRange.Lines())
                                    {
                                        if (textFrmLines.Length > 0)
                                        {
                                            textFrmLines += line.Text;
                                            SlidesManipulation.createNewSlide(presentation.Slides, slideNumber++, textFrmLines, duration);
                                            textFrmLines = "";
                                        }
                                        else
                                        {
                                            textFrmLines += line.Text;
                                        }
                                    }
                                }
                            }
                            var text = textRange.Text;
                            presentation_text += text + " ";
                        }
                    }
                }
            }
            PowerPoint_App.Quit();
            Console.WriteLine(presentation_text);
            FilesController.saveSlides(presentation);
        }
Exemplo n.º 4
0
 public static void Prepare()
 {
     SlidesManipulation.createPresentation(TitlesManipulation.readTitlesFromFile(FilesController.openFile(), 25.0F));
     //MainSpeech.Run();
 }