public static IEnumerable <Effect> GetPPTLEffectsForClick(this PowerPointSlide slide, int clickNo) { DateTime start = DateTime.Now; List <Effect> effects = slide.TimeLine.MainSequence.Cast <Effect>().ToList(); Sequence sequence = slide.TimeLine.MainSequence; try { Effect effectBefore = sequence.FindFirstAnimationForClick(clickNo); Effect effectAfter = sequence.FindFirstAnimationForClick(clickNo + 1); // from idxStart inclusive, idxEnd exclusive int idxStart = effectBefore == null?effects.Count() : effects.IndexOf(effectBefore); int idxEnd = effectAfter == null?effects.Count() : effects.IndexOf(effectAfter); return(effects.GetRange(idxStart, idxEnd - idxStart).Where(x => SelfExplanationTagService.ExtractTagNo(x.Shape.Name) != -1 && x.Exit != Microsoft.Office.Core.MsoTriState.msoTrue)); } catch { // most likely caused by idxStart out of bound return(new List <Effect>()); } }
private void AddItemBelowContextMenu_Click(object sender, RoutedEventArgs e) { ClickItem item = ((MenuItem)sender).CommandParameter as ClickItem; ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty); selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag(); int index; if (item is ExplanationItem) { index = Items.ToList().FindIndex(x => x is ExplanationItem && ((ExplanationItem)x).TagNo == ((ExplanationItem)item).TagNo); } else { index = Items.IndexOf(item); } if (index < listView.Items.Count - 1) { Items.Insert(index + 1, selfExplanationClickItem); } else { Items.Add(selfExplanationClickItem); } isSynced = false; UpdateClickNumAndTriggerInItems(useWorker: false, e: null); ScrollItemToView(selfExplanationClickItem); }
private void CreateButton_Click(object sender, RoutedEventArgs e) { ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty); selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag(); Items.Add(selfExplanationClickItem); isSynced = false; UpdateClickNumAndTriggerInItems(useWorker: false, e: null); ScrollListViewToEnd(); }
private ExplanationItem CreateExpItemFromDictionary(Dictionary <string, string> expItemDic) { ExplanationItem expItem = new ExplanationItem(expItemDic[ELearningLabText.CaptionTextIdentifier], expItemDic[ELearningLabText.CalloutTextIdentifier], expItemDic[ELearningLabText.VoiceLabel], expItemDic[ELearningLabText.CalloutIdentifier] == "Y", expItemDic[ELearningLabText.CaptionIdentifier] == "Y", expItemDic[ELearningLabText.AudioIdentifier] == "Y", tagNo: Convert.ToInt32(expItemDic[ELearningLabText.TagNoIdentifier])); expItem.ClickNo = Convert.ToInt32(expItemDic[ELearningLabText.ClickNumIdentifier]); expItem.TriggerIndex = expItemDic[ELearningLabText.TriggerOnClick] == "Y" ? (int)TriggerType.OnClick : (int)TriggerType.WithPrevious; if (expItem.IsDummyItem) { expItem.tagNo = SelfExplanationTagService.GenerateUniqueTag(); } return(expItem); }
private void AddExplanationItem(ClickItem reference, InsertItemAction action) { ExplanationItem selfExplanationClickItem = new ExplanationItem(captionText: string.Empty); selfExplanationClickItem.tagNo = SelfExplanationTagService.GenerateUniqueTag(); int index = action(reference, selfExplanationClickItem); ExplanationItem template = Items.LastOrDefault(o => o is ExplanationItem && GetItemIndex(o) < index) as ExplanationItem; selfExplanationClickItem.CopyFormat(template); isSynced = false; UpdateClickNumAndTriggerInItems(useWorker: false, e: null); ScrollItemToView(selfExplanationClickItem); }
/// <summary> /// Load custom animations from animation pane separated by click /// </summary> /// <returns>Queue of CustomClickItem</returns> private Queue <CustomItem> LoadCustomClickItems() { int clickNo = FirstClickNumber; Queue <CustomItem> customItems = new Queue <CustomItem>(); List <Effect> effects = slide.TimeLine.MainSequence.Cast <Effect>().ToList(); int startIdx = 0; bool hasReachedEndOfSequence = effects.Count == 0; do { List <CustomEffect> 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 isCustomEffect = SelfExplanationTagService.ExtractTagNo(effect.Shape.Name) == -1; if (isCustomEffect) { if (customEffects.Count == 0 && clickNo > 0) { effect.Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerOnPageClick; } customEffects.Add(new CustomEffect(effect.Shape.Name, effect.Shape.Id.ToString(), EffectToAnimationTypeConverter.GetAnimationTypeOfEffect(effect))); } } CustomItem customClickBlock = new CustomItemFactory(customEffects).GetBlock() as CustomItem; if (customClickBlock != null) { customClickBlock.ClickNo = clickNo; customItems.Enqueue(customClickBlock); } clickNo++; }while (startIdx <= effects.Count - 1 && !hasReachedEndOfSequence); return(customItems); }
protected override ClickItem CreateBlock() { if (effects.Count() == 0) { return(null); } ExplanationItem selfExplanation = new ExplanationItem(captionText: string.Empty); foreach (ELLEffect effect in effects) { string shapeName = effect.shapeName; string functionMatch = StringUtility.ExtractFunctionFromString(shapeName); selfExplanation.tagNo = SelfExplanationTagService.ExtractTagNo(shapeName); switch (functionMatch) { case ELearningLabText.CaptionIdentifier: selfExplanation.IsCaption = true; break; case ELearningLabText.CalloutIdentifier: selfExplanation.IsCallout = true; break; case ELearningLabText.AudioIdentifier: selfExplanation.IsVoice = true; selfExplanation.VoiceLabel = StringUtility.ExtractVoiceNameFromString(shapeName); if (StringUtility.ExtractDefaultLabelFromVoiceLabel(selfExplanation.VoiceLabel) .Equals(ELearningLabText.DefaultAudioIdentifier)) { selfExplanation.VoiceLabel = string.Format(ELearningLabText.AudioDefaultLabelFormat, AudioSettingService.selectedVoice.ToString()); } break; default: break; } } return(selfExplanation); }
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); }
public static IEnumerable <CustomEffect> GetCustomEffectsForClick(this PowerPointSlide slide, int clickNo) { DateTime start = DateTime.Now; List <Effect> effects = slide.TimeLine.MainSequence.Cast <Effect>().ToList(); Sequence sequence = slide.TimeLine.MainSequence; try { Effect effectBefore = sequence.FindFirstAnimationForClick(clickNo); Effect effectAfter = sequence.FindFirstAnimationForClick(clickNo + 1); // from idxStart inclusive, idxEnd exclusive int idxStart = effectBefore == null?effects.Count() : effects.IndexOf(effectBefore); int idxEnd = effectAfter == null?effects.Count() : effects.IndexOf(effectAfter); IEnumerable <Effect> customEffects = effects.GetRange(idxStart, idxEnd - idxStart).Where(x => SelfExplanationTagService.ExtractTagNo(x.Shape.Name) == -1); IEnumerable <CustomEffect> _customEffects = customEffects.Select(x => new CustomEffect(x.Shape.Name, x.Shape.Id.ToString(), EffectToAnimationTypeConverter.GetAnimationTypeOfEffect(x))); if (clickNo > 0 && customEffects.Count() > 0) { customEffects.ElementAt(0).Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerOnPageClick; } return(_customEffects); } catch { // most likely caused by idxStart out of bound return(new List <CustomEffect>()); } }