Exemple #1
0
        public static void RemoveAgenda()
        {
            var currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var oldViewType   = currentWindow.ViewType;

            try
            {
                var slideTracker = new SlideSelectionTracker(SelectedSlides, CurrentSlide);

                if (!AgendaPresent())
                {
                    ShowErrorMessage(TextCollection.AgendaLabNoAgendaError);
                    return;
                }

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                currentWindow.ViewType = PpViewType.ppViewNormal;

                RemoveAllAgendaItems(slideTracker);

                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                currentWindow.ViewType = oldViewType;
            }
        }
Exemple #2
0
        /// <summary>
        /// Assumption: no reference slide exists
        /// </summary>
        private static void CreateBeamAgenda(SlideSelectionTracker slideTracker)
        {
            var refSlide = CreateBeamReferenceSlide();

            var targetSlides = slideTracker.SelectedSlides;

            if (targetSlides.Count == 0)
            {
                // If no slides selected, generate on all slides.
                targetSlides = AllSlidesAfterFirstSection();
            }
            else if (targetSlides.Count == 1)
            {
                // If only one slide selected, ask whether the user wants to generate on all slides.
                var confirmResult = MessageBox.Show(new Form {
                    TopMost = true
                },
                                                    TextCollection.AgendaLabBeamGenerateSingleSlideDialogContent,
                                                    TextCollection.AgendaLabBeamGenerateSingleSlideDialogTitle,
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    targetSlides = AllSlidesAfterFirstSection();
                }
            }

            // here we invoke sync logic, since it's the same behavior as sync
            SyncBeamOnSlides(targetSlides, refSlide);
        }
Exemple #3
0
        /// <summary>
        /// Assumption: no reference slide exists
        /// </summary>
        private static void CreateVisualAgenda(SlideSelectionTracker slideTracker)
        {
            var refSlide = CreateVisualReferenceSlide();

            // here we invoke sync logic, since it's the same behavior as sync
            SyncVisualAgendaSlides(slideTracker, refSlide);
        }
        /// <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);
        }
Exemple #5
0
 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);
 }
        public static void GenerateAgenda(Type type)
        {
            bool dialogOpen = false;
            var currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var oldViewType = currentWindow.ViewType;

            try
            {
                var slideTracker = new SlideSelectionTracker(SelectedSlides, CurrentSlide);

                if (AgendaPresent())
                {
                    var confirm = MessageBox.Show(TextCollection.AgendaLabAgendaExistError,
                                                  TextCollection.AgendaLabAgendaExistErrorCaption,
                                                  MessageBoxButtons.OKCancel);
                    if (confirm != DialogResult.OK) return;

                    RemoveAllAgendaItems(slideTracker);
                }

                if (!ValidSections()) return;

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                slideTracker.DeleteAcknowledgementSlideAndTrack();

                dialogOpen = DisplayLoadingDialog(TextCollection.AgendaLabGeneratingDialogTitle,
                                                    TextCollection.AgendaLabGeneratingDialogContent);
                currentWindow.ViewType = PpViewType.ppViewNormal;

                switch (type)
                {
                    case Type.Beam:
                        CreateBeamAgenda(slideTracker);
                        break;
                    case Type.Bullet:
                        CreateBulletAgenda(slideTracker);
                        break;
                    case Type.Visual:
                        CreateVisualAgenda(slideTracker);
                        break;
                }

                PowerPointPresentation.Current.AddAckSlide();
                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                if (dialogOpen)
                {
                    DisposeLoadingDialog();
                }
                currentWindow.ViewType = oldViewType;
            }
        }
Exemple #7
0
        private static void RemoveAllAgendaItems(SlideSelectionTracker slideTracker = null)
        {
            if (slideTracker == null)
            {
                slideTracker = SlideSelectionTracker.CreateInactiveTracker();
            }

            PowerPointPresentation.Current.Slides.Where(AgendaSlide.IsAnyAgendaSlide)
            .ToList()
            .ForEach(slideTracker.DeleteSlideAndTrack);

            PowerPointPresentation.Current.Slides.ToList()
            .ForEach(RemoveBeamAgendaFromSlide);
        }
        /// <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;
        }
