コード例 #1
0
        private void SyncClickItems()
        {
            bool removeAzureAudioIfAccountInvalid  = false;
            bool removeWatsonAudioIfAccountInvalid = false;

            if (IsAzureVoiceSelected())
            {
                removeAzureAudioIfAccountInvalid = !AzureRuntimeService.IsAzureAccountPresentAndValid;
            }
            if (IsWatsonVoiceSelected())
            {
                removeWatsonAudioIfAccountInvalid = !WatsonRuntimeService.IsWatsonAccountPresentAndValid;
            }
            // also align eLL first item click No to be the same as first click No on animation pane
            SyncCustomAnimationToTaskpane(uncheckAzureAudio: removeAzureAudioIfAccountInvalid,
                                          uncheckWatsonAudio: removeWatsonAudioIfAccountInvalid);
            List <ExplanationItem> items = Items.Where(x => x is ExplanationItem)
                                           .Cast <ExplanationItem>().ToList();
            ELearningService eLearningService = new ELearningService(slide, items);

            RemoveLabAnimationsFromAnimationPane(eLearningService);
            // align first click No on animation pane to be the same as eLL first click No
            AlignFirstClickNumberForCustomItem();
            ELearningLabTextStorageService.StoreSelfExplanationTextToSlide(
                Items.Where(x => x is ExplanationItem && !((ExplanationItem)x).IsEmpty)
                .Cast <ExplanationItem>().ToList(), slide);
            SyncLabItemToAnimationPane(eLearningService);
        }
コード例 #2
0
        private ObservableCollection <ClickItem> LoadItems(DoWorkEventArgs e)
        {
            SelfExplanationTagService.Clear();
            int clickNo = FirstClickNumber;
            ObservableCollection <ClickItem>    customItems      = new ObservableCollection <ClickItem>();
            ObservableCollection <ClickItem>    clickItems       = new ObservableCollection <ClickItem>();
            List <Dictionary <string, string> > explanationItems =
                ELearningLabTextStorageService.LoadSelfExplanationsFromSlide(slide);
            ClickItem customClickBlock;

            SelfExplanationTagService.PopulateTagNos(slide.GetShapesWithNameRegex(ELearningLabText.PPTLShapeNameRegex)
                                                     .Select(x => x.Name).ToList());
            HashSet <int>       tagNums  = new HashSet <int>();
            List <Effect>       effects  = slide.TimeLine.MainSequence.Cast <Effect>().ToList();
            int                 startIdx = 0;
            bool                hasReachedEndOfSequence = effects.Count == 0;
            List <CustomEffect> customEffects           = new List <CustomEffect>();
            List <ELLEffect>    pptlEffects             = new List <ELLEffect>();

            do
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                customEffects = new List <CustomEffect>();
                for (int i = startIdx; i < effects.Count; i++)
                {
                    Effect effect = effects.ElementAt(i);
                    if (i > startIdx && effect.Timing.TriggerType == MsoAnimTriggerType.msoAnimTriggerOnPageClick)
                    {
                        startIdx = i;
                        break;
                    }
                    if (i == effects.Count - 1)
                    {
                        hasReachedEndOfSequence = true;
                    }
                    bool isPPTLEffect = SelfExplanationTagService.ExtractTagNo(effect.Shape.Name) != -1;
                    if (!isPPTLEffect)
                    {
                        customEffects.Add(new CustomEffect(effect.Shape.Name, effect.Shape.Id.ToString(),
                                                           EffectToAnimationTypeConverter.GetAnimationTypeOfEffect(effect)));
                    }
                }
                customClickBlock =
                    new CustomItemFactory(customEffects).GetBlock();
                if (customClickBlock != null)
                {
                    customClickBlock.ClickNo = clickNo;
                    customItems.Add(customClickBlock);
                }
                clickNo++;
            }while (startIdx <= effects.Count - 1 && !hasReachedEndOfSequence);

            while (explanationItems != null && explanationItems.Count > 0 && customItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                ExplanationItem expItem    = CreateExpItemFromDictionary(explanationItems.First());
                CustomItem      customItem = customItems.ElementAt(0) as CustomItem;
                if (customItem.ClickNo <= expItem.ClickNo)
                {
                    clickItems.Add(customItem);
                    customItems.RemoveAt(0);
                }
                else
                {
                    clickItems.Add(expItem);
                    explanationItems.RemoveAt(0);
                }
            }
            while (explanationItems != null && explanationItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                ExplanationItem expItem = CreateExpItemFromDictionary(explanationItems.First());
                explanationItems.RemoveAt(0);
                clickItems.Add(expItem);
            }
            while (customItems.Count > 0)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return(clickItems);
                }
                CustomItem customItem = customItems.ElementAt(0) as CustomItem;
                customItems.RemoveAt(0);
                clickItems.Add(customItem);
            }
            return(clickItems);
        }