Exemple #1
0
        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);
        }
Exemple #2
0
        /// <summary>
        /// Reorganises the positions of all the text boxes in the beam.
        /// </summary>
        private static void ReorganiseBeam(PowerPointSlide refSlide, List <AgendaSection> newSections, Shape highlightedTextBox,
                                           Shape background, BeamFormats beamFormats, List <Shape> oldTextBoxes, Shape beamShape)
        {
            var newTextBoxes = CreateBeamAgendaTextBoxes(refSlide, newSections);

            SetupBeamTextBoxPositions(newTextBoxes, highlightedTextBox, background);

            for (int i = 0; i < newTextBoxes.Count; ++i)
            {
                var referenceTextFormat = beamFormats.Regular;
                if (i < oldTextBoxes.Count)
                {
                    referenceTextFormat = oldTextBoxes[i].TextFrame2.TextRange;
                }

                Graphics.SyncTextRange(referenceTextFormat, newTextBoxes[i].TextFrame2.TextRange, pickupTextContent: false);
            }

            oldTextBoxes.ForEach(shape => shape.Delete());

            var beamShapeShapes = beamShape.Ungroup().Cast <Shape>().ToList();

            beamShapeShapes.AddRange(newTextBoxes);
            beamShape = refSlide.GroupShapes(beamShapeShapes);
            AgendaShape.SetShapeName(beamShape, ShapePurpose.BeamShapeMainGroup, AgendaSection.None);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        private static void UpdateBeamOnSlide(PowerPointSlide slide, Shape refBeamShape)
        {
            RemoveBeamAgendaFromSlide(slide);
            refBeamShape.Copy();
            var beamShape = slide.Shapes.Paste();
            var section   = GetSlideSection(slide);

            beamShape.GroupItems.Cast <Shape>()
            .Where(AgendaShape.WithPurpose(ShapePurpose.BeamShapeHighlightedText))
            .ToList()
            .ForEach(shape => shape.Delete());

            if (section.Index == 1)
            {
                return;
            }

            var beamFormats           = BeamFormats.ExtractFormats(refBeamShape);
            var currentSectionTextBox = beamShape.GroupItems
                                        .Cast <Shape>()
                                        .Where(AgendaShape.MeetsConditions(shape => shape.ShapePurpose == ShapePurpose.BeamShapeText &&
                                                                           shape.Section.Index == section.Index))
                                        .FirstOrDefault();
            var currentSectionText = currentSectionTextBox.TextFrame2.TextRange;

            Graphics.SyncTextRange(beamFormats.Highlighted, currentSectionText, pickupTextContent: false);
        }
Exemple #5
0
        private static Shape PrepareBeamAgendaBackground(PowerPointSlide slide)
        {
            var background = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 0, 0, 0, 0);

            AgendaShape.SetShapeName(background, ShapePurpose.BeamShapeBackground, AgendaSection.None);
            background.Line.Visible       = MsoTriState.msoFalse;
            background.Fill.ForeColor.RGB = Graphics.ConvertColorToRgb(Color.Black);
            background.Width = PowerPointPresentation.Current.SlideWidth;

            return(background);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        private static Shape CreateHighlightedTextBox(PowerPointSlide slide)
        {
            var textBox = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal,
                                                  0, 0, 0, 0);

            AgendaShape.SetShapeName(textBox, ShapePurpose.BeamShapeHighlightedText, AgendaSection.None);
            textBox.TextFrame.AutoSize                 = PpAutoSize.ppAutoSizeShapeToFitText;
            textBox.TextFrame.WordWrap                 = MsoTriState.msoFalse;
            textBox.TextFrame.TextRange.Text           = TextCollection.AgendaLabBeamHighlightedText;
            textBox.TextFrame.TextRange.Font.Color.RGB = Graphics.ConvertColorToRgb(Color.Yellow);

            return(textBox);
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        /// <summary>
        /// Does not reogranise the positions of the text boxes in the beam. Instead, it only deletes text boxes
        /// that no longer correspond to a section, and creates new text boxes for the new sections.
        /// </summary>
        private static void UpdateBeamItems(PowerPointSlide refSlide, List <AgendaSection> newSections, Shape highlightedTextBox,
                                            Shape background, BeamFormats beamFormats, List <Shape> oldTextBoxes, Shape beamShape)
        {
            List <Shape> markedForDeletion;
            var          textboxAssignment = GetBeamTextboxAssignment(oldTextBoxes, out markedForDeletion);

            var reassignedTextboxIndexes = new HashSet <int>();
            var newTextboxes             = new List <Shape>();

            foreach (var section in newSections)
            {
                int index = section.Index;
                if (textboxAssignment.ContainsKey(index))
                {
                    // Reuse old textbox
                    var textbox = textboxAssignment[index];
                    Graphics.SetText(textbox, section.Name);
                    AgendaShape.SetShapeName(textbox, ShapePurpose.BeamShapeText, section);
                    reassignedTextboxIndexes.Add(index);
                }
                else
                {
                    // Create new textbox
                    var textbox             = PrepareBeamAgendaBeamItem(refSlide, section);
                    var referenceTextFormat = beamFormats.Regular;
                    Graphics.SyncTextRange(referenceTextFormat, textbox.TextFrame2.TextRange, pickupTextContent: false);
                    newTextboxes.Add(textbox);
                }
            }

            markedForDeletion.AddRange(from entry in textboxAssignment where !reassignedTextboxIndexes.Contains(entry.Key) select entry.Value);
            markedForDeletion.ForEach(shape => shape.Delete());

            var beamShapeShapes = beamShape.Ungroup().Cast <Shape>().ToList();

            beamShapeShapes.AddRange(newTextboxes);
            beamShape = refSlide.GroupShapes(beamShapeShapes);
            AgendaShape.SetShapeName(beamShape, ShapePurpose.BeamShapeMainGroup, AgendaSection.None);
        }