private static void UpdateSectionImage(PowerPointSlide refSlide, AgendaSection section, Shape previousImageShape) { var snapshotShape = CreateSectionImage(refSlide, section); Graphics.SyncShape(previousImageShape, snapshotShape, pickupShapeFormat: true, pickupTextContent: false, pickupTextFormat: false); previousImageShape.Delete(); }
/// <summary> /// Universal Encode function used for all Agenda Shapes. /// Unpacks a shape name into a set of shape properties. Paired with the Encode function. /// </summary> public static AgendaShape Decode(string shapeName) { string[] parameters = shapeName.Split(Delim, StringSplitOptions.None); if (parameters.Length != 3) { return(null); } if (parameters[0] != Prefix) { return(null); } ShapePurpose shapePurpose; if (!Enum.TryParse(parameters[1], out shapePurpose)) { return(null); } AgendaSection section = AgendaSection.Decode(parameters[2]); return(new AgendaShape(shapePurpose, section)); }
/// <summary> /// Universal Encode function used for all Agenda Slides. /// Unpacks a slide name into a set of slide properties. Paired wit hthe Encode function. /// </summary> public static AgendaSlide Decode(string slide) { string[] parameters = slide.Split(Delim, StringSplitOptions.None); if (parameters.Length != 4) { return(null); } if (parameters[0] != Prefix) { return(null); } Type type; SlidePurpose slidePurpose; if (!Enum.TryParse(parameters[1], out type)) { return(null); } if (!Enum.TryParse(parameters[2], out slidePurpose)) { return(null); } AgendaSection section = AgendaSection.Decode(parameters[3]); return(new AgendaSlide(type, slidePurpose, section)); }
private static Shape CreateSectionImage(PowerPointSlide refSlide, AgendaSection section) { var sectionFirstSlide = FindSectionFirstNonAgendaSlide(section.Index); var shape = refSlide.InsertEntrySnapshotOfSlide(sectionFirstSlide); AgendaShape.SetShapeName(shape, ShapePurpose.VisualAgendaImage, section); return(shape); }
private static void ConfigureTemplate(AgendaSection section, AgendaTemplate template) { if (section.Index == 1) template.ConfigHead(); else if (section.Index == NumberOfSections) template.ConfigEnd(); else template.ConfigMiddle(); }
/// <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; }
private static Shape PrepareBeamAgendaBeamItem(PowerPointSlide slide, AgendaSection section) { var textBox = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0); AgendaShape.SetShapeName(textBox, ShapePurpose.BeamShapeText, section); textBox.TextFrame.AutoSize = PpAutoSize.ppAutoSizeShapeToFitText; textBox.TextFrame.WordWrap = MsoTriState.msoFalse; textBox.TextFrame.TextRange.Text = section.Name; textBox.TextFrame.TextRange.Font.Color.RGB = Graphics.ConvertColorToRgb(Color.White); return(textBox); }
/// <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> /// 0-indexed. /// </summary> private static List <PowerPointSlide> GetSectionSlides(AgendaSection section) { var slides = PowerPointPresentation.Current.Slides; int firstSlideIndex = SectionFirstSlideIndex(section); int lastSlideIndex = SectionLastSlideIndex(section); if (firstSlideIndex == -1 || lastSlideIndex == -1) { return(new List <PowerPointSlide>()); } return(slides.GetRange(firstSlideIndex - 1, lastSlideIndex - firstSlideIndex + 1)); }
private static void ConfigureTemplate(AgendaSection section, AgendaTemplate template) { if (section.Index == 1) { template.ConfigHead(); } else if (section.Index == NumberOfSections) { template.ConfigEnd(); } else { template.ConfigMiddle(); } }
private static void SyncBulletAgendaSlide(PowerPointSlide refSlide, List <AgendaSection> sections, AgendaSection currentSection, List <string> deletedShapeNames, PowerPointSlide targetSlide) { SyncShapesFromReferenceSlide(refSlide, targetSlide, deletedShapeNames); var referenceContentShape = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var targetContentShape = targetSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var bulletFormats = BulletFormats.ExtractFormats(referenceContentShape); Graphics.SetText(targetContentShape, sections.Where(section => section.Index > 1) .Select(section => section.Name)); Graphics.SyncShape(referenceContentShape, targetContentShape, pickupTextContent: false, pickupTextFormat: false); ApplyBulletFormats(targetContentShape.TextFrame2.TextRange, bulletFormats, currentSection); targetSlide.DeletePlaceholderShapes(); }
private static void SyncBulletAgendaSlide(PowerPointSlide refSlide, List<AgendaSection> sections, AgendaSection currentSection, List<string> deletedShapeNames, PowerPointSlide targetSlide) { SyncShapesFromReferenceSlide(refSlide, targetSlide, deletedShapeNames); var referenceContentShape = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var targetContentShape = targetSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var bulletFormats = BulletFormats.ExtractFormats(referenceContentShape); Graphics.SetText(targetContentShape, sections.Where(section => section.Index > 1) .Select(section => section.Name)); Graphics.SyncShape(referenceContentShape, targetContentShape, pickupTextContent: false, pickupTextFormat: false); ApplyBulletFormats(targetContentShape.TextFrame2.TextRange, bulletFormats, currentSection); targetSlide.DeletePlaceholderShapes(); }
/// <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); }
/// <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. var templateTable = template.CreateIndexTable(); var sectionSlides = GetSectionSlides(currentSection); if (AgendaSlide.IsReferenceslide(sectionSlides[0])) sectionSlides.RemoveAt(0); var addToIndex = SectionLastSlideIndex(currentSection) + 1; var assignmentList = new List<int>(); for (var 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. var 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; var goalArray = GenerateGoalArray(newSlideCount, assignmentList, sectionSlides, out markedForDeletion); // Step 4: Use goal array to reorder all goal slides. foreach (var slide in goalArray) { slide.MoveTo(addToIndex-1); } // Step 5: Delete all slides marked for deletion. markedForDeletion.ForEach(slideTracker.DeleteSlideAndTrack); return templateTable; }
/// <summary> /// Stores metadata in the slide by setting its name. /// </summary> public static void SetSlideName(PowerPointSlide slide, Type agendaType, SlidePurpose slidePurpose, AgendaSection section) { slide.Name = Encode(agendaType, slidePurpose, section); }
/// <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) { var createdSlides = new List<PowerPointSlide>(); for (int i = 0; i < template.FrontSlidesCount; ++i) { if (templateTable.FrontIndexes[i] == TemplateIndexTable.NoSlide) { var 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) { var 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; }
private static void SynchroniseAllSlides(AgendaTemplate template, TemplateIndexTable templateTable, PowerPointSlide refSlide, List <AgendaSection> sections, List <string> deletedShapeNames, AgendaSection currentSection) { if (template.NotConfigured) { throw new ArgumentException("Template is not configured yet."); } for (int i = 0; i < template.FrontSlidesCount; ++i) { template.FrontSlides[i].SyncFunction(refSlide, sections, currentSection, deletedShapeNames, templateTable.IsNewlyGeneratedFront[i], templateTable.FrontSlideObjects[i]); } for (int i = 0; i < template.BackSlidesCount; ++i) { template.BackSlides[i].SyncFunction(refSlide, sections, currentSection, deletedShapeNames, templateTable.IsNewlyGeneratedBack[i], templateTable.BackSlideObjects[i]); } }
/// <summary> /// 1-indexed /// </summary> private static int SectionLastSlideIndex(AgendaSection section) { return(SectionLastSlideIndex(section.Index)); }
/// <summary> /// Universal Encode function used for all Agenda Shapes. /// Packs a set of agenda shape properties to a shape name. Paired with the Decode function. /// </summary> public static string Encode(ShapePurpose shapePurpose, AgendaSection section) { string[] parameters = { Prefix, shapePurpose.ToString(), section.Encode() }; return(string.Join(Delim[0], parameters)); }
/// <summary> /// Stores metadata in the shape by setting its name. /// </summary> public static void SetShapeName(Shape shape, ShapePurpose shapePurpose, AgendaSection section) { shape.Name = Encode(shapePurpose, section); }
private AgendaShape(ShapePurpose shapePurpose, AgendaSection section) { ShapePurpose = shapePurpose; Section = section; }
private static Shape PrepareBeamAgendaBeamItem(PowerPointSlide slide, AgendaSection section) { var textBox = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0); AgendaShape.SetShapeName(textBox, ShapePurpose.BeamShapeText, section); textBox.TextFrame.AutoSize = PpAutoSize.ppAutoSizeShapeToFitText; textBox.TextFrame.WordWrap = MsoTriState.msoFalse; textBox.TextFrame.TextRange.Text = section.Name; textBox.TextFrame.TextRange.Font.Color.RGB = Graphics.ConvertColorToRgb(Color.White); return textBox; }
/// <summary> /// 0-indexed. /// </summary> private static List<PowerPointSlide> GetSectionSlides(AgendaSection section) { var slides = PowerPointPresentation.Current.Slides; int firstSlideIndex = SectionFirstSlideIndex(section); int lastSlideIndex = SectionLastSlideIndex(section); if (firstSlideIndex == -1 || lastSlideIndex == -1) return new List<PowerPointSlide>(); return slides.GetRange(firstSlideIndex - 1, lastSlideIndex - firstSlideIndex + 1); }
/// <summary> /// 1-indexed /// </summary> private static int SectionLastSlideIndex(AgendaSection section) { return SectionLastSlideIndex(section.Index); }
private static Shape CreateSectionImage(PowerPointSlide refSlide, AgendaSection section) { var sectionFirstSlide = FindSectionFirstNonAgendaSlide(section.Index); var shape = refSlide.InsertEntrySnapshotOfSlide(sectionFirstSlide); AgendaShape.SetShapeName(shape, ShapePurpose.VisualAgendaImage, section); return shape; }
private static void SynchroniseAllSlides(AgendaTemplate template, TemplateIndexTable templateTable, PowerPointSlide refSlide, List<AgendaSection> sections, List<string> deletedShapeNames, AgendaSection currentSection) { if (template.NotConfigured) throw new ArgumentException("Template is not configured yet."); for (int i = 0; i < template.FrontSlidesCount; ++i) { template.FrontSlides[i].SyncFunction(refSlide, sections, currentSection, deletedShapeNames, templateTable.IsNewlyGeneratedFront[i], templateTable.FrontSlideObjects[i]); } for (int i = 0; i < template.BackSlidesCount; ++i) { template.BackSlides[i].SyncFunction(refSlide, sections, currentSection, deletedShapeNames, templateTable.IsNewlyGeneratedBack[i], templateTable.BackSlideObjects[i]); } }
private static void MatchTemplateTableWithSlides(AgendaTemplate template, List<PowerPointSlide> sectionSlides, TemplateIndexTable templateTable, List<int> assignmentList, AgendaSection currentSection) { for (int i = 0; i < template.FrontSlidesCount; ++i) { var 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) { var 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; } } }
private AgendaSlide(Type type, SlidePurpose slidePurpose, AgendaSection section) { AgendaType = type; SlidePurpose = slidePurpose; Section = section; }
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> /// Universal Encode function used for all Agenda Shapes. /// Packs a set of agenda shape properties to a shape name. Paired with the Decode function. /// </summary> public static string Encode(ShapePurpose shapePurpose, AgendaSection section) { string[] parameters = { Prefix, shapePurpose.ToString(), section.Encode() }; return string.Join(Delim[0], parameters); }
/// <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); }
/// <summary> /// Universal Encode function used for all Agenda Slides. /// Packs a set of agenda slide properties to a slide name. Paired with the Decode function. /// </summary> public static string Encode(Type agendaType, SlidePurpose slidePurpose, AgendaSection section) { string[] parameters = { Prefix, agendaType.ToString(), slidePurpose.ToString(), section.Encode() }; return(string.Join(Delim[0], parameters)); }
/// <summary> /// Applies font highlighting by section to the text in the bullet agenda. /// Set currentSection to the first section for everything to be unvisited. /// Set currentSection to AgendaSection.None for everything to be visited. /// </summary> private static void ApplyBulletFormats(TextRange2 textRange, BulletFormats bulletFormats, AgendaSection currentSection) { // - 1 because first section in agenda is at index 2 (exclude first section) int focusIndex = currentSection.IsNone() ? int.MaxValue : currentSection.Index - 1; textRange.Font.StrikeThrough = MsoTriState.msoFalse; for (var i = 1; i <= textRange.Paragraphs.Count; i++) { var currentParagraph = textRange.Paragraphs[i]; if (i == focusIndex) { Graphics.SyncTextRange(bulletFormats.Highlighted, currentParagraph, pickupTextContent: false); } else if (i < focusIndex) { Graphics.SyncTextRange(bulletFormats.Visited, currentParagraph, pickupTextContent: false); } else { Graphics.SyncTextRange(bulletFormats.Unvisited, currentParagraph, pickupTextContent: false); } } }
/// <summary> /// Universal Encode function used for all Agenda Slides. /// Packs a set of agenda slide properties to a slide name. Paired with the Decode function. /// </summary> public static string Encode(Type agendaType, SlidePurpose slidePurpose, AgendaSection section) { string[] parameters = { Prefix, agendaType.ToString(), slidePurpose.ToString(), section.Encode() }; return string.Join(Delim[0], parameters); }
/// <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> /// 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); }