コード例 #1
1
        /// <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);
        }
コード例 #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);
        }
コード例 #3
0
        private static bool InvalidBeamAgendaReferenceSlide(PowerPointSlide refSlide)
        {
            var beamShape = FindBeamShape(refSlide);

            if (beamShape == null)
            {
                return(true);
            }
            try
            {
                if (BeamFormats.GetShapeWithPurpose(beamShape, ShapePurpose.BeamShapeHighlightedText) == null)
                {
                    return(true);
                }
                if (BeamFormats.GetShapeWithPurpose(beamShape, ShapePurpose.BeamShapeText) == null)
                {
                    return(true);
                }
            }
            catch (COMException)
            {
                // beam shape is not a group
                return(true);
            }
            return(false);
        }
コード例 #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);
        }
コード例 #5
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);
        }
コード例 #6
0
        private static void UpdateBeamReferenceSlide(PowerPointSlide refSlide)
        {
            var beamShape       = FindBeamShape(refSlide);
            var currentSections = ExtractAgendaSectionsFromBeam(beamShape);
            var newSections     = GetAllButFirstSection();

            var beamFormats        = BeamFormats.ExtractFormats(beamShape);
            var oldTextBoxes       = BeamFormats.GetAllShapesWithPurpose(beamShape, ShapePurpose.BeamShapeText);
            var highlightedTextBox = BeamFormats.GetShapeWithPurpose(beamShape, ShapePurpose.BeamShapeHighlightedText);
            var background         = BeamFormats.GetShapeWithPurpose(beamShape, ShapePurpose.BeamShapeBackground);

            MatchColour(highlightedTextBox, background);

            if (SectionsMatch(currentSections, newSections))
            {
                return;
            }


            var confirmResult = MessageBox.Show(new Form()
            {
                TopMost = true
            },
                                                TextCollection.AgendaLabReorganiseSidebarContent,
                                                TextCollection.AgendaLabReorganiseSidebarTitle,
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                ReorganiseBeam(refSlide, newSections, highlightedTextBox, background, beamFormats, oldTextBoxes, beamShape);
            }
            else
            {
                UpdateBeamItems(refSlide, newSections, highlightedTextBox, background, beamFormats, oldTextBoxes, beamShape);
            }
        }
コード例 #7
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);
        }