#pragma warning disable 0618
        #region Main Synchronisation Function
        /// <summary>
        /// Call the function like this for example:
        /// SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new VisualAgendaTemplate());
        /// generateTemplate is a function that returns a newly created template.
        /// </summary>
        private static void SynchroniseSlidesUsingTemplate(SlideSelectionTracker slideTracker, PowerPointSlide refSlide, Func<AgendaTemplate> generateTemplate)
        {
            var sections = Sections;

            var deletedShapeNames = RetrieveTrackedDeletions(refSlide);

            refSlide.DeleteSlideNumberShapes();
            refSlide.MakeShapeNamesNonDefault();
            refSlide.MakeShapeNamesUnique(shape => !AgendaShape.IsAnyAgendaShape(shape) &&
                                                   !PowerPointSlide.IsTemplateSlideMarker(shape));

            ScrambleSlideSectionNames();
            foreach (var currentSection in sections)
            {
                var template = generateTemplate();
                ConfigureTemplate(currentSection, template);

                var templateTable = RebuildSectionUsingTemplate(slideTracker, currentSection, template);
                SynchroniseAllSlides(template, templateTable, refSlide, sections, deletedShapeNames, currentSection);
            }

            TrackShapesInSlide(refSlide);
        }
#pragma warning disable 0618
        #region Main Synchronisation Function
        /// <summary>
        /// Call the function like this for example:
        /// SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new VisualAgendaTemplate());
        /// generateTemplate is a function that returns a newly created template.
        /// </summary>
        private static void SynchroniseSlidesUsingTemplate(SlideSelectionTracker slideTracker, PowerPointSlide refSlide, Func <AgendaTemplate> generateTemplate)
        {
            List <AgendaSection> sections = Sections;

            List <string> deletedShapeNames = RetrieveTrackedDeletions(refSlide);

            refSlide.DeleteSlideNumberShapes();
            refSlide.MakeShapeNamesNonDefault();
            refSlide.MakeShapeNamesUnique(shape => !AgendaShape.IsAnyAgendaShape(shape) &&
                                          !PowerPointSlide.IsTemplateSlideMarker(shape));

            ScrambleSlideSectionNames();
            foreach (AgendaSection currentSection in sections)
            {
                AgendaTemplate template = generateTemplate();
                ConfigureTemplate(currentSection, template);

                TemplateIndexTable templateTable = RebuildSectionUsingTemplate(slideTracker, currentSection, template);
                SynchroniseAllSlides(template, templateTable, refSlide, sections, deletedShapeNames, currentSection);
            }

            TrackShapesInSlide(refSlide);
        }
        public static void RemoveAgenda()
        {
            var currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var oldViewType = currentWindow.ViewType;

            try
            {
                var slideTracker = new SlideSelectionTracker(SelectedSlides, CurrentSlide);

                if (!AgendaPresent())
                {
                    ShowErrorMessage(TextCollection.AgendaLabNoAgendaError);
                    return;
                }

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                currentWindow.ViewType = PpViewType.ppViewNormal;

                RemoveAllAgendaItems(slideTracker);

                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                currentWindow.ViewType = oldViewType;
            }
        }
Exemple #12
0
 /// <summary>
 /// Called from the Synchronise action only.
 /// </summary>
 private static void SyncVisualAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     RegenerateReferenceSlideImages(refSlide);
     SyncVisualAgendaSlides(slideTracker, refSlide);
 }
Exemple #13
0
 /// <summary>
 /// Called from both generate and synchronise actions.
 /// </summary>
 private static void SyncVisualAgendaSlides(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     DeleteAllZoomSlides(slideTracker);
     SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new VisualAgendaTemplate());
 }
Exemple #14
0
 /// <summary>
 /// Called from the Synchronise action only.
 /// </summary>
 private static void SyncBulletAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     AdjustBulletReferenceSlideContent(refSlide);
     SyncBulletAgendaSlides(slideTracker, refSlide);
 }
