/// <summary> /// Assumes that there is no reference slide. /// Takes in a slide, and sets it as the reference slide of the agenda. /// </summary> private static void SetAsReferenceSlide(PowerPointSlide refSlide, Type type) { AgendaSlide.SetAsReferenceSlideName(refSlide, type); refSlide.Hidden = true; refSlide.AddTemplateSlideMarker(); refSlide.MoveTo(1); }
private static PowerPointSlide CreateBulletReferenceSlide() { var refSlide = PowerPointSlide.FromSlideFactory(PowerPointPresentation.Current .Presentation .Slides .Add(1, PpSlideLayout.ppLayoutText)); refSlide.Transition.EntryEffect = PpEntryEffect.ppEffectPushUp; refSlide.Transition.Duration = 0.8f; var titleShape = refSlide.Shapes.Placeholders[1]; var contentShape = refSlide.Shapes.Placeholders[2]; AgendaShape.SetShapeName(contentShape, ShapePurpose.ContentShape, AgendaSection.None); Graphics.SetText(titleShape, TextCollection.AgendaLabTitleContent); Graphics.SetText(contentShape, TextCollection.AgendaLabBulletVisitedContent, TextCollection.AgendaLabBulletHighlightedContent, TextCollection.AgendaLabBulletUnvisitedContent); var paragraphs = Graphics.GetParagraphs(contentShape); paragraphs[0].Font.Fill.ForeColor.RGB = Graphics.ConvertColorToRgb(Color.Gray); paragraphs[1].Font.Fill.ForeColor.RGB = Graphics.ConvertColorToRgb(Color.Red); paragraphs[2].Font.Fill.ForeColor.RGB = Graphics.ConvertColorToRgb(Color.Black); AgendaSlide.SetAsReferenceSlideName(refSlide, Type.Bullet); refSlide.AddTemplateSlideMarker(); refSlide.Hidden = true; return(refSlide); }
private static void MatchTemplateTableWithSlides(AgendaTemplate template, List <PowerPointSlide> sectionSlides, TemplateIndexTable templateTable, List <int> assignmentList, AgendaSection currentSection) { for (int i = 0; i < template.FrontSlidesCount; ++i) { SlidePurpose purpose = template.FrontSlides[i].SlidePurpose; for (int j = 0; j < assignmentList.Count; ++j) { if (!AgendaSlide.MatchesPurpose(sectionSlides[j], purpose)) { continue; } templateTable.FrontIndexes[i] = j; AgendaSlide.SetSlideName(sectionSlides[j], template.Type, purpose, currentSection); assignmentList[j] = TemplateIndexTable.Reserved; break; } } for (int i = 0; i < template.BackSlidesCount; ++i) { SlidePurpose purpose = template.BackSlides[i].SlidePurpose; for (int j = 0; j < assignmentList.Count; ++j) { if (!AgendaSlide.MatchesPurpose(sectionSlides[j], purpose)) { continue; } templateTable.BackIndexes[i] = j; AgendaSlide.SetSlideName(sectionSlides[j], template.Type, purpose, currentSection); assignmentList[j] = TemplateIndexTable.Reserved; break; } } }
/// <summary> /// Scrambles the slide section names to avoid duplicate names later on, which can crash powerpoint. /// Use this just before reassigning the slide section names! Don't keep the slide names this way! /// </summary> private static void ScrambleSlideSectionNames() { var slides = PowerPointPresentation.Current.Slides; slides.Where(slide => AgendaSlide.IsAnyAgendaSlide(slide) && AgendaSlide.IsNotReferenceslide(slide)) .ToList() .ForEach(AgendaSlide.AssignUniqueSectionName); }
/// <summary> /// Rebuilds the slides in the section to match the slides indicated by the template. /// Names the agenda slides properly. /// Assumption: Reference slide is the first slide. /// </summary> private static TemplateIndexTable RebuildSectionUsingTemplate(SlideSelectionTracker slideTracker, AgendaSection currentSection, AgendaTemplate template) { if (template.NotConfigured) { throw new ArgumentException("Template is not configured yet."); } // Step 1: Generate Assignment List and fill in Template Table. TemplateIndexTable templateTable = template.CreateIndexTable(); List <PowerPointSlide> sectionSlides = GetSectionSlides(currentSection); if (AgendaSlide.IsReferenceslide(sectionSlides[0])) { sectionSlides.RemoveAt(0); } int addToIndex = SectionLastSlideIndex(currentSection) + 1; List <int> assignmentList = new List <int>(); for (int i = 0; i < sectionSlides.Count; ++i) { assignmentList.Add(-1); } // Step 1a: Filling in Template Table MatchTemplateTableWithSlides(template, sectionSlides, templateTable, assignmentList, currentSection); // Step 1b: Generating Assignment List int indexOfFirstBackSlide; GenerateInitialAssignmentList(out indexOfFirstBackSlide, template, templateTable, assignmentList, sectionSlides); // Step 2: Add all missing slides. List <PowerPointSlide> createdSlides = AddAllMissingSlides(ref addToIndex, template, templateTable, assignmentList, currentSection, indexOfFirstBackSlide); sectionSlides.AddRange(createdSlides); templateTable.StoreSlideObjects(sectionSlides); // Step 3: Create Goal Array of Slide Objects and MarkedForDeletion list. List <PowerPointSlide> markedForDeletion; int newSlideCount = indexOfFirstBackSlide + template.BackSlidesCount; PowerPointSlide[] goalArray = GenerateGoalArray(newSlideCount, assignmentList, sectionSlides, out markedForDeletion); // Step 4: Use goal array to reorder all goal slides. foreach (PowerPointSlide slide in goalArray) { slide.MoveTo(addToIndex - 1); } // Step 5: Delete all slides marked for deletion. markedForDeletion.ForEach(slideTracker.DeleteSlideAndTrack); return(templateTable); }
private static void DeleteAllZoomSlides(SlideSelectionTracker slideTracker) { PowerPointPresentation.Current.Slides .Where(AgendaSlide.MeetsConditions(slide => slide.SlidePurpose == SlidePurpose.ZoomIn || slide.SlidePurpose == SlidePurpose.ZoomOut || slide.SlidePurpose == SlidePurpose.FinalZoomOut)) .ToList() .ForEach(slideTracker.DeleteSlideAndTrack); }
private static Type GetReferenceSlideType() { var referenceSlide = FindReferenceSlide(); if (referenceSlide == null) { return(Type.None); } return(AgendaSlide.Decode(referenceSlide).AgendaType); }
/// <summary> /// Create the zoom in (drill down) effect in visual agenda. The zoom in slide is not part of the template. /// </summary> private static void GenerateVisualAgendaSlideZoomIn(PowerPointSlide slide, Shape zoomInShape) { PowerPointDrillDownSlide addedSlide; AutoZoom.AddDrillDownAnimation(zoomInShape, slide, out addedSlide, includeAckSlide: false, deletePreviouslyAdded: false); slide.GetShapesWithRule(new Regex("PPTZoomIn"))[0].Delete(); AgendaSection section = AgendaSlide.Decode(slide).Section; AgendaSlide.SetSlideName(addedSlide, Type.Visual, SlidePurpose.ZoomIn, section); zoomInShape.Visible = MsoTriState.msoTrue; }
public static bool MatchesPurpose(PowerPointSlide slide, SlidePurpose purpose) { AgendaSlide agendaSlide = Decode(slide); if (agendaSlide == null) { return(false); } return(agendaSlide.SlidePurpose == purpose); }
public static bool IsReferenceslide(Slide slide) { AgendaSlide agendaSlide = Decode(slide); if (agendaSlide == null) { return(false); } return(agendaSlide.SlidePurpose == SlidePurpose.Reference); }
/// <summary> /// Same as MeetConditions, but returns a function from Slide to bool instead. /// </summary> /// <param name="condition">Input a condition on (AgendaSlide : bool)</param> /// <returns>Output a condition on (Slide : bool).</returns> public static Func <Slide, bool> MeetsConditions2(Predicate <AgendaSlide> condition) { return(slide => { AgendaSlide agendaSlide = Decode(slide); if (agendaSlide == null) { return false; } return condition(agendaSlide); }); }
/// <summary> /// Identifies the previous section index of a section by looking at the generated agenda slides in the section. /// The identified section is the section index of the first generated agenda slide found. /// Returns -1 when old section index is not found. /// </summary> private static int IdentifyOldSectionIndex(AgendaSection section) { var sectionSlides = GetSectionSlides(section); foreach (var slide in sectionSlides) { var agendaSlide = AgendaSlide.Decode(slide); if (agendaSlide != null) { return(agendaSlide.Section.Index); } } return(-1); }
/// <summary> /// Checks whether there is a section with no slides. /// Agenda slides are not counted. /// </summary> private static bool HasEmptySection() { var sections = Sections; foreach (var section in sections) { var sectionSlides = GetSectionSlides(section); if (sectionSlides.All(slide => AgendaSlide.IsAnyAgendaSlide(slide) || PowerPointAckSlide.IsAckSlide(slide))) { return(true); } } return(false); }
private static PowerPointSlide CreateBeamReferenceSlide() { var refSlide = PowerPointSlide.FromSlideFactory(PowerPointPresentation.Current .Presentation .Slides .Add(1, PpSlideLayout.ppLayoutBlank)); CreateBeamAgendaShapes(refSlide); AgendaSlide.SetAsReferenceSlideName(refSlide, Type.Beam); refSlide.AddTemplateSlideMarker(); refSlide.Hidden = true; return(refSlide); }
private static Type GetAnyAgendaSlideType() { var agendaSlide = PowerPointPresentation.Current .Slides .FirstOrDefault(slide => AgendaSlide.IsAnyAgendaSlide(slide) || HasBeamShape(slide)); if (agendaSlide == null) { return(Type.None); } if (HasBeamShape(agendaSlide)) { return(Type.Beam); } return(AgendaSlide.Decode(agendaSlide).AgendaType); }
/// <summary> /// Create the zoom out (step back) effect in visual agenda. The zoom out slide is not part of the template. /// </summary> private static void GenerateVisualAgendaSlideZoomOut(PowerPointSlide slide, Shape zoomOutShape, bool finalZoomOut = false) { PowerPointStepBackSlide addedSlide; AutoZoom.AddStepBackAnimation(zoomOutShape, slide, out addedSlide, includeAckSlide: false, deletePreviouslyAdded: false); slide.GetShapesWithRule(new Regex("PPTZoomOut"))[0].Delete(); AgendaSection section = AgendaSlide.Decode(slide).Section; AgendaSlide.SetSlideName(addedSlide, Type.Visual, finalZoomOut ? SlidePurpose.FinalZoomOut : SlidePurpose.ZoomOut, section); zoomOutShape.Visible = MsoTriState.msoTrue; var index = slide.Index; // move the step back slide to the first slide of the section PowerPointPresentation.Current.Presentation.Slides[index - 1].MoveTo(index); slide.MoveTo(index); }
private static PowerPointSlide FindSectionLastNonAgendaSlide(int sectionIndex) { var presentation = PowerPointPresentation.Current; int currentIndex = SectionLastSlideIndex(sectionIndex); var slide = presentation.GetSlide(currentIndex); while (AgendaSlide.IsAnyAgendaSlide(slide)) { currentIndex--; if (currentIndex <= 0) { return(null); } slide = presentation.GetSlide(currentIndex); } return(slide); }
private static PowerPointSlide CreateVisualReferenceSlide() { var refSlide = PowerPointSlide.FromSlideFactory(PowerPointPresentation.Current .Presentation .Slides .Add(1, PpSlideLayout.ppLayoutTitleOnly)); var titleBar = refSlide.Shapes.Placeholders[1]; Graphics.SetText(titleBar, TextCollection.AgendaLabTitleContent); InsertVisualAgendaSectionImages(refSlide); AgendaSlide.SetAsReferenceSlideName(refSlide, Type.Visual); refSlide.AddTemplateSlideMarker(); refSlide.Hidden = true; return(refSlide); }
private static PowerPointSlide FindSectionFirstNonAgendaSlide(int sectionIndex) { PowerPointPresentation presentation = PowerPointPresentation.Current; int slideCount = presentation.SlideCount; int currentIndex = SectionFirstSlideIndex(sectionIndex); PowerPointSlide slide = presentation.GetSlide(currentIndex); while (AgendaSlide.IsAnyAgendaSlide(slide)) { currentIndex++; if (currentIndex > slideCount) { return(null); } slide = presentation.GetSlide(currentIndex); } return(slide); }
/// <summary> /// Returns a list of the newly added slides. /// Updates assignmentList (by appending) /// Gives placeholder agendaslide name to the created slides. /// </summary> private static List <PowerPointSlide> AddAllMissingSlides(ref int addToIndex, AgendaTemplate template, TemplateIndexTable templateTable, List <int> assignmentList, AgendaSection currentSection, int indexOfFirstBackSlide) { List <PowerPointSlide> createdSlides = new List <PowerPointSlide>(); for (int i = 0; i < template.FrontSlidesCount; ++i) { if (templateTable.FrontIndexes[i] == TemplateIndexTable.NoSlide) { PowerPointSlide newSlide = AddBlankSlide(addToIndex); createdSlides.Add(newSlide); AgendaSlide.SetSlideName(newSlide, template.Type, template.FrontSlides[i].SlidePurpose, currentSection); templateTable.IsNewlyGeneratedFront[i] = true; templateTable.FrontIndexes[i] = assignmentList.Count; assignmentList.Add(i); addToIndex++; } } for (int i = 0; i < template.BackSlidesCount; ++i) { if (templateTable.BackIndexes[i] == TemplateIndexTable.NoSlide) { PowerPointSlide newSlide = AddBlankSlide(addToIndex); createdSlides.Add(newSlide); AgendaSlide.SetSlideName(newSlide, template.Type, template.BackSlides[i].SlidePurpose, currentSection); templateTable.IsNewlyGeneratedBack[i] = true; templateTable.BackIndexes[i] = assignmentList.Count; assignmentList.Add(indexOfFirstBackSlide + i); addToIndex++; } } return(createdSlides); }
/// <summary> /// The assignment list indicates the new position of each of the previous slides. /// assignmentList[oldSlideIndex] = newSlideIndex /// /// if newSlideIndex is equal to TemplateIndexTable.NoSlide, it means the slide is marked for deletion. /// /// All slideIndexes are relative to the index of the first slide in the section. first slide is index 0. /// </summary> private static void GenerateInitialAssignmentList(out int indexOfFirstBackSlide, AgendaTemplate template, TemplateIndexTable templateTable, List <int> assignmentList, List <PowerPointSlide> sectionSlides) { for (int i = 0; i < template.FrontSlidesCount; ++i) { int chosenSlide = templateTable.FrontIndexes[i]; if (chosenSlide == -1) { continue; } assignmentList[chosenSlide] = i; } int currentIndex = template.FrontSlidesCount; for (int i = 0; i < assignmentList.Count; ++i) { if (assignmentList[i] == TemplateIndexTable.NoSlide) { if (!AgendaSlide.IsAnyAgendaSlide(sectionSlides[i])) { assignmentList[i] = currentIndex; currentIndex++; } } } indexOfFirstBackSlide = currentIndex; for (int i = 0; i < template.BackSlidesCount; ++i) { int chosenSlide = templateTable.BackIndexes[i]; if (chosenSlide == -1) { continue; } assignmentList[chosenSlide] = indexOfFirstBackSlide + i; } }
private static void SyncBeamOnSlides(List <PowerPointSlide> targetSlides, PowerPointSlide refSlide) { var syncSlides = new List <PowerPointSlide>(); // Generate beam agenda for all target slides that do not currently have the beam agenda. if (targetSlides != null) { var selectedSlidesWithoutBeam = targetSlides.Where(slide => !HasBeamShape(slide)); syncSlides.AddRange(selectedSlidesWithoutBeam); } // Synchronise agenda for all slides in the presentation that have the beam agenda. var refBeamShape = FindBeamShape(refSlide); var allSlidesWithBeam = PowerPointPresentation.Current.Slides .Where(slide => AgendaSlide.IsNotReferenceslide(slide) && FindBeamShape(slide) != null); syncSlides.AddRange(allSlidesWithBeam); foreach (var slide in syncSlides) { UpdateBeamOnSlide(slide, refBeamShape); } }
/// <summary> /// Assigns the slide's section to None, which is encoded as an arbitrary string of numbers that is guaranteed to be unique. /// Used to prevent duplicate slide names, which crashes powerpoint. /// </summary> public static void AssignUniqueSectionName(PowerPointSlide slide) { AgendaSlide properties = Decode(slide); slide.Name = Encode(properties.AgendaType, properties.SlidePurpose, AgendaSection.None); }