private void Button_Click(object sender, RoutedEventArgs e) { EzPPTSlidePage ezPPTSlidePage = new EzPPTSlidePage(index); this.NavigationService.Navigate(ezPPTSlidePage); // no images on title page, just text SlideInfo slideInfo = new SlideInfo(this.title.Text, this.subtitle.Text, new List <String>()); SlideInfoCollection.GetInstance().AddToCollection(slideInfo); }
private void Next_Button_Click(object sender, RoutedEventArgs e) { currentSlideInfo.title = this.title.Text; currentSlideInfo.text = this.text.Text; if (SlideInfoCollection.GetInstance().NumberOfSlides() <= index) { SlideInfoCollection.GetInstance().AddToCollection(currentSlideInfo); } else { SlideInfoCollection.GetInstance().EditSlideInCollection(index, currentSlideInfo); } EzPPTSlidePage ezPPTSlidePage = new EzPPTSlidePage(index); this.NavigationService.Navigate(ezPPTSlidePage); }
private void Confirm_Finish_Button_Click(object sender, RoutedEventArgs e) { //Add the page we were on to the list, unless it's totally empty if (this.slideWhenPressed.text != null || this.slideWhenPressed.title != null || this.slideWhenPressed.imageURLs.Count != 0) { SlideInfoCollection.GetInstance().AddToCollection(this.slideWhenPressed); } //Fetch our list of slides List <SlideInfo> slideInfo = SlideInfoCollection.GetInstance().GetList(); //Spin up PPT. Application application = new Application(); //These represent the array of slides, the individual slide we are editing, and the area of text we're dealing with. Slides slides; _Slide slide; //Open a new presentation, fetch the title page. We'll stitch together the first one by hand before a loop. Presentation pptPresentation = application.Presentations.Add(MsoTriState.msoTrue); CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutTitle]; //Assign the slides variable the value of the slides inside of ppt, then create our first title slide. slides = pptPresentation.Slides; slide = slides.AddSlide(1, customLayout); slide.Shapes.Title.TextFrame.TextRange.Text = slideInfo[0].title; slide.Shapes[2].TextFrame.TextRange.Text = slideInfo[0].text; //Onto the regular slides. int i = 2; bool firstPass = true; foreach (SlideInfo info in slideInfo) { if (firstPass) { firstPass = false; continue; } int numOfPictures = info.imageURLs.Count; //Configure the layout of the slide switch (numOfPictures) { case 0: customLayout = pptPresentation.SlideMaster.CustomLayouts[2]; break; case 1: customLayout = pptPresentation.SlideMaster.CustomLayouts[9]; break; case 2: customLayout = pptPresentation.SlideMaster.CustomLayouts[5]; break; } //Add the title of the slide slide = slides.AddSlide(i, customLayout); slide.Shapes[1].TextFrame.TextRange.Text = info.title; /* * There is a lot of duplicated code living here. * The way that interop is set up, you can't pass these TextRanges as ref in functions, * so I can't do this in a nice function call, I have to do it here. */ List <int> boldWordIndexes = new List <int>(); switch (numOfPictures) { case 0: boldWordIndexes = GetIndicesOfBold(info.text); info.text = info.text.Replace("**", ""); slide.Shapes[2].TextFrame.TextRange.Text = info.text; foreach (int boldIndex in boldWordIndexes) { slide.Shapes[2].TextFrame.TextRange.Words(boldIndex).Font.Bold = MsoTriState.msoTrue; } break; case 1: boldWordIndexes = GetIndicesOfBold(info.text); info.text = info.text.Replace("**", ""); slide.Shapes[3].TextFrame.TextRange.Text = info.text; foreach (int boldIndex in boldWordIndexes) { slide.Shapes[3].TextFrame.TextRange.Words(boldIndex).Font.Bold = MsoTriState.msoTrue; } var shape = slide.Shapes[2]; slide.Shapes.AddPicture(info.imageURLs[0], MsoTriState.msoFalse, MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height); slide.NotesPage.Shapes[2].TextFrame.TextRange.Text = "You may need to manually resize your images!"; break; case 2: //split input on double newline string[] separators = { "\r\n\r\n" }; string[] textArr = info.text.Split(separators, StringSplitOptions.RemoveEmptyEntries); boldWordIndexes = GetIndicesOfBold(textArr[0]); slide.Shapes[2].TextFrame.TextRange.Text = textArr[0].Replace("**", ""); foreach (int boldIndex in boldWordIndexes) { slide.Shapes[2].TextFrame.TextRange.Words(boldIndex).Font.Bold = MsoTriState.msoTrue; } if (textArr.Length <= 1) { slide.Shapes[4].TextFrame.TextRange.Text = " "; } else { boldWordIndexes = GetIndicesOfBold(textArr[1]); slide.Shapes[4].TextFrame.TextRange.Text = textArr[1].Replace("**", ""); foreach (int boldIndex in boldWordIndexes) { slide.Shapes[4].TextFrame.TextRange.Words(boldIndex).Font.Bold = MsoTriState.msoTrue; } } var shapeAddingTo = slide.Shapes[3]; slide.Shapes.AddPicture(info.imageURLs[0], MsoTriState.msoFalse, MsoTriState.msoTrue, shapeAddingTo.Left, shapeAddingTo.Top, shapeAddingTo.Width, shapeAddingTo.Height); shapeAddingTo = slide.Shapes[5]; slide.Shapes.AddPicture(info.imageURLs[1], MsoTriState.msoFalse, MsoTriState.msoTrue, shapeAddingTo.Left, shapeAddingTo.Top, shapeAddingTo.Width, shapeAddingTo.Height); slide.NotesPage.Shapes[2].TextFrame.TextRange.Text = "You may need to manually resize your images!"; break; } i++; } pptPresentation.SaveAs(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/" + slideInfo[0].title + @".pptx", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue); System.Windows.Application.Current.Shutdown(); }
public LibraryFileSlides(LibraryFileResultInfo fileInfo, SlideInfoCollection slides) { FileInfo = fileInfo; Slides = slides; }
public LibraryFileSlides() { Slides = new SlideInfoCollection(); }