Exemple #15
0
        /// <summary>
        /// Called from both generate and synchronise actions.
        /// </summary>
        private static void SyncBulletAgendaSlides(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
        {
            var sections = Sections;

            SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new BulletAgendaTemplate());
        }
 /// <summary>
 /// Called from both generate and synchronise actions.
 /// </summary>
 private static void SyncVisualAgendaSlides(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     DeleteAllZoomSlides(slideTracker);
     SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new VisualAgendaTemplate());
 }
        public static void SynchroniseAgenda()
        {
            bool dialogOpen = false;
            var currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var oldViewType = currentWindow.ViewType;

            try
            {
                var slideTracker = new SlideSelectionTracker(SelectedSlides, CurrentSlide);
                var refSlide = FindReferenceSlide();
                var type = GetReferenceSlideType();
                bool usingNewReferenceSlide = false;

                if (refSlide == null)
                {
                    type = GetAnyAgendaSlideType();
                    refSlide = TryFindSuitableRefSlide(type);
                    usingNewReferenceSlide = true;
                }

                if (!ValidAgenda(refSlide, type)) return;
                if (!ValidSections()) return;

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                if (usingNewReferenceSlide)
                {
                    SetAsReferenceSlide(refSlide, type);
                }

                slideTracker.DeleteAcknowledgementSlideAndTrack();
                dialogOpen = DisplayLoadingDialog(TextCollection.AgendaLabSynchronizingDialogTitle,
                                                    TextCollection.AgendaLabSynchronizingDialogContent);
                currentWindow.ViewType = PpViewType.ppViewNormal;

                BringToFront(refSlide);

                switch (type)
                {
                    case Type.Beam:
                        SyncBeamAgenda(slideTracker, refSlide);
                        break;
                    case Type.Bullet:
                        SyncBulletAgenda(slideTracker, refSlide);
                        break;
                    case Type.Visual:
                        SyncVisualAgenda(slideTracker, refSlide);
                        break;
                }

                PowerPointPresentation.Current.AddAckSlide();
                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                if (dialogOpen)
                {
                    DisposeLoadingDialog();
                }
                currentWindow.ViewType = oldViewType;
            }
        }
Exemple #18
0
        public static void SynchroniseAgenda()
        {
            bool dialogOpen    = false;
            var  currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var  oldViewType   = currentWindow.ViewType;

            try
            {
                var  slideTracker           = new SlideSelectionTracker(SelectedSlides, CurrentSlide);
                var  refSlide               = FindReferenceSlide();
                var  type                   = GetReferenceSlideType();
                bool usingNewReferenceSlide = false;

                if (refSlide == null)
                {
                    type     = GetAnyAgendaSlideType();
                    refSlide = TryFindSuitableRefSlide(type);
                    usingNewReferenceSlide = true;
                }

                if (!ValidAgenda(refSlide, type))
                {
                    return;
                }
                if (!ValidSections())
                {
                    return;
                }

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                if (usingNewReferenceSlide)
                {
                    SetAsReferenceSlide(refSlide, type);
                }

                slideTracker.DeleteAcknowledgementSlideAndTrack();
                dialogOpen = DisplayLoadingDialog(TextCollection.AgendaLabSynchronizingDialogTitle,
                                                  TextCollection.AgendaLabSynchronizingDialogContent);
                currentWindow.ViewType = PpViewType.ppViewNormal;

                BringToFront(refSlide);

                switch (type)
                {
                case Type.Beam:
                    SyncBeamAgenda(slideTracker, refSlide);
                    break;

                case Type.Bullet:
                    SyncBulletAgenda(slideTracker, refSlide);
                    break;

                case Type.Visual:
                    SyncVisualAgenda(slideTracker, refSlide);
                    break;
                }

                PowerPointPresentation.Current.AddAckSlide();
                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                if (dialogOpen)
                {
                    DisposeLoadingDialog();
                }
                currentWindow.ViewType = oldViewType;
            }
        }
        /// <summary>
        /// Assumption: no reference slide exists
        /// </summary>
        private static void CreateBeamAgenda(SlideSelectionTracker slideTracker)
        {
            var refSlide = CreateBeamReferenceSlide();

            var targetSlides = slideTracker.SelectedSlides;
            if (targetSlides.Count == 0)
            {
                // If no slides selected, generate on all slides.
                targetSlides = AllSlidesAfterFirstSection();
            }
            else if (targetSlides.Count == 1)
            {
                // If only one slide selected, ask whether the user wants to generate on all slides.
                var confirmResult = MessageBox.Show(new Form { TopMost = true },
                                                    TextCollection.AgendaLabBeamGenerateSingleSlideDialogContent,
                                                    TextCollection.AgendaLabBeamGenerateSingleSlideDialogTitle,
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    targetSlides = AllSlidesAfterFirstSection();
                }
            }

            // here we invoke sync logic, since it's the same behavior as sync
            SyncBeamOnSlides(targetSlides, refSlide);
        }
 /// <summary>
 /// Called from the Synchronise action only.
 /// </summary>
 private static void SyncBulletAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     AdjustBulletReferenceSlideContent(refSlide);
     SyncBulletAgendaSlides(slideTracker, refSlide);
 }
        private static void RemoveAllAgendaItems(SlideSelectionTracker slideTracker = null)
        {
            if (slideTracker == null) slideTracker = SlideSelectionTracker.CreateInactiveTracker();

            PowerPointPresentation.Current.Slides.Where(AgendaSlide.IsAnyAgendaSlide)
                                                 .ToList()
                                                 .ForEach(slideTracker.DeleteSlideAndTrack);

            PowerPointPresentation.Current.Slides.ToList()
                                                 .ForEach(RemoveBeamAgendaFromSlide);
        }
 /// <summary>
 /// Called from both generate and synchronise actions.
 /// </summary>
 private static void SyncBulletAgendaSlides(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     var sections = Sections;
     SynchroniseSlidesUsingTemplate(slideTracker, refSlide, () => new BulletAgendaTemplate());
 }
        private static void SyncBeamAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
        {
            UpdateBeamReferenceSlide(refSlide);

            SyncBeamOnSlides(slideTracker.SelectedSlides, refSlide);
        }
 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);
 }
Exemple #25
0
        private static void SyncBeamAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
        {
            UpdateBeamReferenceSlide(refSlide);

            SyncBeamOnSlides(slideTracker.SelectedSlides, refSlide);
        }
        /// <summary>
        /// Assumption: no reference slide exists
        /// </summary>
        private static void CreateVisualAgenda(SlideSelectionTracker slideTracker)
        {
            var refSlide = CreateVisualReferenceSlide();

            // here we invoke sync logic, since it's the same behavior as sync
            SyncVisualAgendaSlides(slideTracker, refSlide);
        }
Exemple #27
0
        public static void GenerateAgenda(Type type)
        {
            bool dialogOpen    = false;
            var  currentWindow = Globals.ThisAddIn.Application.ActiveWindow;
            var  oldViewType   = currentWindow.ViewType;

            try
            {
                var slideTracker = new SlideSelectionTracker(SelectedSlides, CurrentSlide);

                if (AgendaPresent())
                {
                    var confirm = MessageBox.Show(TextCollection.AgendaLabAgendaExistError,
                                                  TextCollection.AgendaLabAgendaExistErrorCaption,
                                                  MessageBoxButtons.OKCancel);
                    if (confirm != DialogResult.OK)
                    {
                        return;
                    }

                    RemoveAllAgendaItems(slideTracker);
                }

                if (!ValidSections())
                {
                    return;
                }

                // The process should not abort (return) anytime past this point. Changes will start being made past this point.

                slideTracker.DeleteAcknowledgementSlideAndTrack();

                dialogOpen = DisplayLoadingDialog(TextCollection.AgendaLabGeneratingDialogTitle,
                                                  TextCollection.AgendaLabGeneratingDialogContent);
                currentWindow.ViewType = PpViewType.ppViewNormal;

                switch (type)
                {
                case Type.Beam:
                    CreateBeamAgenda(slideTracker);
                    break;

                case Type.Bullet:
                    CreateBulletAgenda(slideTracker);
                    break;

                case Type.Visual:
                    CreateVisualAgenda(slideTracker);
                    break;
                }

                PowerPointPresentation.Current.AddAckSlide();
                SelectOriginalSlide(slideTracker.UserCurrentSlide, PowerPointPresentation.Current.FirstSlide);
            }
            finally
            {
                if (dialogOpen)
                {
                    DisposeLoadingDialog();
                }
                currentWindow.ViewType = oldViewType;
            }
        }
 /// <summary>
 /// Called from the Synchronise action only.
 /// </summary>
 private static void SyncVisualAgenda(SlideSelectionTracker slideTracker, PowerPointSlide refSlide)
 {
     RegenerateReferenceSlideImages(refSlide);
     SyncVisualAgendaSlides(slideTracker, refSlide);
 }